function load_header(){
	$("#header_top").animate({left: 0, top:0}, {duration: 1000, easing: "easeInOutExpo"});
}
function load_bottom(){
	$("#bg_bottom").animate({left: 0, top:235}, {duration: 1400, easing: "easeInOutExpo"});
}
	
function load_btns(){
	$("#btn_1").animate({left:36, top:118,opacity: 0.5},{duration: 1000, easing: "easeOutExpo"});
	$("#btn_2").animate({left:168, top:118,opacity: 0.5},{duration: 1100, easing: "easeOutExpo"});
	$("#btn_3").animate({left:300, top:118,opacity: 0.5},{duration: 1200, easing: "easeOutExpo"});
}
function load_logo(){
	$("#logo").animate({left:46, top:24},{duration: 1000, easing: "easeOutExpo"});

}
function load_baselines(){
	$("#baseline_1").fadeIn(200);
	$("#baseline_2").fadeIn({duration: 1100, easing: 'easeOutExpo'});
	$("#baseline_3").fadeIn({duration: 1200, easing: "easeOutExpo"});
}
function load_shadow(){
	$("#shadow").animate({left:0, top:220},{duration: 1600, easing: "easeInOutExpo"});

}
function open_stage(new_item,old_item){

	switch(new_item){
		case "1":

			$("#bg_bottom").stop().animate({left: 0, top:900, height:400, opacity:0}, {duration: 1400, easing: "easeInOutExpo"});
			//$("#display_bg").stop().animate({top:750, height:20, opacity:0}, {duration: 1000, easing: "easeInOutExpo"});
			if(old_item!="" && old_item!="4"){
				$("#submenu").fadeOut(600);
				$("#con_"+sub_active).stop().animate({opacity: 0,top:200},{duration: 1000, easing: "easeInOutExpo", complete: function(){ $("#display").empty();getContent("0");}});
			}else{
				$("#display").stop().animate({ opacity:0}, {duration: 1000, easing: "easeInOutExpo", complete: function(){ $("#display").empty();getContent("0");}});
			}
		break;
		
		case "2":
			
			$("#bg_bottom").stop().animate({left: 0, top:900, height:400, opacity:0}, {duration: 1400, easing: "easeInOutExpo"});
			//$("#display_bg").stop().animate({top:750, height:20, opacity:0}, {duration: 1000, easing: "easeInOutExpo"});
			if(old_item!="" && old_item!="4"){
				$("#submenu").fadeOut(600);
				$("#con_"+sub_active).stop().animate({opacity: 0,top:200},{duration: 1000, easing: "easeInOutExpo", complete: function(){ $("#display").empty();getContent("1");}});
			}else{
				$("#display").stop().animate({ opacity:0}, {duration: 1000, easing: "easeInOutExpo", complete: function(){ $("#display").empty();getContent("1");}});
			}
		break;
		
		case "3":

			$("#bg_bottom").stop().animate({left: 0, top:900, height:400, opacity:0}, {duration: 1400, easing: "easeInOutExpo"});
			//$("#display_bg").stop().animate({top:750, height:20, opacity:0}, {duration: 1000, easing: "easeInOutExpo"});
			if(old_item!="" && old_item!="4"){
				$("#submenu").fadeOut(600);
				$("#con_"+sub_active).stop().animate({opacity: 0,top:200},{duration: 1000, easing: "easeInOutExpo", complete: function(){  $("#display").empty();getContent("2");}});
			}else{
				$("#display").stop().animate({opacity:0}, {duration: 1000, easing: "easeInOutExpo", complete: function(){  $("#display").empty();getContent("2");}});
			}
		break;
		
		case "4":
			if(old_item!="" && old_item!="4"){
				//$("#display_bg").stop().animate({top:750, height:20, opacity:0}, {duration: 1000, easing: "easeInOutExpo"});
				$("#submenu").fadeOut(600);
				$("#con_"+sub_active).stop().animate({opacity: 0,top:200},{duration: 1000, easing: "easeInOutExpo", complete: function(){  $("#display").empty();$("#bg_bottom").stop().animate({left: 0, top:235, height:500, opacity:1}, {duration: 1000, easing: "easeOutExpo"});}});
				//$("#display").stop().animate({ opacity:0}, {duration: 1000, easing: "easeInOutExpo", complete: function(){  $("#display").empty();$("#bg_bottom").stop().animate({left: 0, top:235, height:500, opacity:1}, {duration: 1000, easing: "easeOutExpo"});}});
			}

			
		break;
	
	
	
	
	}
}	



