/**
 * @author Dennis Weggemann
 */
$(document).ready(function(){
//	$("#pics div").css({"right":300 - $("#a1").width() / 2 + "px"})
//	.css({"top":180 - $("#a1").height() / 2 + "px"});

	/*
	 * Browser Check
	 */
		if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
			 var ieversion=new Number(RegExp.$1); // capture x.x portion and store as a number
		}
/*		
	if(ieversion == 8){
		
		$(document,"#menu,#wrapper,#content,#logo,#title,#").bind("click", function(){
			
			$("#pics div:eq(0),#pics2 div:eq(0),#pics3 div:eq(0),#pics4 div:eq(0)").delay(500).css({"opacity":"1"});
			
		});
		
	};
*/
	/*
	 * Anzeigen des ersten Fotos
	 */
		
			
		
		
		
	$("#pics div:eq(0),#pics2 div:eq(0),#pics3 div:eq(0),#pics4 div:eq(0)").delay(500).animate({"opacity":"1"},5);
		
		
		/*
		 * Zentrierung des ersten Fotos und der ganzen Seite, horizontal und vertikal
		 */
	$(window).load(function(){
		
		$("img").removeAttr("width");  
		$("img").removeAttr("height"); 
		
		$("#pics div:eq(0)").css({"right":300 - $("#a1 img").width() / 2 + "px"})
		.css({"top":180 - $("#a1 img").height() / 2 + "px"});
		});
	
	
//		$("#wrapper").removeAttr("height"); 
//		var fenster_height = $(window).height();
//		var wrapper_height = $("#wrapper").height();
//		var wrapper_height_center = (fenster_height - wrapper_height)/2;
//		if(wrapper_height <= fenster_height){
//		$("#wrapper").css({"margin-top":wrapper_height_center + "px"});
//		}else{
//		document.getElementById("wrapper").style.marginTop = 15 + "px";
//		};
	 
	
	
		//$("#pics div:eq(0)").animate({"right":300 - $("#a1 img").width() / 2 + "px"},200)
		//.animate({"top":180 - $("#a1 img").height() / 2 + "px"},200);
	
	
	
		/////////MAINMENU SHOW AND HIDE
	$("#menu").bind("mouseenter", function(){
				$("#menu_top ul").stop().animate({"top":"2px"},400);
			}).bind("mouseleave", function(){
				$("#menu_top ul").stop().animate({"top":"30px"},400);
				$("#selector_top").stop().animate({"left":"40px"},200);
				$("#selector_bottom").stop().animate({"left":"60px"},200);
	});
	
	////////MOVEMENT OF SELECTOR MENU_TOP
	///Funktion
	var move_sel_top = function(top_item, top_pos, bottom_pos){
		
		$("#menu_top li:eq("+top_item+")").bind("mouseenter", function(){
			$("#selector_top").stop().animate({"left":""+top_pos+"px"},200);
			$("#selector_bottom").stop().animate({"left":""+bottom_pos+"px"},200);
		 }).bind("mouseleave", function(){
		 	});
		
	};
///// das Zeug
	move_sel_top(0, 140, 160);
	move_sel_top(1, 212, 232);
	move_sel_top(2, 289, 309);
	move_sel_top(3, 376, 396);
	move_sel_top(4, 480, 500);
	move_sel_top(5, 563, 583);
	move_sel_top(6, 638, 658);
	move_sel_top(7, 710, 730);
	
	
	////////MOVEMENT OF SELECTOR MENU_BOTTOM
	/////Funktion
	var move_sel_bottom = function(list_number, list_item, left_pos){
		
		$("#menu_bottom #l"+list_number+" li:eq("+list_item+")").bind("mouseenter", function(){
			$("#selector_bottom").stop().animate({"left":""+left_pos+"px"},200);
		 }).bind("mouseleave", function(){
});
		
	};
	//////das Zeug
	move_sel_bottom(1, 0, 160);
	move_sel_bottom(1, 1, 262);
	move_sel_bottom(1, 2, 359);
	move_sel_bottom(2, 0, 232);
	move_sel_bottom(2, 1, 300);
	move_sel_bottom(3, 0, 309);
	move_sel_bottom(3, 1, 378);
	move_sel_bottom(3, 2, 471);
	move_sel_bottom(4, 0, 396);
	move_sel_bottom(7, 0, 658);
	move_sel_bottom(7, 1, 727);
	move_sel_bottom(7, 2, 824);
	
	
	////////SUB MENU: SHOW WHEN MOUSEOVER
	/////Funktion
	var sub_menue_show = function( list_item,list_number, top_pos1, top_pos2){
		$("#menu_top li:eq("+list_item+"),#l"+list_number+"").bind("mouseover", function(){
			$("#l"+list_number+"").stop().animate({"top":""+top_pos1+"px"},400);
		 }).bind("mouseout", function(){
		 	$("#l"+list_number+"").stop().animate({"top":""+top_pos2+"px"},400);
});
	};
	sub_menue_show(0, 1, -2, -30);
	sub_menue_show(1, 2, -2, -30);
	sub_menue_show(2, 3, -2, -30);
	sub_menue_show(3, 4, -2, -30);
	sub_menue_show(4, 5, -2, -30);
	sub_menue_show(5, 6, -2, -30);
	sub_menue_show(6, 7, -2, -30);
	
	
	
	////////////HOME THUMBS HOVER: OPACITY
/*	$(".home_thumbs div").bind("mouseenter", function(){
		$(this).stop().animate({"opacity":"1"},300);
   }).bind("mouseleave", function(){
		$(this).stop().animate({"opacity":"0.5"},300);
});*/
	
	///////THUMBS HOVER: OPACITY
		$(".thumbs_cols div").bind("mouseenter", function(){
								$(this).stop().animate({"opacity":"1"},300);
						   }).bind("mouseleave", function(){
								$(this).stop().animate({"opacity":"0.5"},300);
		});
		///////THUMBS REPO HOVER: OPACITY
		$(".repo_cols div").bind("mouseenter", function(){
								$(this).stop().animate({"opacity":"1"},300);
						   }).bind("mouseleave", function(){
								$(this).stop().animate({"opacity":"0.5"},300);
		});
		
		
		
		///////////CLICK ????? : MORE PICS
		$("#left").bind("click", function(){
			if(thumbs == 3){
				if($("#thumbs").css("z-index") == "300"){
					$("#left").css({"display":"none"});
				}else if($("#thumbs2").css("z-index") == "300"){
					$("#thumbs3").animate({"opacity":"0"},500).css({"z-index":"100"});
					$("#thumbs2").animate({"opacity":"0"},500).css({"z-index":"200"});
					$("#thumbs").animate({"opacity":"1"},500).css({"z-index":"300"});
					$("#left").css({"display":"none"});
				}else if($("#thumbs3").css("z-index") == "300"){
					$("#thumbs3").animate({"opacity":"0"},500).css({"z-index":"200"});
					$("#thumbs2").animate({"opacity":"1"},500).css({"z-index":"300"});
					$("#thumbs").animate({"opacity":"0"},500).css({"z-index":"100"});
					$("#right").css({"display":"block"});
				}
			}else if(thumbs == 2){
				if($("#thumbs").css("z-index") == "300"){	
					
				}else if($("#thumbs2").css("z-index") == "300"){
					$("#thumbs2").animate({"opacity":"0"},500).css({"z-index":"200"});
					$("#thumbs").animate({"opacity":"1"},500).css({"z-index":"300"});
					$("#left").css({"display":"none"});
					$("#right").css({"display":"block"});
				}
			}
		});
		$("#right").bind("click", function(){
			if(thumbs == 3){
			if( $("#thumbs3").css("z-index") == "300"){
				$("#left").css({"display":"block"});				
			}else if($("#thumbs2").css("z-index") == "300"){
				$("#thumbs3").animate({"opacity":"1"},500).css({"z-index":"300"});
				$("#thumbs2").animate({"opacity":"0"},500).css({"z-index":"200"});
				$("#thumbs").animate({"opacity":"0"},500).css({"z-index":"100"});
				$("#right").css({"display":"none"});
				$("#left").css({"display":"block"});
			}else if($("#thumbs").css("z-index") == "300"){
				$("#thumbs3").animate({"opacity":"0"},500).css({"z-index":"200"});
				$("#thumbs2").animate({"opacity":"1"},500).css({"z-index":"300"});
				$("#thumbs").animate({"opacity":"0"},500).css({"z-index":"100"});
				$("#left").css({"display":"block"});
			}
			}else if(thumbs == 2){
				if( $("#thumbs2").css("z-index") == "300"){					
				}else if($("#thumbs").css("z-index") == "300"){
					$("#thumbs2").animate({"opacity":"1"},500).css({"z-index":"300"});
					$("#thumbs").animate({"opacity":"0"},500).css({"z-index":"200"});
					$("#right").css({"display":"none"});
					$("#left").css({"display":"block"});
				}
			}
	});
/*		///////////CLICK ARROWS : OTHER PICS REPORTAGE
		var active_repo = 1;
		$("#left_repo").bind("click", function(){
				if($("repo1").css("z-index") == "4"){
					active_repo = 1;
				}else if($("#repo2").css("z-index") == "4"){
					active_repo = 2;
					$("#repo1").animate({"opacity":"1"},500).css({"z-index":"4"});
					$("#repo2").animate({"opacity":"0"},500).css({"z-index":"3"});
					$("#repo3").animate({"opacity":"0"},500).css({"z-index":"2"});
					$("#repo4").animate({"opacity":"0"},500).css({"z-index":"1"});
				}else if($("#repo3").css("z-index") == "4"){
					active_repo = 3;
					$("#repo1").animate({"opacity":"0"},500).css({"z-index":"3"});
					$("#repo2").animate({"opacity":"1"},500).css({"z-index":"4"});
					$("#repo3").animate({"opacity":"0"},500).css({"z-index":"2"});
					$("#repo4").animate({"opacity":"0"},500).css({"z-index":"1"});
				}else if($("#repo4").css("z-index") == "4"){
					active_repo = 4;
					$("#repo1").animate({"opacity":"0"},500).css({"z-index":"1"});
					$("#repo2").animate({"opacity":"0"},500).css({"z-index":"3"});
					$("#repo3").animate({"opacity":"1"},500).css({"z-index":"4"});
					$("#repo4").animate({"opacity":"0"},500).css({"z-index":"2"});
				}
			
		});
		$("#right_repo").bind("click", function(){
			if($("repo4").css("z-index") == "4"){
				active_repo = 4;
			}else if($("#repo3").css("z-index") == "4"){
				active_repo = 3;
				$("#repo1").animate({"opacity":"0"},500).css({"z-index":"1"});
				$("#repo2").animate({"opacity":"0"},500).css({"z-index":"2"});
				$("#repo3").animate({"opacity":"0"},500).css({"z-index":"3"});
				$("#repo4").animate({"opacity":"1"},500).css({"z-index":"4"});
			}else if($("#repo2").css("z-index") == "4"){
				active_repo = 2;
				$("#repo1").animate({"opacity":"0"},500).css({"z-index":"1"});
				$("#repo2").animate({"opacity":"0"},500).css({"z-index":"2"});
				$("#repo3").animate({"opacity":"1"},500).css({"z-index":"4"});
				$("#repo4").animate({"opacity":"0"},500).css({"z-index":"3"});
			}else if($("#repo1").css("z-index") == "4"){
				active_repo = 1;
				$("#repo1").animate({"opacity":"0"},500).css({"z-index":"2"});
				$("#repo2").animate({"opacity":"1"},500).css({"z-index":"4"});
				$("#repo3").animate({"opacity":"0"},500).css({"z-index":"3"});
				$("#repo4").animate({"opacity":"0"},500).css({"z-index":"1"});
			}
	});	*/
		
	
		});
