$(function(){
	if ($("body").attr("id") == "P00"){
	     document.getElementById("flash").innerHTML = fplay("images/home.swf", "979px", "342px");
		 document.getElementById("logo").innerHTML = fplay("images/name.swf", "313px", "47px");
	}

    if($("body").attr("id") != "P00" && document.getElementById("flash01")) {
		document.getElementById("flash01").innerHTML = fplay("images/i" + $("body").attr("id").substring(2,3) + ".swf","972","229");
		 document.getElementById("logo").innerHTML = fplay("images/name.swf", "313px", "47px");		
		}

	nav = $("#menu > ul");
    var rootli = nav.children("li");
	rootli.each(function() {
		var childA = $(this).children("a");
		if(childA.attr("href").indexOf(":") > 0) {
			childA.attr("href", $("li:eq(0)>a", childA.next()).attr("href"));
		}
	});

	$("ul.products0 ul:not(ul:has(ul))").each(function(){
			$(this).addClass("pros");
			$(this).prepend("<li class=\"ltop\"></li>");
			$(this).append("<li class=\"lend\"></li>");
	});

     $("#pmenu0 ul li:has(ul)").hover(function(){
			$(this).children("ul").eq(0).stop(true,true).show();
		},function(){
			$(this).children("ul").eq(0).stop(true,true).hide();
	   });	

     $("ul.products0 ul").hover(function(){
			$(this).prev("a").addClass("ac");
		},function(){
			$(this).prev("a").removeClass("ac");
	   });

		$("#products dl dd").eq(0).show();
		$("#products dl dt>a").click(function(){
			$("dd:visible").fadeOut(10,function(){$(this).slideUp("slow");});
			
			$(this).parent().next().slideDown("slow",function(){$(this).fadeIn(600);});

			return false;
		});
		$("#menu > ul > li:has(ul)").hover(function(){
			$(this).children("ul").stop(true,true).show();
		},function(){
			$(this).children("ul").stop(true,true).hide();
	    });
		$("#case ul li:not(:first)").css("opacity","0.6"); 
	    $("#case ul li").mouseover(function(){
			$(this).css("opacity","1.0")
				   .siblings().css("opacity","0.6");
		});

	  $("#nowLocation1 span").mouseover(function(){
			$("#locationList").show();
		});
	  $("#locationList").mouseleave(function(){
			$(this).hide();
		});


	if ($("ul.list1").length > 0) {	$("ul.list1 li a.thumb").lightBox();}
	if ($("ul.list2").length > 0) {	$("ul.list2 li a.thumb").lightBox();}

	$("#products dd").each(function() {
		if ($(this).find("li").length < 5){
			$(this).children("div.prev01").css("visibility","hidden");
			$(this).children("div.next01").css("visibility","hidden");
		}
	});

	var myLi = new Array;
	for (var i=0; i< $("#products .next01").length; i++){
		myLi[i] = 4;
		 $("#products .next01").eq(i).click(function(){ 
			var $parent = $(this).parents("#products dl dd");//根据当前点击元素获取到父元素
			var $v_show = $parent.find(".product ul"); //寻找到“视频内容展示区域” 
			var v_width = 105 ; 
			var len = $v_show.children("li").length;
			 if( !$v_show.is(":animated") ){    //判断“视频内容展示区域”是否正在处于动画
				  if( myLi[i] == len){  //到最后一个版面了。
					}else{if( myLi[i] == len-1 ){  
					$(this).css("background","url(images/product_04.jpg) no-repeat left");
					$(this).siblings(".prev01").css("background","url(images/product_02.jpg) no-repeat left");
					$v_show.animate({ left : '-=' + v_width }, "slow");  
					myLi[i]++;
					}else{
					$v_show.animate({ left : '-=' + v_width }, "slow");  
					myLi[i]++;
					$(this).siblings(".prev01").css("background","url(images/product_02.jpg) no-repeat left");
					}
				 }
			 }
		});
		$("#products .prev01").eq(i).click(function(){
			var $parent = $(this).parents("#products dl dd");//根据当前点击元素获取到父元素
			var $v_show = $parent.find(".product ul"); //寻找到“视频内容展示区域”
			var $v_content = $parent.find(".product"); 
			var v_width = 105 ;
			 if( !$v_show.is(":animated") ){    //判断“视频内容展示区域”是否正在处于动画
				 if( myLi[i] == 4 ){ 
				}else{ if( myLi[i] == 5){  
					$(this).css("background","url(images/product_01.jpg) no-repeat left"); 
					$(this).siblings(".next01").css("background","url(images/product_03.jpg) no-repeat right");
					$v_show.animate({ left : '+='+v_width }, "slow");
					myLi[i]--;
				}else{
					$v_show.animate({ left : '+='+v_width }, "slow");
					myLi[i]--;
					$(this).siblings(".next01").css("background","url(images/product_03.jpg) no-repeat right");
				   }
				}
			 }
			
		});
	}
 })

function fplay(swf, swfwidth, swfheight,full) {
    if (navigator.userAgent.indexOf('Firefox') > - 1) {
		if (full == "full"){
	        return('<embed src="' + swf + '" width="' + swfwidth + '" height="' + swfheight + '" quality="high" wmode="Opaque" allowFullScreen="true" allowScriptAccess="always"></embed>');
		}else{
        return('<embed src="' + swf + '" width="' + swfwidth + '" height="' + swfheight + '" quality="high" wmode="transparent"></embed>');}
    } else {
		if (full == "full"){
			return('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + swfwidth + '" height="' + swfheight + '"><param name="movie" value="' + swf + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="Opaque" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /></object>');
		}else{
        return('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + swfwidth + '" height="' + swfheight + '"><param name="movie" value="' + swf + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="transparent" /></object>');}
    }
}

