//goods_detail pic scoll
	//商品细节相册图滚动
	var timeoutid = null;
	var intervalId = null;
	function scroll_auto(way){
		if(intervalId){clearInterval(intervalId)}
		if(timeoutid != null){clearTimeout(timeoutid)}
		
		var s = document.getElementById('scrollbox').getElementsByTagName('li')[0].offsetWidth+1;
		
		var t = 0; tt = 5;v0 = 50;
		var a = 2*(s/tt - v0)/tt;
		var v = v0;
		
		var obj = document.getElementById('focustab');
		this.oScroll = obj;
		
		this.oLeft = this.oScroll.currentStyle ? parseInt(this.oScroll.currentStyle.left) : parseInt(document.defaultView.getComputedStyle(this.oScroll, "").getPropertyValue("left"));
		
		var oS = this.oScroll;
		var oL = this.oLeft;
		gooo = this.init.caller
		
		
		
		if(way == 'left'){
			intervalId = setInterval(function()
									{
										t += 0.5;
										oS.style.left = (oL -(v * t + (a * t * t)/2)) + 'px';
										if((50 + a * t) <= 0)
										{
											clearInterval(intervalId);
											oS.appendChild(oS.getElementsByTagName('li')[0]);
											oS.style.left = '0px';
											timeoutid = setTimeout('gooo()' , 5000);
										}
									} , 50);
		}
		else if(way == 'right') {
			intervalId = setInterval(function()
									{
										t += 0.5;
										oS.style.left = (oL + (v * t + (a * t * t)/2)) + 'px';
										if((50 + a * t) <= 0)
										{
											clearInterval(intervalId);
											theLast = oS.lastChild;											
											while(theLast.nodeType == 3)
											{
												theLast = theLast.previousSibling;
											}
											oS.insertBefore(theLast,oS.getElementsByTagName('li')[0]);
											oS.style.left = '0px';
											timeoutid = setTimeout('gooo()' , 5000);
										}
									} , 50);
		}
		
	}
	
	function scroll(obj)
	{
		this.oScroll = obj;
		this.s = this.oScroll.getElementsByTagName('li')[0].offsetWidth+1;
		this.tt = 5;
		this.t = 0;
		this.v0 = 50;
		this.a = 2*(this.s/this.tt - this.v0)/this.tt;
		this.oLeft = this.oScroll.currentStyle ? parseInt(this.oScroll.currentStyle.left) : parseInt(document.defaultView.getComputedStyle(this.oScroll, "").getPropertyValue("left"));
	}
	timeoutid = null;
	intervalId = null;
	scroll.prototype.init = function()
	{
		if(intervalId){clearInterval(intervalId)}
		if(timeoutid != null){clearTimeout(timeoutid)}
		var t = this.t;
		var a = this.a;
		var v = this.v0;
		var oS = this.oScroll;
		var oL = this.oLeft;
		gooo = this.init.caller
		if(this.way == 'left')
		{
			intervalId = setInterval(function()
									{
										t += 0.5;
										oS.style.left = (oL -(v * t + (a * t * t)/2)) + 'px';
										if((50 + a * t) <= 0)
										{
											clearInterval(intervalId);
											oS.appendChild(oS.getElementsByTagName('li')[0]);
											oS.style.left = '0px';
											timeoutid = setTimeout('gooo()' , 5000);
										}
									} , 50);
		}
		else if(this.way == 'right') {
			intervalId = setInterval(function()
									{
										t += 0.5;
										oS.style.left = (oL + (v * t + (a * t * t)/2)) + 'px';
										if((50 + a * t) <= 0)
										{
											clearInterval(intervalId);
											theLast = oS.lastChild;											
											while(theLast.nodeType == 3)
											{
												theLast = theLast.previousSibling;
											}
											oS.insertBefore(theLast,oS.getElementsByTagName('li')[0]);
											oS.style.left = '0px';
											timeoutid = setTimeout('gooo()' , 5000);
										}
									} , 50);
		}
	};


	window.onload = function()
	{
		var objj = document.getElementById('focustab');
		obj_scroll = new scroll(objj);

		arr = objj.getElementsByTagName('li');
		for(i=0 ; i< arr.length ; i++)
		{
			arr[i].onmouseover = function()
			{
				if(intervalId){clearInterval(intervalId)}
				if(timeoutid != null){clearTimeout(timeoutid)}
			}
			arr[i].onmouseout = function()
			{
				//obj_scroll.init();
			}
		}
	}

