// JavaScript Document
jQuery(function(){
	//////////////////////////主导航
	(function mainNav($){
		if($("ul.ul_mainNav").length){
			var nowInd = $("ul.ul_mainNav>li").index($("ul.ul_mainNav>li:now"));
			$("ul.ul_mainNav").mouseout(function(){$("ul.ul_mainNav>li").eq(nowInd).addClass("now")});
			var timerId;
			function slideD(that) {
					that.addClass("now");
					that.children("ul").slideDown();
			}
			function slideU(that) {
					that.removeClass("now");
					that.children("ul").slideUp();
			}
			
			$("ul.ul_mainNav>li").each(function(){
				var that = $(this);
				$(this).mouseenter(function(){
					clearTimeout(timerId);
					timerId = setTimeout(function(){slideD(that)},200);
				});
				$(this).mouseleave(function(){
					clearTimeout(timerId);
					slideU($(this));
				});
			});
		}
	})(jQuery);
	//////////////////////////左导航
	(function sideNav($){
		if($("ul.subNavList").length){
			var timerId;
			function slideD(that) {
					that.addClass("on");
					that.children("ul").slideDown();
			}
			function slideU(that) {
					that.removeClass("on");
					that.children("ul").slideUp();
			}
			$("ul.subNavList li").each(function(){
				var that = $(this);
				if(!$(this).hasClass("on")){
					$(this).children("ul").hide();
				}
				if($(this).children("ul").length){
					$(this).addClass("hasChild");
				}
				if(!$(this).hasClass("on")&&$(this).children("ul").length){
					$(this).mouseenter(function(){
						clearTimeout(timerId);
						timerId = setTimeout(function(){slideD(that)},200);
					});
					$(this).mouseleave(function(){
						clearTimeout(timerId);
						slideU($(this));
					});
				}
				
			});
		}
	})(jQuery);
	//////////////////////////页脚友情链接
	(function friendSites($){
		if($("ul.links").length > 0){
			$("#footer h3").click(function(){
			$("ul.links").toggle();
		});
		}
	})(jQuery);
	//////////////////////////首页标签
	(function indTab($){
		if($(".homeNews").length){
			var tagH2 = $(".homeNews>h2>a");
			var tagList = $(".ul_a1");
			tagList.eq(1).hide();
			var autoRun;
	
			tagH2.eq(0).addClass("now");
			tagList.eq(0).css("display","block");
	
			tagH2.each(function(i) {
				$(this).mouseover(function(){ 
					autoRun=setTimeout(function() {
						tagH2.removeClass("now");
						tagH2.eq(i).addClass("now");
						tagList.css("display","none");
						tagList.eq(i).css("display","block");
					},300);
				});
				$(this).mouseout(function() {
					clearTimeout(autoRun);
				});
			});
		}
	})(jQuery);
	//////////////////////////首页滚动产品
	(function indPd($){
		if($("#proHomebox").length){
			$('#proHomebox').jcarousel({
				scroll:1
			});
		}
	})(jQuery);
	//////////////////////////内页左侧滚动产品
	(function sidePd($){
		if($('#proSidebox').length){
			$('#proSidebox').jcarousel({
				scroll:1
			});	
		}
	})(jQuery);
	//////////////////////////内页产品标签
	(function pdTab($){
		if($(".proBox1").length){
			$(".proBox1 h3").eq(0).addClass("on");
			$(".tagB").eq(0).show();
			$(".proBox1 h3").each(function(i) {
			var autoRun;
				$(this).mouseover(function() {
					autoRun = setTimeout(function() {
						$(".proBox1 h3").removeClass("on");
						$(".proBox1 h3").eq(i).addClass("on");
						$(".tagB").hide();
						$(".tagB").eq(i).show();
					},500);	
				});
				$(this).mouseout(function() {
					clearTimeout(autoRun);
				});
			});
		}
	})(jQuery);
	//////////////////////////企业参观
	(function gallery($){
		if($(".visitImg").length){
			$("#vImgList img").click(function(){
				var largePath = $(this).attr("src");
				var largeAlt = $(this).attr("alt");
				$(".visitImg img").attr({ src: largePath, alt: largeAlt });
				$(".visitImg h3").html(largeAlt); return false;
			});
		}
	})(jQuery);
	//////////////////////////招聘职位
	(function gallery($){
		if($(".jobH3").length){
			$(".jobBox").hide();
			$(".jobH3").each(function(i) {
				$(this).click(function() {
					$(".jobH3").next("div").hide();
					$(".jobH3").next("div").eq(i).show();
				});
			});
		}
	})(jQuery);
});
//////////////////////////左导航
function subNav() {
	if($(".subNavList").length){
		var autoRun;
		window.ulChange=function(m) {
			$(".subNavList>li").eq(m).find("ul").css("display","block");
		}
		$(".subNavList>li a.on + ul").css("display","block");
		$(".subNavList>li").each(function(i) {
			$(this).hover(function() {
				var index=$(".subNavList>li").index($(this));
				//alert(index);
				autoRun=setTimeout("ulChange("+index+")",200);
					
				},function() {
					clearTimeout(autoRun);
					$(this).find("ul").css("display","none");
			});
		});
	}
}

//////////////////////////加入收藏
function AddFavorite(sURL, sTitle){   
    try{   
         window.external.addFavorite(sURL, sTitle);   
     }   
    catch (e){   
        try{   
             window.sidebar.addPanel(sTitle, sURL, "");   
         }   
        catch (e){   
             alert("加入收藏失败，请使用Ctrl+D进行添加");   
         }   
     }   
} 
