// JavaScript Document
//addThis Config:
var addthis_config = {
	ui_cobrand: "EXPOformer",
   	ui_header_color: "#5C5C5C",
    ui_header_background: "#EEEFEF",
	services_compact: 'facebook,linkedin,twitter,google,misterwong_de,yigg,delicious,stumbleupon,technorati,favorites,email',
 	services_expanded: '',
	services_exclude: 'print, more'
}

$(document).ready(  function(){ 
	//$('DIV#panel-inner').pngFix({blankgif:'../images/blank.gif'});


/// GALERIE-LISTEN
$('DIV.galitem-1col, DIV.galitem-2col').hover(function() {
        $(this).addClass('hover');
      }, function() {
        $(this).removeClass('hover');
});	
// die ganze box anklickbar machen:
$('DIV.galitem-1col,DIV.galitem-2col').click(function() {
		  var linkziel = $(this).find('a:first').attr('href');
		  var TBLink = $(this).find('a:first').attr('class');
		  if(linkziel != undefined && linkziel.length >=3) {
			  if(TBLink) {
				  tb_show("",linkziel);
			} else {
			// normaler link
			 // fix wegen coolURI...
			document.location.href = document.location.protocol + "//" + document.location.host +"/" + linkziel;
		  }
		  }
});
// required fields formular:
$('INPUT#nachname,INPUT#vorname,INPUT#firma,INPUT#strassenr,INPUT#plz,INPUT#ort,INPUT#email ').addClass('req-field');
// validate signup form on keyup and submit
	var validator = $("#kontaktform").validate({
		validClass: "req-valid",
		errorClass: "req-field",
		ignore: ".fignore",
		rules: {
			"formhandler[vorname]": "required",
			"formhandler[nachname]": "required",
			"formhandler[firma]": "required",
			"formhandler[strassenr]": "required",			
			"formhandler[plz]": {
				required: true,
				minlength: 4
			},
			"formhandler[ort]": "required",			
			"formhandler[email]": {
				required: true,
				email: true
			}
		},
		errorPlacement: function(error, element) {
			 // nix machen
		},
		highlight: function(element, errorClass) {
			 $(element).removeClass("req-valid");
			 $(element).addClass(errorClass);
		  },
		success: function(label) {
			// 
		}
	});












// formular zeilen-highlight:
	$('tr.tbl-indicate').hover(
 		  function() {
   			 $(this).addClass("tbl-ro");
   			},
  		 function() {
    		$(this).removeClass("tbl-ro");
  		 }
  	);


	
// ende document.ready:	
});

// SHOWCASE-POPUP
function nwsc_init() { 
	
	//einstellungen fuer runde ecken im IE:
	var settingsRund = {
      tl: { radius: 10 },
      tr: { radius: 10 },
      bl: { radius: 10 },
      br: { radius: 10 },
      antiAlias: true
    }
	 var settingsBtn = {
      bl: { radius: 10 },
      antiAlias: true
    }
  
// clik-handler fuer rollover navigation nur zeigen wenn link da ist:
	var linkNext = $('#nwsc-btn-next').attr('href');
	if(linkNext) {
	$('#nwsc_nextLink').show();
	$('#nwsc_nextLink').click(function() {	
			tb_show("",linkNext);
		});
	}
	var linkPrev = $('#nwsc-btn-prev').attr('href');
	if(linkPrev) {
	$('#nwsc_prevLink').show();
		$('#nwsc_prevLink').click(function() {	
				tb_show("",linkPrev);
			});
	}
	
	$('#nwsc_loading').show();
	
	
// pruefe bildgroesse:	
	var imgW = $('#nwsc-grossbild').width();
	var imgH = $('#nwsc-grossbild').height();
	
			//skalierung fuer zu hohe bilder
			var wS = $.clientSize();
			var x = wS.width - 150;
			var y = wS.height - 200;
			

			if(imgH >= y) {			
				var Tquot = (y/imgH);
				var tW = Math.floor(imgW * Tquot);
				var tH = Math.floor(imgH * Tquot);
				imgH = tH;

				imgW = tW;
				$('img#nwsc-grossbild').attr('height',imgH);
				$('img#nwsc-grossbild').attr('width',imgW);

				  
			}
			if(imgW <= 630) {
				imgW = 630;
			}
			
			TB_WIDTH = (imgW*1) + 22;
			TB_HEIGHT = (imgH*1) + 106;
	
			ajaxContentW = TB_WIDTH;
			ajaxContentH = TB_HEIGHT ;
	
// thickbox neu ausrichten:	
	tb_position();


// fertig - die box etwas animieren, preloader einsetzen und IE-styles anwenden:
	   $('#TB_ajaxContent').animate({width: ajaxContentW, left:0, top: 0, height: ajaxContentH},300,'linear',function(){
				if ($.browser.msie)  {
					curvyCorners(settingsRund, ".nwsc_rounded");
					curvyCorners(settingsBtn, ".nwsc_closerounded");
				}				
				// bild korrekt vorladen
				$('#nwsc-grossbild').css('display','none');
				img = new Image();// preload image
				img.onload = function(){
							$('#nwsc_loading').css('display','none');
							$('#nwsc-grossbild, #nwsc-bottom').fadeIn(200);							
						}
				img.src = $('#nwsc-grossbild').attr('src');
	});

}

$.clientSize = function() {
     var dimensions = {width: 0, height: 0};
     if (document.documentElement) {
         dimensions.width = document.documentElement.offsetWidth;
         dimensions.height = document.documentElement.offsetHeight;
     } else if (window.innerWidth && window.innerHeight) {
         dimensions.width = window.innerWidth;
         dimensions.height = window.innerHeight;
     }
     return dimensions;
}


