// JavaScript Document
function GetObj(objName){if(document.getElementById){return eval('document.getElementById("'+objName+'")')}else{return eval('document.all.'+objName)}}
function AutoPlayClass(SCOLL_Name, ISL_Cont_id, list1_id, list2_id)
{
	this.Speed = 1; //速度(毫秒)
	this.Space = 2; //每次移动(px)
	this.PageWidth = 528; //翻页宽度
	this.fill = 0; //整体移位
	this.MoveLock = false;
	this.MoveTimeObj;
	this.Comp = 0;
	this.AutoPlayObj = null;
	GetObj(list2_id).innerHTML = GetObj(list1_id).innerHTML;	
	GetObj(ISL_Cont_id).scrollLeft = this.fill;	
	this.clearInterval = function(AutoPlayObj){
		clearInterval(this.AutoPlayObj);
	}
			
	this.AutoPlay = function(){ //自动滚动
	 clearInterval(this.AutoPlayObj);
	 var ISL_GoDown = this.ISL_GoDown;
	 var ISL_StopDown = this.ISL_StopDown;
	 this.AutoPlayObj = setInterval(SCOLL_Name + '.ISL_GoDown();'+ SCOLL_Name+'.ISL_StopDown();',1500); //间隔时间
	}
	
	this.ISL_GoUp = function (){ //上翻开始
	 if(this.MoveLock) return;
	 clearInterval(this.AutoPlayObj);
	 this.MoveLock = true;
	 var ISL_ScrUp = this.ISL_ScrUp; 
	 this.MoveTimeObj = setInterval(SCOLL_Name +'.ISL_ScrUp();',this.Speed);
	}
	this.ISL_StopUp = function ISL_StopUp(){ //上翻停止
	 clearInterval(this.MoveTimeObj);
	 if(GetObj(ISL_Cont_id).scrollLeft % this.PageWidth - this.fill != 0){
	  this.Comp = this.fill - (GetObj(ISL_Cont_id).scrollLeft % this.PageWidth);
	  this.CompScr();
	 }else{
	  this.MoveLock = false;
	 }
	 this.AutoPlay();
	}
	this.ISL_ScrUp = function ISL_ScrUp(){ //上翻动作
	 if(GetObj(ISL_Cont_id).scrollLeft <= 0){GetObj(ISL_Cont_id).scrollLeft = GetObj(ISL_Cont_id).scrollLeft + GetObj(list1_id).offsetWidth}
	 GetObj(ISL_Cont_id).scrollLeft -= this.Space ;
	}
	this.ISL_GoDown = function (){ //下翻		
	 clearInterval(this.MoveTimeObj);
	 if(this.MoveLock) return;	
	 clearInterval(this.AutoPlayObj);
	 this.MoveLock = true;
	 this.ISL_ScrDown();
	 var ISL_ScrDown = this.ISL_ScrDown;
	 this.MoveTimeObj = setInterval(SCOLL_Name + '.ISL_ScrDown()',this.Speed);
	}
	this.ISL_StopDown = function (){ //下翻停止		
	 clearInterval(this.MoveTimeObj);
	 if(GetObj(ISL_Cont_id).scrollLeft % this.PageWidth - this.fill != 0 ){
	  this.Comp = this.PageWidth - GetObj(ISL_Cont_id).scrollLeft % this.PageWidth + this.fill;
	  this.CompScr();
	 }else{
	  this.MoveLock = false;
	 }
	 this.AutoPlay();
	}
	this.ISL_ScrDown = function (){ //下翻动作
	 if(GetObj(ISL_Cont_id).scrollLeft >= GetObj(list1_id).scrollWidth){GetObj(ISL_Cont_id).scrollLeft = GetObj(ISL_Cont_id).scrollLeft - GetObj(list1_id).scrollWidth;}
	 GetObj(ISL_Cont_id).scrollLeft += this.Space ;
	}
	this.CompScr=function (){
	 var num;
	 if(this.Comp == 0){this.MoveLock = false;return;}
	 if(this.Comp < 0){ //上翻
	  if(this.Comp < -this.Space){
	   this.Comp += this.Space;
	   num = this.Space;
	  }else{
	   num = -this.Comp;
	   this.Comp = 0;
	  }
	  GetObj(ISL_Cont_id).scrollLeft -= num;
	  var CompScr = this.CompScr()
	  setTimeout(SCOLL_Name+'.CompScr()',this.Speed);
	 }
	 else{ //下翻
	  if(this.Comp > this.Space){
	   this.Comp -= this.Space;
	   num = this.Space;
	  }else{
	   num = this.Comp;
	   this.Comp = 0;
	  }
	  GetObj(ISL_Cont_id).scrollLeft += num;
	  var CompScr = this.CompScr
	  setTimeout(SCOLL_Name +'.CompScr()',this.Speed);
	 }
	}
}

//下面是使用方法，注意，第一个参数要与返回的对象变量名相同, 如 at 并且at要是全局的，否则不能正常工作
//var at = new this.AutoPlayClass('at', 'ISL_Con', 'List1', 'List2');
//at.AutoPlay();

//var at2 = new this.AutoPlayClass('at2', 'ISL_Cont111', 'List111', 'List222');
//at2.AutoPlay();

