// JavaScript Document

	$("#teaser4").css('zIndex', -100);


$(document).ready(function(){       
    compressed = false;
	
	teaserHeight = 380;	
	/*alert(teaserHeight);*/

	 /*if (contactError == 1){
		 $("#intro_wrapper").height(600);
		 }
	*/	
		$("#indexGallery").click(function () {
			expand();
		});
	
	$("#btnSubmit").click(function () {
		$("#error_msg").addClass('displayBlock');								
		}
	);
	
	$("#contactToggle").click(function () {
      
	  contentHeight = $("#teaser4").height() + $("#error_msg").height();
	  teaserHeight = $("#teaser3").height();
	  
	  if ($("#kontaktSlider").is(":hidden")) {
		showContact();

	  } else {
		hideContact();
	  }
    });
	
	$("#teaser1").click(function () {
      var contentHeight = $("#content1").height();
	 /* var teaserHeight = $("#teaser1").height();*/
	  
	  if ($("#content1").is(":hidden")) {
		  
		$("#teaser1").css('zIndex', 40);
		$("#teaser2").css('zIndex', 30);
		$("#teaser3").css('zIndex', 20);
		
		$("#teaser1").addClass("white");
		$("#teaser2").removeClass("white");
		$("#teaser3").removeClass("white");
		
		$("#content1").fadeIn("slow");
		$("#content2").fadeOut("slow");
		$("#content3").fadeOut("slow");
		
		hideTeaserContent();
	
		if(compressed == false){
			compress();
		}
		$("#intro_wrapper").height(contentHeight-150);
		
		if($("#kontaktSlider").is(":visible	")) {
			hideContact();
		}

		
      } else {
		hideContent1();
	    $("#intro_wrapper").height(teaserHeight);
		
	  }
    });
	
	$("#teaser2").click(function () {
       var contentHeight = $("#content2").height();
	  /* var teaserHeight = $("#teaser2").height();*/
	  
	  if ($("#content2").is(":hidden")) {
		  
		  $("#teaser1").css('zIndex', 30);
		  $("#teaser2").css('zIndex', 40);
		  $("#teaser3").css('zIndex', 20);
			
		$(this).addClass("white");
		$("#teaser1").removeClass("white");
		$("#teaser3").removeClass("white");
		
		$("#content1").fadeOut("slow");
		$("#content2").fadeIn("slow");
		$("#content3").fadeOut("slow");
		
		hideTeaserContent();
		
		if (compressed == false){
			compress();
			}
		$("#intro_wrapper").height(contentHeight-150);
		
		if($("#kontaktSlider").is(":visible	")) {
			hideContact();
		}
		
      } else {
		hideContent2();
	  }
    });
	
	
	$("#teaser3").click(function () {
       contentHeight = $("#content3").height();
	  /* teaserHeight = $("#teaser3").height();*/
	   	  
	  if ($("#content3").is(":hidden")) {
				
		  $("#teaser1").css('zIndex', 30);
		  $("#teaser2").css('zIndex', 20);
		  $("#teaser3").css('zIndex', 40);
		
		$(this).addClass("white");
		$("#teaser1").removeClass("white");
		$("#teaser2").removeClass("white");
		
		$("#content3").fadeIn("slow");
		$("#content2").fadeOut("slow");
		$("#content1").fadeOut("slow");
		
		hideTeaserContent();
		
		if (compressed == false){
			compress();
			}
		$("#intro_wrapper").height(contentHeight-150);
		
		if($("#kontaktSlider").is(":visible	")) {
			hideContact();
		}
		
      } else {
		hideContent3();
	    }
    });
	
	
	$("#galleryToggle").click(function () {
      if (compressed == false) {
		compress();
      } else {
		expand();
		}
	/*  if (compressed == true) {compressed = false;} else {compressed = true;}*/
    });
  if (contactError == 0){
		$("#kontaktSlider").addClass("displayNone");
		$("#teaser4").removeClass("white");
		$("#kontaktSlider h3").show();
		$("#intro_wrapper").height(teaserHeight);
		
	} else {
		$("#teaser4").addClass("white");
		$("#logo").animate({top:"-=145"});
		$("#teaser4").animate({top:"-=145"});
		$("#kontaktSlider h3").hide();
		/*$("#intro_wrapper").height($("#error_msg").height() + $("#teaser4").height() + 60);*/
		$("#intro_wrapper").height(550);
		$("#kontaktSlider").removeClass("displayNone");
		$("#kontaktSlider").show();	
		contactError = 0;
		hideContent1();
		hideContent2();
		hideContent3();
	};
 
});