/////ERSTE EBENE
////////THUMBS HOVER: PREVIEW SHOW
////Function
var thumbs_hover_first = function(thumb_item, thumb_item_number, topic, pic_name){
	$("#"+thumb_item+" div").eq(thumb_item_number).bind("mouseenter", function(){
		$("#pp").stop().html("<img src='files/img/"+topic+"/preview/"+pic_name+"' alt=''>")
		.animate({"opacity":"1"},500);
   }).bind("mouseleave", function(){
   		$("#pp").stop().animate({"opacity":"0"},50);
});};
/////ZWeite EBENE
////////THUMBS HOVER: PREVIEW SHOW
////Function
var thumbs_hover = function(thumb_item, thumb_item_number, topic, pic_name){
	$("#"+thumb_item+" div").eq(thumb_item_number).bind("mouseenter", function(){
		$("#pp").stop().html("<img src='../files/img/"+topic+"/preview/"+pic_name+"' alt=''>")
		.animate({"opacity":"1"},500);
   }).bind("mouseleave", function(){
   		$("#pp").stop().animate({"opacity":"0"},50);
});};



/////Beide EBENEN
//////SHOW BIG PICS: CLICK ON THUMB
/////Function

var show_big = function(thumb_item, thumb_item_number, pic_id){
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
		 var ieversion=new Number(RegExp.$1); // capture x.x portion and store as a number
	};

	$("#"+thumb_item+" div").eq(thumb_item_number).stop().bind("click", function(){
		
	//	$("#pics div").animate({"opacity":"0"},450);
		
	if(ieversion <= 8){
		
		$("#pics div,#pics div:eq(0),#pics2 div:eq(0),#pics3 div:eq(0),#pics4 div:eq(0)")
		.animate({"opacity":"0"},450)
		
		.animate({"right":300 - $("#"+pic_id+"").width() / 2 + "px"},200)
		.animate({"top":180 - $("#"+pic_id+"").height() / 2 + "px"},200);
		if(300 - $("#"+pic_id+"").width() / 2 <= 0){
			$("#pics div").animate({"right":0+"px"},200);
		};
		
		$("#"+pic_id+"").animate({"opacity":"1"},500);
		
			
			
		}else{
		
		$("#pics div,#pics div:eq(0),#pics2 div:eq(0),#pics3 div:eq(0),#pics4 div:eq(0)")
		.stop().animate({"opacity":"0"},450)
		
		.animate({"right":300 - $("#"+pic_id+"").width() / 2 + "px"},200)
		.animate({"top":180 - $("#"+pic_id+"").height() / 2 + "px"},200);
		if(300 - $("#"+pic_id+"").width() / 2 <= 0){
			$("#pics div").animate({"right":0+"px"},200);
		}
		
		$("#"+pic_id+"").animate({"opacity":"1"},500);
		};
		
});

};
//////SHOW BIG PICS: CLICK ON THUMB REPO STYLE
/////Function
var opacity = 0;
var show_big_repo = function(thumb_item, thumb_item_number, pic_id){
$("#"+thumb_item+" div").eq(thumb_item_number).stop().bind("click", function(){
	
	$("#pics div,#pics2 div,#pics3 div,#pics4 div").stop().animate({"opacity":"0"},500).animate({"right":300 - $("#"+pic_id+"").width() / 2 + "px"},200)
	.animate({"top":180 - $("#"+pic_id+"").height() / 2 + "px"},200);
	
	$("#"+pic_id+"").animate({"opacity":"1"},500);
});};


function loadImages() {
	if (document.getElementById) {  // DOM3 = IE5, NS6
	document.getElementById('pic_load').style.visibility = 'hidden';
	}
	else {
	if (document.layers) {  // Netscape 4
	document.hidepage.visibility = 'hidden';
	}
	else {  // IE 4
	document.all.hidepage.style.visibility = 'hidden';
	      }
	   }
	}
