//SubMenu Effects
$(document).ready(function(){
	//products
	$(".subNav").find("ul li").each(
		function(i){
			var theConFind = $(this).find("dl").html()
			if(theConFind){
				$(this).hover(
					function(){
						$(this).find("dl").css({display:"block"}); 
						
						$(this).addClass("currentMenu1");
					},
					function(){
						if($(this).find("dl").mouseout){
							$(this).find("dl").css({display:"none"}); 
							$(this).removeClass("currentMenu1");
						}						 
					}
				)
			}
		}								
	)
	//Planning Tab
	for(f=0;f<$(".subMenuChild").length;f++){
		(function(){
			$(".subMenuChild").eq(f).find("dt").each(function(i){
					$(this).click(function(){
						var liConNo = $(".planningCon > div").size()
						for(x=0;x<liConNo;x++){
							$("#section"+x).slideUp(500);
							if(i==x){
								$("#section"+x).slideDown(500);	
							}
						}
					});
					if($(this).next("dd")){
					$(this).hover(
						function(){$(this).addClass("acrrentColor")},
						function(){$(this).removeClass("acrrentColor")}
					)
					}
			})
		})()
	}
	//facility Img
	var theImgNo = $(".flImg > div").find("img"),
		imgArrary = new Array(),
		t=0;
	function setTimeShow(){
		for(n=0;n<theImgNo.length;n++){
			var newSrc = theImgNo.eq(n).attr("src").replace("b","l"); 
			imgArrary[n] = newSrc;
		}
		if(t>imgArrary.length){
			t=0;	
		}
		else{
			for(s=0;s<imgArrary.length;s++){
				$(".flImg a").eq(s).removeClass("currentMenu");
				if(t==s){
					$("#flImg").attr("src",imgArrary[s]);
					$(".flImg a").eq(s).addClass("currentMenu")
				}
			}
			t++;
		}
		
	}
	var int = setInterval(setTimeShow,2000)
	theImgNo.each(function(i){
		$(this).hover(function(){
			clearInterval(int);
			for(s=0;s<imgArrary.length;s++){
				$(".flImg a").eq(s).removeClass("currentMenu");
				if(i==s){
					$(".flImg a").eq(i).addClass("currentMenu")
				}
			}
			var currentSrc = $(this).attr("src");
			$("#flImg").attr("src",currentSrc.replace("b","l"));
			},
			function(){int = setInterval(setTimeShow,2000)
		})									
	});
	//products width
	$("#subMenuChild").width($(".subNav").width())
	var theNewMenu = ($("#subMenuChild").width()/3)-42;
	$(".otherMenu").width(theNewMenu)
	var otherMenuWidth = theNewMenu/2-12;
	if(theNewMenu>0){
		$(".otherMenu").find(".menuBlock").width(theNewMenu)	
		$(".otherMenu").find(".menuBlock dl").width(otherMenuWidth)
	}
	//imitateSelect
	var selectOption = $(".imitateSelect").find("ul");
	$(".imitateSelect").hover(
		function(){
			if(selectOption.is(":hidden")){							
				selectOption.animate({
				opacity: 'toggle',height:'toggle'			
			},"show")
			}
		},
		function(){
			selectOption.animate({
				opacity: 'toggle',height:"toggle"				
			},"hide")
	})
	//human effects
	$(".humanCon").find("h3").click(function(){
		var summary = $(".humanCon").find("dl");
		if(summary.is(":visible")){
			summary.animate({
				opacity: 'toggle',height:"toggle"				
			},"hide")
		}	
		else{
			summary.animate({
				opacity: 'toggle',height:'toggle'			
			},"show")
		}
	});
	$(".humanCon").find("table tbody tr").hover(
		function(){
			$(this).addClass("theBgColor");
		},
		function(){
			$(this).removeClass("theBgColor");
	})
	$(".humanCon").find("table tbody tr").click(function(){
		var conId = $(this).attr("id")
		$("#humanView").html("");
		$.ajax({
		  url: "humanInfro.asp?id="+conId,
		  cache: false,
		  success: function(html){
			$("#humanView").html(html);
			$("#humanView").find("div > h3 > span").click(function(){
				$(".zhezhao").remove();	
				$("#humanView").slideUp()
			})
		  }
		});  
		if($("#humanView").is(":hidden")){
			var position = $(this).position();
			$("#humanView").css({top:position.top})
			$("#humanView").slideDown()
			$("#humanView").before("<div class='zhezhao'></div>")
			
		}
		$(".zhezhao").click(function(){
			$(this).remove();	
			$("#humanView").slideUp()
		})
		
	})
	
})


