// JavaScript Document

//首页焦点图
	//切换函数
	function fcEdt(fcInd){
		$('.fc_ctrl a').removeClass('on');
		$('.fc_ctrl a').eq(fcInd).addClass('on');
		$('.fc_view p').fadeOut();
		$('.fc_view p').eq(fcInd).css({'z-index':'1'}).fadeIn('slow');
	};
	//自动函数
	function fcFun(onInd){
		onInd++;
		if(onInd==$('.fc_view p').length){onInd=0};
		fcEdt(onInd);
	};
//
$(function(){
	//顶部下拉菜单
	$('#tpNav li').hover(function(){
		if($(this).find('i').length){
			$(this).find('span a').addClass('on');
			$(this).find('.tn_drop').show();
			//随机客服
	
			//随机客服完
		};
	},function(){
		$(this).find('span a').removeClass('on');
		$(this).find('.tn_drop').hide();
	});
	
	//主导航鼠标事件
	$('#mainNav .nav>li').hover(function(){
		$('#mainNav .nav>li').removeClass('on');
		$(this).addClass('on');
		var mNavOnInd = $(this).index()
		if(mNavOnInd<3){
			$(this).children('.nav_pro').fadeIn();
		}else{
			//二级导航
			if(mNavOnInd==3){
				$(this).children('.nav_sve').fadeIn();
			}else{
				$(this).children('.nav_pro').fadeIn();
			};
		};
	},function(){
		$(this).removeClass('on');
		$('.nav_pro').fadeOut(200);
		$('.nav_sve').fadeOut(200);
		$('.nav_child').fadeOut(200);
	});
	//产品二级导航
	$('.nav_sub li').click(function(){
		$(this).parents('.nav_pro').find('.nav_sub li').removeClass('on');
		$(this).addClass('on');
		$(this).parents('.nav_pro').find('.nsc_cnt').hide();
		$(this).parents('.nav_pro').find('.nsc_cnt').eq($(this).index()).show();
	});
	
	//首页焦点图
	//初始化
	$('.fc_view p:first').css('z-index','1');
	//开始定时
	var fcTimer = setInterval('fcFun($(".fc_ctrl a.on").index())',5000);
	$('.focus').mouseover(function(){
		clearInterval(fcTimer);
	});
	//移除定时
	$('.focus').mouseout(function(){
		fcTimer = setInterval('fcFun($(".fc_ctrl a.on").index())',5000);
	});
	//事件绑定
	$('.fc_ctrl a').click(function(){
		fcEdt($(this).index());
	});
	
	//首页新闻滚动
	var newsWrap = $('.bar_news ul');
	var newsTimer;
	if(newsWrap.children('li').size()>1){
		newsWrap.hover(function(){
			clearInterval(newsTimer);
		},function(){
			var newsH = newsWrap.find('li:first').height();
			newsTimer = setInterval(function(){
				newsWrap.find('li:first').animate({marginTop:-newsH},500,function(){
					newsWrap.find('li:first').css({marginTop:'0'}).appendTo(newsWrap);
				});
			},3000);
		}).trigger('mouseleave');
	};
	
	//左侧菜单控制
	//检查所有dl，非当前项，且无二级菜单时，添加off样式
	var lthMyMenuDl = $('#myMenu dl').length;
	for(i=0;i<lthMyMenuDl;i++){
		if(!$('#myMenu dl').eq(i).hasClass('on')&&$('#myMenu dl').eq(i).find('dd').length){
			$('#myMenu dl').eq(i).addClass('off');
		};
	};
	//阻止点击空链接时页面跳动
	$('#myMenu a').click(function(){
		if($(this).attr('href')=='#'){
			$(this).attr('href','javascript:;')
		};
	});
	//点击一级菜单，折叠非当前项 及 并展开当前项
	$('#myMenu dt').click(function(){
		$('#myMenu dl').removeClass('on');
		//非当前项 且 包含子项时关闭
		var lthDl = $('#myMenu dl').length;
		for(i=0;i<lthDl;i++){
			if($('#myMenu dl').eq(i).find('dd').length){
				$('#myMenu dl').eq(i).addClass('off')
			};
		};
		$(this).parent('dl').removeClass('off');
		//二级菜单中
		if($(this).parent('dl').find('dd').hasClass('on')){
			var ddHeight = $(this).parent('dl').find('dd').height();
			$(this).parent('dl').find('dd').stop(true,true).animate({height:'0'},'fast').animate({height:ddHeight},'fast');
			$(this).parent('dl').find('dd').removeClass('on');
			$(this).parent('dl').addClass('on');
		}else{
			$(this).parent('dl').addClass('on');
		};
	});
	//点击二级菜单
	$('#myMenu dd').click(function(){
		$('#myMenu dl').removeClass('on');
		$('#myMenu dd').removeClass('on');
		$(this).addClass('on');
	});
	
	//产品详细页图片切图
	$('#proView .pro_pic img').not(':first').hide();
	$('.pro_pic_lst li').click(function(){
		$('.pro_pic_lst li').removeClass('on');
		$(this).addClass('on');
		var indProImg = $('#proView .pro_pic img').eq($(this).index());
		if(indProImg.is(':hidden')){
			$('#proView .pro_pic img').slideUp();
			indProImg.slideDown();
		};
	});
	//产品详细页 - 选项卡
	$('.wp_pro_info .wp_tab li').mouseover(function(){
		$('.wp_pro_info .wp_tab li a').attr('href','javascript:;')
		$('.wp_pro_info .wp_tab li').removeClass('on');
		$(this).addClass('on');
	});
	//知识库 偶数模块右对齐
	$('.wp_hp_oth .w_cnt:odd').addClass('fr');
});