function load_btn_hover(){
	$("#btn_1, #btn_2, #btn_3").hover(function () {	
		if(this!=active){
			//$(this).stop().animate({opacity: 1},{duration: 2000, easing: "easeOutExpo"});
			$(this).stop().animate({opacity: 1,top:108, height:118},{duration: 700, easing: "easeOutExpo"});
			//$("#baseline_"+this.id.charAt(4)).stop().animate({opacity: 1},{duration: 2000, easing: "easeOutExpo"});
			}
		}, function(){				
		if(this==active){
			$(this).stop().animate({opacity: 1,top: 118,height:104},{duration: 1500, easing: "easeOutExpo"});
		}else{
			$(this).stop().animate({opacity: 0.4,top: 118,height:104},{duration: 1500, easing: "easeOutExpo"});
			//$("#baseline_"+this.id.charAt(4)).stop().animate({opacity: 0.3},{duration: 2000, easing: "easeOutExpo"});
		}
	});
	
	
}
function getContent(cat){
	
	$.ajax({
	   	type: "GET",
	   	url: "_program.php",
	   	dataType:"html",
	   	data: "action=load_content&cat="+cat,
		contentType: "application/x-www-form-urlencoded;charset=ISO-8859-15",

		beforeSend:function(){
 			$("#loader_1").fadeIn("fast");
 		},



	   success: function(html){	
	   		$("#display").append(html);
	   		
	   },
	   complete: function(){
		$("#loader_1").fadeOut("fast");   
		$("#display").stop().animate({top:0, opacity:1}, {duration: 100, easing: "easeInOutExpo"});
		
		
		//$("#con_display").stop().animate({top:500, opacity:0}, {duration: 10, easing: "easeInOutExpo"});
	   	//$("#con_display").animate({top:300, opacity:1}, {duration: 1400, easing: "easeInOutExpo"});
		
 
	   $(".thumb").hover(function () {	
					//$(this).append("<div style='position:absolute; width:100%; height:100%; background-color:#ffffff;'></div>");
					$(this).stop().animate({opacity: 0},{duration: 200, easing: "easeOutExpo"});
					$(this).stop().animate({opacity: 0.7},{duration: 600, easing: "easeOutExpo"});
				}, function(){	
					$(this).stop().animate({opacity: 1},{duration: 600, easing: "easeOutExpo"});
		});
	   	$(".thumb").click(function () {	pic_zoom=true;});
		/* This is basic - uses default settings */ 
		//$("a#single_image").fancybox(); /* Using custom settings */ 
		//$("a#inline").fancybox({ 'hideOnContentClick': true }); 
		//$("a.group").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false });
		//$("a#thumb_0 a").fancybox({ 'zoomSpeedIn': 1, 'zoomSpeedOut': 1, 'overlayShow': true,'overlayOpacity':0.8}); 

	   }
	   

	 });


}
function close_zoom(){
	$("#shutter").stop().animate({top:800,opacity:0},{duration: 700,easing: "easeInExpo"});
	$("#shutter").animate({top:1000,height:2,opacity:0},{duration: 10});
	$("#pic_box").stop().animate({top:800, opacity:0}, {duration: 700, easing: "easeInExpo", complete: function(){ $("#pic_box").empty();}});
	$("#pic_box").animate({top:1000,opacity:0},{duration: 10});
	pic_zoom=false;
	
	$("#shutter").unbind("click");
return false;
	
}

function activate_sensitive_shutter(){
	$("#btn_close_zoom,#shutter").click(function () {
			close_zoom();								 	
	}); 

}