function hideTeaserContent() {
		$("#teaserContent1").fadeTo(500, 0);
		$("#teaserContent2").fadeTo(500, 0);
		$("#teaserContent3").fadeTo(500, 0);
		}

  function hideContent1() {
		$("#teaser1").removeClass("white");
        $("#content1").fadeOut("slow");
	    $("#teaserContent1").fadeTo(500, 1);
		$("#teaserContent2").fadeTo(500, 1);
		$("#teaserContent3").fadeTo(500, 1);
		if (compressed == true) {
		expand();
		}
		 $("#intro_wrapper").height(teaserHeight);
		}
		
		function hideContent2() {
		$("#teaser2").removeClass("white");
        $("#content2").fadeOut("slow");
	    $("#teaserContent1").fadeTo(500, 1);
		$("#teaserContent2").fadeTo(500, 1);
		$("#teaserContent3").fadeTo(500, 1);
		if (compressed == true) {
		expand();
		}
		 $("#intro_wrapper").height(teaserHeight);
		}

function hideContent3() {
		$("#teaser3").removeClass("white");
        $("#content3").fadeOut("slow");
	    $("#teaserContent1").fadeTo(500, 1);
		$("#teaserContent2").fadeTo(500, 1);
		$("#teaserContent3").fadeTo(500, 1);
		if (compressed == true) {
		expand();
		}
		 $("#intro_wrapper").height(teaserHeight);
		}

function compress() {
	
	if (compressed == false){
		$("#galleryToggle").fadeIn("slow");
		$("#logo").animate({top:"+=250"},600,"easeInOutQuad");
		$("#teaser4").animate({top:"+=250"},600,"easeInOutQuad");
		$("#header_index").animate({top:"-=250"},600,"easeInOutQuad");
		$("#intro_wrapper").animate({top:"-=250"},800,"easeInOutQuad");
			
		compressed = true;
		}
}
	
function expand() {
	if (compressed == true){
		$("#galleryToggle").fadeOut("slow");
		$("#logo").animate({top:"-=250"},600,"easeInOutQuad");
		$("#teaser4").animate({top:"-=250"},600,"easeInOutQuad");
		$("#header_index").animate({top:"+=250"},600,"easeInOutQuad");
		$("#intro_wrapper").animate({top:"+=250"},800,"easeInOutQuad");
				
		compressed = false;
		}
}

function showContact(){
		$("#logo").animate({top:"-=145"},600,"easeInOutQuad");
		$("#teaser4").animate({top:"-=145"},800,"easeInOutQuad");
		$("#teaser4").addClass("white");
		$("#kontaktSlider").fadeIn("slow");
		/*$("#intro_wrapper").height(contentHeight);*/
		$("#contactToggle h3").fadeTo(500,0);
		
}

function hideContact()
		{
			$("#logo").animate({top:"+=145"},600,"easeInOutQuad");
			$("#teaser4").animate({top:"+=145"},800,"easeInOutQuad");
			$("#teaser4").removeClass("white");
			
			
		$("#kontaktSlider").fadeOut("slow");
		$("#kontaktSlider").slideUp("slow");
		$("#intro_wrapper").height(teaserHeight);
		$("#contactToggle h3").fadeTo(500,1);
}