//goods_detail pic auotab
function initAutoFocus(){
    autoShiftFocus("focustab", "a", "focuscont", "div");
    function autoShiftFocus(tabsid, tabstagname, contentid, contenttagname){
        var tabs = document.getElementById(tabsid).getElementsByTagName(tabstagname);
        tabs[0].className = "act";
        var contents = document.getElementById(contentid).getElementsByTagName(contenttagname);
        contents[0].style.display = "block";
        var cur_index_num = 0;
        if (tabstagname == "a") {
            for (var a = tabs.length - 1; a >= 0; a--) {
                tabs[a].onclick = function(){
                    return false;
                }
            }
        }
        function getContentsArr(){
            var contentsarr = new Array();
            for (var z=0;z<contents.length; z++) {
                if(contents[z].id.indexOf(contentid)>=0){
                    contentsarr[contentsarr.length] = contents[z];
                }                
            }
             return contentsarr;
        }
        var contarr=getContentsArr();
        function autoSlideTopic(){
            for (var a = tabs.length - 1; a >= 0; a--) {
                tabs[a].className = "";
            }
            
            for (var b = contarr.length - 1; b >= 0; b--) {                
                    contarr[b].style.display = "none";
            }
            contarr[cur_index_num].style.display = "block";
            
            tabs[cur_index_num].className = "act";
            var total_num = tabs.length;
            cur_index_num++;
            if (cur_index_num >= total_num) {
                cur_index_num = 0;
            }
        }
        for (var c = tabs.length - 1; c >= 0; c--) {
            tabs[c].onmouseover = function(){
                changeTabs(this.name);
            }
            tabs[c].onmouseout = function(){
                clearInterval(autoSlideTopic);
            }
        }
        function changeTabs(num){
            var thenum = num - 1;
            for (var n = tabs.length - 1; n >= 0; n--) {
                tabs[n].className = "";
            }
            //tabs[thenum].className = "act";
            for (var m = contarr.length - 1; m >= 0; m--) {
                contarr[m].style.display = "none";
            }
            contarr[thenum].style.display = "block";
            cur_index_num = thenum;
        }
        
    }
    
}

