//首页焦点图切换效果
function hdpjdt(anchorid,photoid,defaultclass,activeclass)
{
	this.dclass = defaultclass;
	this.aclass = activeclass;
	this.ul = document.getElementById(anchorid);
	this.lis = this.ul.getElementsByTagName("li");
	this.photobox = document.getElementById(photoid);
	this.time = 400; //切换一次总耗时
	this.itime = 100; //多少毫秒执行一次
	this.left = 0;
	this.width = 728; //图片宽度
	this.hdpet = 0; 
	this.lunbocurrent = 0; //轮播标记
	this.lunbotip = 0; //轮播开关
	var me = this;
	
	this.init = function(){
		for(var i=0;i<this.lis.length;i++){
			this.lis[i].onmouseover = function(){
				var a = i;
				var distance = -(i*me.width); //每个图片应该设的left值
				return function(){
					me.go(distance,a);
				}
			}(i)
		}
		document.getElementById("hdptp").onmouseover = this.stop;
		document.getElementById("hdptp").onmouseout = this.start;
		this.lunbotip = setInterval(this.lunbo,3000);
	}
	
	this.go = function(distance,no){
		if(me.t){
			clearInterval(me.t);
		}
		me.leftdistance = distance; 
		me.l = me.leftdistance - me.left;
		if(me.l == 0){
			return;
		}
		me.k = me.l/me.time; //速度
		me.t = setInterval(me.psms,me.itime);
		if(me.hdpet == no){
			return;
		}
		me.lis[no].className = me.aclass;
		me.lis[me.hdpet].className = me.dclass;
		me.hdpet = no;
		me.lunbocurrent = no;
	}
	
	this.psms = function(){
		me.left = me.left + me.k*me.itime;
		if(me.l > 0 && me.left >= me.leftdistance){
			me.left = me.leftdistance;
			me.photobox.style.left = me.left + "px";
			clearInterval(me.t);
		}
		if(me.l < 0 && me.left <= me.leftdistance){
			me.left = me.leftdistance;
			me.photobox.style.left = me.left + "px";
			clearInterval(me.t);
		}
		me.photobox.style.left = me.left + "px";
	}
	
	//轮播
	this.lunbo = function(){
		var no = me.lunbocurrent;
		me.lunbocurrent++;
		me.lunbocurrent = me.lunbocurrent%4;
		var distance = -(me.lunbocurrent*me.width);
		me.go(distance,me.lunbocurrent);
//		me.left = distance;
//		me.photobox.style.left = me.left + "px";
//		me.lis[no].className = me.dclass;
//		me.lis[me.current].className = me.aclass;
	}
	//onmouseover 鼠标进入停止轮播
	this.stop = function(){
		if(me.lunbotip){
			clearInterval(me.lunbotip);
		}
	}
	//onmouseout 鼠标离开启动轮播
	this.start = function(){
		if(me.lunbotip){
			clearInterval(me.lunbotip);
		}
		me.lunbotip = setInterval(me.lunbo,5000);
	}
	
	this.init();
}

//焦点图显示
function jiaodianshow(id1,id2)
{
	document.getElementById(id1).style.display="none";
	document.getElementById(id2).style.display = "";
}


