//首页自动换图广告
function fnGoodsMove_Type1() {
	this.GoodsSetTime = null;
	this.BannerCurrent = 0;
	
	this.GoodsSetting = function() {
		this.ObjBox = document.getElementById(this.DivName);
		this.PrevBtnLink = document.getElementById(this.PrevBtn);
		this.NextBtnLink = document.getElementById(this.NextBtn);
		this.ObjUl = this.ObjBox.getElementsByTagName("ul")[0];
		this.ObjLi = this.ObjUl.getElementsByTagName("li");
		this.ObjLiNum = this.ObjLi.length;
		this.TotalWidth = this.DateWidth * this.ObjLiNum;
		
		this.ObjBox.style.width = this.TotalWidth + "px";
		//alert(this.DivName);
		if ( this.ObjLiNum % this.DateNum == 0 ) {
			this.BannerEnd = this.TotalWidth - ( this.DateWidth * this.DateNum );
		} else {
			this.BannerEnd = this.TotalWidth - this.DateWidth;
		}
		
		this.BannerPrevLeft = this.BannerEnd;
		this.BannerNextLeft = this.DateWidth * this.DateNum ;
		
		this.PrevBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerPrevLeft + ",'prev')";
		this.NextBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerNextLeft + ",'next')";
		
		this.GoodsSetTime = setTimeout( this.fnName + "._moveFrame('" + this.BannerNextLeft + "','next')" , 3000 );
	}
	
	this._moveFrame = function(val,fnmove) {
		clearTimeout(this.GoodsSetTime)
		
		if ( Math.abs(val - this.BannerCurrent) > 5 ) {
			this.BannerCurrent = this.BannerCurrent + ( val - this.BannerCurrent ) * this.Speed;
		} else {
			this.BannerCurrent = val;
		}
		
		this.ObjUl.style.left = ( -1 * this.BannerCurrent ) + "px";
		
		if ( this.BannerCurrent != val ) {
			this.GoodsSetTime = setTimeout(this.fnName + "._moveFrame(" + val + ",'" + fnmove + "')",10);
		} else {
			this.CurrentPicNum = this.BannerCurrent / this.DateWidth;
			
			this.BannerPrevLeft = this.BannerCurrent - ( this.DateWidth * this.DateNum );
			this.BannerNextLeft = this.BannerCurrent + ( this.DateWidth * this.DateNum );
			
			if ( this.BannerCurrent == 0 ) {
				this.BannerPrevLeft = this.BannerEnd;
			} else if ( this.BannerCurrent == this.BannerEnd ) {
				this.BannerNextLeft = 0;
			}
			this.PrevBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerPrevLeft + ",'prev')";
			this.NextBtnLink.href = "javascript:" + this.fnName +"._moveFrame(" + this.BannerNextLeft + ",'next')";
		}
		
		this.GoodsSetTime = setTimeout( this.fnName + "._moveFrame('" + this.BannerNextLeft + "','next')" , 3000 );
	}
}