function getPic(maincat,subcat,pic,job){
	s_height=screen.height+250;
	//alert(maincat+"-"+pic+"-"+job);
	$.ajax({
	   type: "GET",
	   url: "_program.php",
	   dataType:"html",
	   data: "action=load_pic&maincat="+maincat+"&subcat="+subcat+"&pic="+pic,
	   beforeSend:function(){
		   	if(job=="new"){
				$("#loader_1").fadeIn("fast");
				//$("#shutter").stop().animate({top:102,opacity:0},{duration: 0});
				//$("#shutter").stop().animate({top:102, height:s_height, width:"100%",opacity:0.85},{duration: 1000, easing: "easeOutExpo"});
				
			}else{
				$("#loader_2").fadeIn("fast");
				$("#pic_box").stop().animate({top:102, opacity:0}, {duration: 600});	
			}
		   	
	   		
			

	   },
	   
	   success: function(html){	
	   		$("#pic_box").empty();
	   		$("#pic_box").append(html);
	   		
	   },
	   complete: function(){
		$("#loader_1").fadeOut("fast");
		$("#loader_2").fadeOut("fast");
		if(job=="new"){
			$("#shutter").stop().animate({top:102, height:s_height, width:"100%",opacity:0.85},{duration: 1400, easing: "easeOutExpo"});
				
		}

	   	$("#pic_box").stop().animate({top:102, opacity:1}, {duration: 1400, easing: "easeOutExpo"});
		//$(".thumb_row a").fancybox({ 'zoomSpeedIn': 1, 'zoomSpeedOut': 1, 'overlayShow': true,'overlayOpacity':0.8}); 
			$("#btn_zoom_back,#btn_zoom_forward,#arrow_back,#arrow_forward").stop().animate({opacity: 0},{duration: 100, easing: "easeOutExpo"});
			$("#zoom_pic").stop().animate({opacity: 1},{duration: 100, easing: "easeOutExpo"});
			$("#btn_zoom_back").hover(function () {	
					$("#btn_zoom_back").stop().animate({opacity: 0.6},{duration: 600, easing: "easeOutExpo"});
					$("#arrow_back").stop().animate({opacity: 1},{duration: 600, easing: "easeOutExpo"});		
				}, function(){					
					$("#btn_zoom_back,#arrow_back").stop().animate({opacity: 0},{duration: 600, easing: "easeOutExpo"});
			});
			 $("#btn_zoom_forward").hover(function () {	
					$("#btn_zoom_forward").stop().animate({opacity: 0.6},{duration: 600, easing: "easeOutExpo"});
					$("#arrow_forward").stop().animate({opacity: 1},{duration: 600, easing: "easeOutExpo"});
					
					
				}, function(){					
					$("#btn_zoom_forward,#arrow_forward").stop().animate({opacity: 0},{duration: 600, easing: "easeOutExpo"});
	
					
			});
			 
			
			
			
			/*$("#btn_close_zoom,#shutter").click(function () {
				close_zoom();								 	
			}); */
/*			$("#shutter").click(function () {
				alert("sdf");
			
			}); */
			
			
	   }

	 });


}


function start_animation(){
	load_bottom();
	setTimeout("load_header()",200);
	setTimeout("load_shadow()",400);
	setTimeout("load_btns()",680);
	setTimeout("load_logo()",600);
	//setTimeout("load_baselines()",800);
	setTimeout("$('#line_1, #line_2').animate({height:96, opacity:0.8},{duration: 1800, easing: 'easeOutExpo'})",1000);
	setTimeout("$('#baseline_1').fadeIn(400, function(){$(this).animate({opacity:0.3},{duration: 1400, easing: 'easeOutExpo'})})",1400);
	setTimeout("$('#baseline_2').fadeIn(400, function(){$(this).animate({opacity:0.3},{duration: 1400, easing: 'easeOutExpo'})})",1600);
	setTimeout("$('#baseline_3').fadeIn(400, function(){$(this).animate({opacity:0.3},{duration: 1400, easing: 'easeOutExpo'})})",1800);
	setTimeout("load_btn_hover()",1400);
	setTimeout("$('#btn_kontakt').fadeIn(1000)",1000);
	setTimeout("$('#btn_impressum').fadeIn(1000)",1000);
	setTimeout("$('#header_line').animate({height:4, top:0},{duration: 800, easing: 'easeOutExpo'})",1400);
	
}
$(window).load(function(){
	setTimeout("start_animation()",600);
	
});




