//Zentriertes Window aufpoppen--------------------------------------------------------------------------
function popfunc(URL, breite, hoehe)
{
	if (!breite){var breite=420;}
	if (!hoehe)	{var hoehe=415;}
	
	var top=(screen.availHeight-hoehe)/2;
	var left=(screen.availWidth-breite)/2;
	var args = "height="+hoehe+", width="+breite+",menubar=0,resizable=1,scrollbars=0,status=0,titlebar=0,toolbar=0,left="+left+",top="+top;
	popwin=window.open(URL,'popname',args);
	popwin.focus();
}

function poptext(URL, breite, hoehe)

{
	if (!breite){var breite=450;}
	if (!hoehe)	{var hoehe=450;}

	var top=(screen.availHeight-hoehe)/2;
	var left=(screen.availWidth-breite)/2;
	var args = "height="+hoehe+", width="+breite+",menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left="+left+",top="+top;
	poptextwin=window.open(URL,'poptextname',args);
	poptextwin.focus();
}

if(window.navigator.systemLanguage && !window.navigator.language) {
	function hoverIE() {
		var LI = document.getElementById("mainNav").firstChild.firstChild;
		do {
			if (sucheUL(LI.firstChild)) {
				LI.onmouseover=einblenden; LI.onmouseout=ausblenden;
			}
			LI = LI.nextSibling;
		}
		while(LI);
	}
	
	function sucheUL(UL) {
		do {
			if(UL) UL = UL.nextSibling;
			if(UL && UL.nodeName == "UL") return UL;
		}
		while(UL);
		return false;
	}
	
	function einblenden() {
		var UL = sucheUL(this.firstChild);
		UL.style.display = "block"; UL.style.backgroundColor = "silver";
	}
	
	function ausblenden() {
		sucheUL(this.firstChild).style.display = "none";
	}
	
	window.onload=hoverIE;
}
				