//goods_detail show assemble
slider.names = new Array();
function slider()
{
	this.id = slider.names.length;
	slider.names[this.id] = this;
	this.target	 = document.getElementById(arguments[0]);	//第一个参数：被操作div的id
	this.direction = arguments[1];//第二个参数：div弹出的方向
	this.height = arguments[2];//第三个参数：div的高度
	this.width = arguments[3];//第四个参数：div的宽度
	this.step = arguments[4];//第五个参数：希望动作分解为几步完成
	this.timer = 10 * arguments[5];//第六个参数：每个动作的间隔时间，10ms为一个单位
	this.startopa = arguments[6];//第七个参数：div开始的透明度
	this.sparent = this.target.parentNode;//获取操作div的父容器
	this.intervalid = null;//循环定时的id
	this.i = 0;//循环的计数器
	this.status = 0;//slider层的状态：0-可以展开；1-不可以展开
	this.target.style.display = "none";//先将div隐去
	return this;
}
slider.prototype.initialize = function()
{
	this.sparent.style.overflow = "hidden";//设置父容器overflow
	this.target.style.width = Number(this.width) + 'px';//设置目标div的宽度
	this.target.style.height = Number(this.height) + 'px';//设置目标div的高度
	this.target.style.position = "";//设置目标div的定位方式
	this.target.style.display = "";//设置目标div的显示方式
	this.target.style.filter = 'Alpha(opacity=' + Number(this.startopa) + ')';//设置目标div的透明度为初始透明度
	this.target.style.overflow = "hidden";//设置overflow
	switch(this.direction)//根据弹出方向设定div的margin
	{
		case 1://left to right
			this.target.style.marginLeft = "-" + this.width + "px";
			break;
		case 2://top to bottom
			this.target.style.marginTop = "-" + this.height + "px";
			break;
		case 3://right to left
			this.target.style.marginRight = "-" + this.width + "px";
			break;
	}
}
slider.prototype.show = function()
{
	if (this.status==0)//检查状态是否已经展开
	{
		this.initialize();//操作div及其父容器的初始化
		this.intervalid = window.setInterval("slider.names["+this.id+"].cycle()",this.timer);//设置动作循环
	}
}
slider.prototype.hide = function()
{
	if (this.status==1)//检查状态是否已经展开
	{
		this.intervalid = window.setInterval("slider.names["+this.id+"].decycle()",this.timer);//设置动作循环
	}
}
slider.prototype.cycle = function()	//单步循环动作
{
	var opa = this.target.style.filter.split("=")[1].split(")")[0]//获取目标div的透明度数值
	var opastep = Math.round(((100 - Number(opa)) / this.step)+2.5);//计算每步增加的透明度
	var nopa = Number(opa) + Number(opastep);//当前透明度
	if (nopa>100){this.target.style.filter = 'Alpha(opacity=100)';}else{this.target.style.filter = 'Alpha(opacity=' + String(nopa) + ')';}//给div透明度赋值
	switch(this.direction)//根据弹出方向计算和设定div的动作
	{
		case 1:		//left to right
			var opx = this.target.style.marginLeft.split("px")[0];
			var pxstep = Math.round((this.width / this.step)+0.5);
			var npx = Number(opx) + Number(pxstep);
			if (npx>0){this.target.style.marginLeft = '0px';}else{this.target.style.marginLeft = String(npx) + 'px';}
			break;
		case 2:		//top to bottom
			var opx = this.target.style.marginTop.split("px")[0];
			var pxstep = Math.round((this.height / this.step)+0.5);
			var npx = Number(opx) + Number(pxstep);
			if (npx>0){this.target.style.marginTop = '0px';}else{this.target.style.marginTop = String(npx) + 'px';}
			break;
		case 3:		//right to left
			var opx = this.target.style.marginRight.split("px")[0];
			var pxstep = Math.round((this.width / this.step)+0.5);
			var npx = Number(opx) + Number(pxstep);
			if (npx>0){this.target.style.marginRight = '0px';}else{this.target.style.marginRight = String(npx) + 'px';}
			break;
	}
	this.i++	//计数器+1
	if (this.i>(this.step-1)){window.clearInterval(this.intervalid);this.i=0;this.status=1;}	//循环完毕，清除循环定时
}
slider.prototype.decycle = function()	//单步循环动作
{
	var opa = this.target.style.filter.split("=")[1].split(")")[0]//获取目标div的透明度数值
	var opastep = Math.round(((100 - Number(opa)) / this.step)+2.5)*2;//计算每步增加的透明度
	var nopa = Number(opa) - Number(opastep);//当前透明度
	if (nopa<this.startopa){this.target.style.filter = 'Alpha(opacity=' + this.startopa + ')';}else{this.target.style.filter = 'Alpha(opacity=' + String(nopa) + ')';}//给div透明度赋值
	switch(this.direction)//根据弹出方向计算和设定div的动作
	{
		case 1:		//left to right
			var opx = this.target.style.marginLeft.split("px")[0];
			var pxstep = Math.round((this.width / Math.round(this.step*0.5))+0.5);
			var npx = Number(opx) - Number(pxstep);
			if (Math.abs(npx)>this.width+2){this.target.style.marginLeft = '-' + this.width + 'px';}else{this.target.style.marginLeft = String(npx) + 'px';}
			break;
		case 2:		//top to bottom
			var opx = this.target.style.marginTop.split("px")[0];
			var pxstep = Math.round((this.height / Math.round(this.step*0.5))+0.5);
			var npx = Number(opx) - Number(pxstep);
			if (Math.abs(npx)>this.height+2){this.target.style.marginTop = '-' + this.height + 'px';}else{this.target.style.marginTop = String(npx) + 'px';}
			break;
		case 3:		//right to left
			var opx = this.target.style.marginRight.split("px")[0];
			var pxstep = Math.round((this.width / Math.round(this.step*0.5))+0.5);
			var npx = Number(opx) - Number(pxstep);
			if (Math.abs(npx)>this.width+2){this.target.style.marginRight = '-' + this.width + 'px';}else{this.target.style.marginRight = String(npx) + 'px';}
			break;
	}
	this.i++	//计数器+1
	if (this.i>(Math.round(this.step*0.5)-1)){window.clearInterval(this.intervalid);this.i=0;this.status=0;this.target.style.display = "none";}	//循环完毕，清除循环定时
}