var active="";
var active_id="";
var sub_active="";
var pic_zoom=false;
$(document).ready(function(){
	
	// Transparenz Selector
	$("#selector").animate({opacity: 0.5},{duration: 0});
	
	//TRansparaenz Line
	$("#line_1, #line_2").animate({opacity: 0},{duration: 0});
	
	
	$("#display").stop().animate({opacity:0},{duration: 0});
	$("#content_kontakt").stop().animate({opacity:0},{duration: 0});
	$("#content_impressum").stop().animate({opacity:0},{duration: 0});
	
	//Transparenz der Buttons einstellen
	$("#btn_1,#btn_2,#btn_3").animate({opacity: 0.2},{duration: 0});

	/*$("#btn_1, #btn_2, #btn_3").hover(function () {	$(this).stop().animate({opacity: 1},{duration: 2000, easing: "easeOutExpo"});
		}, function(){								$(this).stop().animate({opacity: 0.5},{duration: 4000, easing: "easeOutExpo"}); 
	});*/
	$("#btn_1, #btn_2, #btn_3").click(function () {
		if(active!=this){	
			$(active).stop().animate({opacity: 0.5,top: 118,height:108},{duration: 2000, easing: "easeOutExpo"});
			$("#baseline_"+active_id.charAt(4)).stop().animate({opacity: 0.3},{duration: 2000, easing: "easeOutExpo"});
			$("#baseline_"+this.id.charAt(4)).stop().animate({opacity: 1},{duration: 2000, easing: "easeOutExpo"});
			$(this).stop().animate({opacity: 0.3},{duration: 100});
			$(this).animate({opacity: 1,top: 118},{duration: 2000, easing: "easeOutExpo"});
			open_stage(this.id.charAt(4),active);
			
			active=this;
			active_id=this.id;
			
			
		}
	});
	
	$("#logo").click(function () {
		if(active!=this){	
			$(active).stop().animate({opacity: 0.5,top: 118,height:108},{duration: 2000, easing: "easeOutExpo"});
			$("#baseline_"+active_id.charAt(4)).stop().animate({opacity: 0.3},{duration: 2000, easing: "easeOutExpo"});
			$("#baseline_"+this.id.charAt(4)).stop().animate({opacity: 1},{duration: 2000, easing: "easeOutExpo"});
			
			//ZOOM PIC ausblenden,wenn vorhanden
			if(pic_zoom==true){
/*				$("#shutter").stop().animate({top:700,opacity:0},{duration: 700,easing: "easeInExpo"});
				$("#shutter").animate({top:800,opacity:0},{duration: 10});
				$("#pic_box").stop().animate({top:700, opacity:0}, {duration: 700, easing: "easeInExpo", complete: function(){ $("#pic_box").empty();}});
				$("#pic_box").animate({top:800,opacity:0},{duration: 10});
				pic_zoom=false;*/
				close_zoom();
				setTimeout("open_stage('4');",500);
				setTimeout("active='4'",550);
				
				//alert("zoom true");
			}else{
				open_stage("4",active);
				active="4";	
			}
			
			
			active_id="btn_4";
			
		}
		

		
	});
	$("#shutter").animate({top:800,opacity:0},{duration: 10});
	//$("#display_bg").animate({opacity:0},{duration: 10});

	

		
		
		 
	

	
	
/*	$("#btn_kontakt, #btn_impressum").hover(function () {
			$(this).css({'color' : '#000000'});
		}, function(){	
			$(this).css({'color' : '#999'});			
	});*/
	$("#btn_kontakt").click(function () {
			$("#content_kontakt").stop().animate({opacity: 1,top:8, height:148},{duration: 900, easing: "easeOutExpo"});

		
	});
	
	
	$("#btn_impressum").click(function () {
			$("#content_impressum").stop().animate({opacity: 1,top:8, height:148},{duration: 900, easing: "easeOutExpo"});

	});
	$(".btn_close").click(function () {			
			$("#btn_kontakt").stop().animate({opacity: 0},{duration: 0});
			$("#btn_impressum").stop().animate({opacity: 0},{duration: 0});
			$("#content_impressum").stop().animate({opacity: 0,top: -160,height:108},{duration: 1500, easing: "easeOutExpo"});
			$("#content_kontakt").stop().animate({opacity: 0,top: -160,height:108},{duration: 1500, easing: "easeOutExpo"});
			$("#btn_kontakt").stop().animate({opacity: 1},{duration: 1500, easing: "easeOutExpo"});
			$("#btn_impressum").stop().animate({opacity: 1},{duration: 1500, easing: "easeOutExpo"});
	});
	/*$("#btn_2").hover(function () {	$(this).stop().animate({opacity: 1,top:108,height:120},{duration: 900, easing: "easeOutExpo"});
		}, function(){				$(this).stop().animate({opacity: 0.5,top: 118,height:108},{duration: 1500, easing: "easeOutExpo"});
	});
	$("#btn_3").hover(function () {	$(this).stop().animate({opacity: 1,top:108,height:120},{duration: 900, easing: "easeOutExpo"});
		}, function(){				$(this).stop().animate({opacity: 0.5,top: 118,height:108},{duration: 1500, easing: "easeOutExpo"});
	});*/
	
	// Initialisiere PNG FIX

	

	



});


	
	

