$(document).ready(function(){
	$("div.title a").click(function(event) {
		event.stopImmediatePropagation();		
	});

	$("div.subtitle a").click(function(event) {
		event.stopImmediatePropagation();		
	});
	
	$("li.navi1item .title").click(function() {
		$(this).nextAll().toggle();
		if($(this).next().css("display") == "none") {
			$(this).children('img').css("display","inline");
		}
		else {
			$(this).children('img').css("display","none");
		}
	});	
		
	$(".fancygallery").fancybox({			
		'overlayOpacity' : '0.8',
		'overlayColor' : '#000',			
		'hideOnContentClick': false	
	});
	
	$("img.img190:last").css("margin","0px");
	
	$("div.cleardiv20px:last").css("height","1px");
	
	$("#pageflip").fancybox({			
		'overlayOpacity' : '0.8',
		'overlayColor' : '#000',			
		'hideOnContentClick' : false,
		'type' : 'iframe',
		'width' : 872,
		'height' : 642,
		'scrolling' : 'no'
	});
	
	if(navigator.platform == 'iPad' || navigator.platform == 'iPhone' || navigator.platform == 'iPod') {
    	$("#footer").css("position", "static");
	};

});

var i = 0;
var myImages = new Array();

function preloadImages() {
	if (i<backgroundImages.length) {
		theImage = backgroundImages[i];
		i++;
		setTimeout("doPreload(theImage);",750)
	}
}

function doPreload(theImage) {
	myImages[i] = new Image();
	myImages[i].src = theImage;
	preloadImages();
}

function silentErrorHandler() {
	return true;
}

//window.onerror = silentErrorHandler;

$(window).load(function(){

	var parent_height = 88;
	var parent_width = 88;

	imprThumbs = $('div.imprthumb img');	
	
	for(i=0; i<imprThumbs.length; i++) {	
		//get the width of the image
		var image_height = $(imprThumbs[i]).height();
		var image_width = $(imprThumbs[i]).width();
	
		//calculate how far from top the image should be
		var top_margin = (parent_height - image_height)/2;
		var left_margin = (parent_width - image_width)/2;
	
		//and change the margin-top css attribute of the image
		$(imprThumbs[i]).css( 'margin-top' , top_margin);
		$(imprThumbs[i]).css( 'margin-left' , left_margin);	
	}
});


function popNewsletter(inout) {
    address = document.forms["optinout"].elements[0].value;
    if(address && (address!="Ihre E-Mail Adresse") && (address!="Your E-Mail address") && (address!="Votre adresse e-mail")) {
        var url = "http://letters.popletter.com/getzner/optinout.php?inOut="+inout+"&address="+address+"&l=11";
        window.open(url,"optWin","width=300,height=180,top=50,left=100,scrollbars=no");
    }
    else {
    	if(jsLang == "en") {
    		alert("Please enter your E-Mail address.");
	     }
    	else if(jsLang == "fr") {
	        alert("Merci d´entrer votre adresse e-mail.");
	     }	     
	     else {
	        alert("Bitte geben Sie eine Adresse ein.");
	     }
    }
}

function newsletterFocus() {
    address = document.forms["optinout"].elements[0].value;    
	if((address=="Ihre E-Mail Adresse") || (address=="Your E-Mail address") || (address=="Votre addresse e-mail")) {
		document.forms["optinout"].elements[0].value = "";
	}
}
