// JavaScript Document

	function _gel(objName){
  return document.getElementById(objName);
}

var Roll = function(dom,pw){
  this.dom = dom;
  this.Speed = 10; //ï¿½Ù¶ï¿½(ï¿½ï¿½ï¿½ï¿½) 
  this.Space = 6; //Ã¿ï¿½ï¿½ï¿½Æ¶ï¿½(px) 
  this.PageWidth = pw; //ï¿½ï¿½Ò³ï¿½ï¿½ï¿?
  this.fill = 0; //ï¿½ï¿½ï¿½ï¿½ï¿½ï¿½Î» 
  this.MoveLock = false; 
  this.MoveTimeObj; 
  this.Comp = 0; 
  this.AutoPlayObj = null;
}
Roll.prototype = {
  init: function(){
    var me = this;
    document.getElementById(this.dom + 'List2').innerHTML = document.getElementById(this.dom + 'List1').innerHTML; 
    _gel(this.dom).scrollLeft = this.fill; 
    _gel(this.dom).onmouseover = function(){clearInterval(me.AutoPlayObj);} 
    _gel(this.dom).onmouseout = function(){me.AutoPlay();} 
    this.AutoPlay();
  },
  AutoPlay: function(){
    var me = this;
    clearInterval(this.AutoPlayObj); 
    this.AutoPlayObj = setInterval(function(){
      me.ISL_ScrUp()
      ,me.ISL_StopUp()
    },3000);
  },
  ISL_GoUp: function(){
    var me= this;
    if(this.MoveLock) return; 
    clearInterval(this.AutoPlayObj); 
    this.MoveLock = true; 
    this.MoveTimeObj = setInterval(function(){me.ISL_ScrUp()},this.Speed); 
  },
  ISL_StopUp: function(){
    clearInterval(this.MoveTimeObj); 
    if(_gel(this.dom).scrollLeft % this.PageWidth - this.fill != 0){ 
      this.Comp = this.fill - (_gel(this.dom).scrollLeft % this.PageWidth); 
      this.CompScr();
    }else{ 
      this.MoveLock = false; 
    } 
    this.AutoPlay(); 
  },
  ISL_ScrUp: function(){
    if(_gel(this.dom).scrollLeft <= 0){
      _gel(this.dom).scrollLeft = _gel(this.dom).scrollLeft + _gel(this.dom + 'List1').offsetWidth
    } 
    _gel(this.dom).scrollLeft -= this.Space ; 
  },
  ISL_GoDown: function(){
    var me = this;
    clearInterval(this.MoveTimeObj); 
    if(this.MoveLock) return; 
    clearInterval(this.AutoPlayObj); 
    this.MoveLock = true;
    this.ISL_ScrDown();
    this.MoveTimeObj = setInterval(function(){me.ISL_ScrDown()},this.Speed); 
  },
  ISL_StopDown: function(){
    clearInterval(this.MoveTimeObj); 
    if(_gel(this.dom).scrollLeft % this.PageWidth - this.fill != 0 ){ 
      this.Comp = this.PageWidth - _gel(this.dom).scrollLeft % this.PageWidth + this.fill;
      this.CompScr(); 
    }else{
      this.MoveLock = false; 
    }
    this.AutoPlay(); 
  },
  ISL_ScrDown: function(){
    if(_gel(this.dom).scrollLeft >= _gel(this.dom+'List1').scrollWidth){
      _gel(this.dom).scrollLeft = _gel(this.dom).scrollLeft - _gel(this.dom+'List1').scrollWidth;
    } 
    _gel(this.dom).scrollLeft += this.Space ; 
  },
  CompScr: function(){
    var me = this;
    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; 
      } 
      _gel(this.dom).scrollLeft -= num; 
      setTimeout(function(){me.CompScr()},this.Speed); 
    }else{ //ï¿½Â·ï¿½ 
      if(this.Comp > this.Space){ 
        this.Comp -= this.Space; 
        num = this.Space; 
      }else{ 
        num = this.Comp; 
        this.Comp = 0; 
      } 
      _gel(this.dom).scrollLeft += num; 
      setTimeout(function(){me.CompScr()},this.Speed); 
    } 
  }
}

