var Ticker = Class.create({

	initialize : function(base, options) {
		this.base = $(base);
    this.base.setStyle({whiteSpace:'nowrap',overflow:'hidden'});
    if (this.base.scrollWidth <= this.base.offsetWidth) return;

    this.options = Object.extend({moveTime:.05,movePixel:1,pauseOnHover:true}, options);

    this.scrollWidth = this.base.scrollWidth;
    this.offsetWidth = this.base.offsetWidth;
    this.currLeft = this.offsetWidth;
    this.scrollFunction = function() {
      this.base.setStyle({textIndent:this.currLeft+'px'});
      this.currLeft -= this.options.movePixel;
      if (this.currLeft <= (this.scrollWidth*-1)) { this.currLeft = this.offsetWidth; }
    }.bind(this);

    this.pe = new PeriodicalExecuter(this.scrollFunction, this.options.moveTime);
    
    if (this.options.pauseOnHover) {
      this.base.observe('mouseover', function(){this.pe.stop()}.bind(this));
      this.base.observe('mouseout', function(){this.pe = new PeriodicalExecuter(this.scrollFunction, this.options.moveTime)}.bind(this));
    }

	}

});
