window.onload=function(){
	var navagation=document.getElementById("navContent");
	if(navagation){
		new Nav(navagation);
	}
};

var Nav=function(oEle){
	this.oTimer=null;
	this.iSpeed=0;
	var obj=this;
	this.oEle=oEle;
	this.fixIndex=0;//加载后找出带色的
	this.aLi=this.oEle.getElementsByTagName("li");
	this.aLiLast=this.aLi[this.aLi.length-1];//最后一个aLi
	this.oDiv=this.aLiLast.getElementsByTagName("div")[2];
	for(var i=0;i<this.aLi.length-1;i++){
		this.aLi[i].iIndex=i;
		if(this.aLi[i].getElementsByTagName("a")[0].className=="hover"){
			this.fixIndex=i;
			this.startMove(this.fixIndex);
		}
		this.aLi[i].onmouseover=function(){
			obj.startMove(this.iIndex);
		};
		this.aLi[i].onmouseout=function(){
			this.getElementsByTagName("a")[0].style["color"]="#fff";
			obj.startMove(obj.fixIndex);
		};
	}
};
Nav.prototype.startMove=function(iTarget){
	var obj=this;
	this.oDiv.style.width=this.aLi[iTarget].offsetWidth-10+"px";
	this.aLi[iTarget].getElementsByTagName("a")[0].style["color"]="#242424";
	if(this.oTimer){
		clearInterval(this.oTimer);
	}
	this.oTimer=setInterval(
		function(){
			obj.doMove(obj.aLi[iTarget].offsetLeft);
		}
	,30);
};

Nav.prototype.doMove=function(iTarget){
	this.iSpeed+=(iTarget-this.aLiLast.offsetLeft)/5;
	this.iSpeed*=0.5;
	this.aLiLast.style.left=this.aLiLast.offsetLeft+this.iSpeed-10+'px';

};

//选择==================================================

$(function(){
	$(".survey_result1 > ul >li > label").click(function(){
		$(this).parent().toggleClass("click");
	})
});

$(function(){
	$(".survey_border > div").click(function(){
		var $index=$(this).index();
		$("#survey_result > div").eq($index).siblings().slideUp(
			function(){
				$("#survey_result > div").eq($index).animate({height:"toggle"});
			}
		);
		
	});
	$(".clo").click(function(){
		$(this).parent().slideUp();
	});
});

$(function(){
	$("#search").focus(function(){
		if($(this).val()=="-Search Products-"){
			$(this).val("");
		}
	});
	$("#search").blur(function(){
		if($(this).val()==""){
			$(this).val("-Search Products-");
		}
	});
});


$(function(){
	$(".nav_vertical > li").hover(function(){
			$(this).children("span").stop(true,true).animate({opacity:0.6,width:"215px"}).siblings().stop(true,true).animate({"padding-left":"50px"}).parent().stop(true,true).animate({width:"215px"});
		}
		,function(){
			$(this).children("span").stop(true,true).animate({opacity:0.5,width:"200px"}).siblings().stop(true,true).animate({"padding-left":"10px"}).parent().stop(true,true).animate({width:"200px"});
	});

	$(".nav_vertical > li > a").mousedown(function(){
		return false;
	});
	$(".nav_vertical li").mousedown(function(){
		$(this).siblings("li").children("ul").slideUp();
		$(this).children("ul").toggle(300);
		//$(this).children("span").css({opacity:""});
	});
});

$(function(){
	var oL=$(".rowMain_left");
	var oM=$(".rowMain_middle");
	var oR=$(".rowMain_right");
	var l=oL.height();
	var m=oM.height();
	var r=oM.height();
	var H=Math.max(l,m,r);
	oL.css({height:H});
	oR.css({height:H});
	oM.css({height:H});
});
//遮罩层
$(function(){
	var zhezhaoW=document.body.clientWidth;
	var zhezhaoH=document.body.clientHeight;
	var zhezhao=document.getElementById("zhezhaoceng");
	var require=document.getElementById("require");
	if(zhezhao){
		zhezhao.style.width=zhezhaoW+"px";
		zhezhao.style.height=zhezhaoH+"px";
	}


	$("#survey3").click(function(){
		$("#zhezhaoceng").show();
		$("#require").show();
		require.style.left=(zhezhaoW-require.offsetWidth)/2+"px";
	});
	$("#close2").click(function(){
		$("#zhezhaoceng").hide();
		$("#require").hide();
		return false;
	});
	$("#close3").click(function(){
		$("#zhezhaoceng").hide();
		$("#require").hide();
	});
})

/*productsImg---set height*/
$(function(){
	var $aticleListHeight = $('.aticleList').height();
	$('.productsImg').height($aticleListHeight);
});