$(document).ready(function() {
	
	if($("body").hasClass("home")) {
		//Box 1
		$("#box01 .wrapCorner").click(function() {
			console.log("Klick " + $(this).css("bottom"));
			if($(this).css("bottom") == "0px") {
				console.log("+");
				$(this).siblings(".wrapImg").animate({
						"top": "-171px",
						"left": "-171px"
					},"slow");
				$(this).animate({
						"bottom": "171px",
						"right": "171px"
					},"slow", function(){
							$("#box01 .wrapImg").css("display","none");
							$("#box01 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
						});
			} else {
				console.log("-");
				$(this).siblings(".wrapImg").css("display","block").animate({
					"top": "0px",
					"left": "0px"
				},"slow");
				$(this).animate({
					"bottom": "0px",
					"right": "0px"
				},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
			}
		});
		//Box 2
		$("#box02 .wrapCorner").click(function() {
			if($(this).css("bottom") == "0px") {
				$(this).siblings(".wrapImg").animate({
						"top": "-171px",
						"left": "-171px"
					},"slow");
				$(this).animate({
						"bottom": "171px",
						"right": "171px"
					},"slow", function(){
							$("#box02 .wrapImg").css("display","none");
							$("#box02 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
						});
			} else {
				$(this).siblings(".wrapImg").css("display","block").animate({
					"top": "0px",
					"left": "0px"
				},"slow");
				$(this).animate({
					"bottom": "0px",
					"right": "0px"
				},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
			}
		});
		//Box 3
		$("#box03 .wrapCorner").click(function() {
			if($(this).css("bottom") == "0px") {
				$(this).siblings(".wrapImg").animate({
						"top": "-171px",
						"left": "-171px"
					},"slow");
				$(this).animate({
						"bottom": "171px",
						"right": "171px"
					},"slow", function(){
							$("#box03 .wrapImg").css("display","none");
							$("#box03 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
						});
			} else {
				$(this).siblings(".wrapImg").css("display","block").animate({
					"top": "0px",
					"left": "0px"
				},"slow");
				$(this).animate({
					"bottom": "0px",
					"right": "0px"
				},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
			}
		});
		//Box 4
		$("#box04 .wrapCorner").click(function() {
			if($(this).css("bottom") == "0px") {
				$(this).siblings(".wrapImg").animate({
						"top": "-171px",
						"left": "-171px"
					},"slow");
				$(this).animate({
						"bottom": "171px",
						"right": "171px"
					},"slow", function(){
							$("#box04 .wrapImg").css("display","none");
							$("#box04 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
						});
			} else {
				$(this).siblings(".wrapImg").css("display","block").animate({
					"top": "0px",
					"left": "0px"
				},"slow");
				$(this).animate({
					"bottom": "0px",
					"right": "0px"
				},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
			}
		});
		//Box 5
		$("#box05 .wrapCorner").click(function() {
			if($(this).css("bottom") == "0px") {
				$(this).siblings(".wrapImg").animate({
						"top": "-171px",
						"left": "-367px"
					},"slow");
				$(this).animate({
						"bottom": "171px",
						"right": "367px"
					},"slow", function(){
							$("#box05 .wrapImg").css("display","none");
							$("#box05 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
						});
			} else {
				$(this).siblings(".wrapImg").css("display","block").animate({
					"top": "0px",
					"left": "0px"
				},"slow");
				$(this).animate({
					"bottom": "0px",
					"right": "0px"
				},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
			}
		});
		//Box 7
		$("#box07 .wrapCorner").click(function() {
			if($(this).css("bottom") == "0px") {
				$(this).siblings(".wrapImg").animate({
						"top": "-171px",
						"left": "-367px"
					},"slow");
				$(this).animate({
						"bottom": "171px",
						"right": "367px"
					},"slow", function(){
							$("#box07 .wrapImg").css("display","none");
							$("#box07 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
						});
			} else {
				$(this).siblings(".wrapImg").css("display","block").animate({
					"top": "0px",
					"left": "0px"
				},"slow");
				$(this).animate({
					"bottom": "0px",
					"right": "0px"
				},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
			}
		});		
		//Box 8
		$("#box08 .wrapCorner").click(function() {
			if($(this).css("bottom") == "0px") {
				$(this).siblings(".wrapImg").animate({
						"top": "-171px",
						"left": "-171px"
					},"slow");
				$(this).animate({
						"bottom": "171px",
						"right": "171px"
					},"slow", function(){
							$("#box08 .wrapImg").css("display","none");
							$("#box08 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
						});
			} else {
				$(this).siblings(".wrapImg").css("display","block").animate({
					"top": "0px",
					"left": "0px"
				},"slow");
				$(this).animate({
					"bottom": "0px",
					"right": "0px"
				},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
			}
		});		
		
		$('#nivo-slider').nivoSlider({
			effect:'sliceUpDown', // Specify sets like: 'fold,fade,sliceDown'
			slices: 3,
			boxCols: 9, // For box animations
			boxRows: 3, // For box animations
			animSpeed: 1000, // Slide transition speed
			pauseTime: 7000, // How long each slide will show
			startSlide: 0, // Set starting Slide (0 index)
			directionNav: false, // Next & Prev navigation
			directionNavHide: false, // Only show on hover
			controlNav: false, // 1,2,3... navigation
			controlNavThumbs: false, // Use thumbnails for Control Nav
			controlNavThumbsFromRel: false, // Use image rel for thumbs
			controlNavThumbsSearch: '.jpg', // Replace this with...
			controlNavThumbsReplace: '_thumb.jpg', // ...this in thumb Image src
			keyboardNav: false, // Use left & right arrows
			pauseOnHover: false, // Stop animation while hovering
			manualAdvance: false, // Force manual transitions
			captionOpacity: 0.8, // Universal caption opacity
			prevText: '<-', // Prev directionNav text
			nextText: '->', // Next directionNav text
			beforeChange: function(){}, // Triggers before a slide transition
			afterChange: function(){}, // Triggers after a slide transition
			slideshowEnd: function(){}, // Triggers after all slides have been shown
			lastSlide: function(){}, // Triggers when last slide is shown
			afterLoad: function(){} // Triggers when slider has loaded
		});
		
												
	}//if($("body").hasClass("home")) {
	
	//Box 6 gibt es nicht nur auf der Startseite und kann deshalb immer animiert werden
	$("#box06 .wrapCorner").click(function() {
		if($(this).css("bottom") == "0px") {
			$(this).siblings(".wrapImg").animate({
					"top": "-171px",
					"left": "-563px"
				},"slow");
			$(this).animate({
					"bottom": "171px",
					"right": "563px"
				},"slow", function(){
						$("#box06 .wrapImg").css("display","none");
						$("#box06 .wrapCorner").css("background","transparent url(/images/chrome/assets.png) 0 -27px no-repeat");	
					});
		} else {
			$(this).siblings(".wrapImg").css("display","block").animate({
				"top": "0px",
				"left": "0px"
			},"slow");
			$(this).animate({
				"bottom": "0px",
				"right": "0px"
			},"slow").css("background","transparent url(/images/chrome/assets.png) 0 0 no-repeat");
		}
	});
	

	
});	
