TEXT_DELAY_PX = 100

DynLine = Class.create();
DynLine.prototype = {
	initialize: function( outputDivID, msgDivID, link, speed ) {
		this.outputDiv  = document.getElementById( outputDivID );
		this.msgDiv     = document.getElementById( msgDivID );
		this.speed      = speed || 1;
    this.link       = link || 1;
    
    var self = this;
    
    this.msgDiv.onmouseover = function() {
      self.xTimer.stop();
    }
    
    this.msgDiv.onmouseout = function() {
      self.xTimer.start();
    }
    
    this.msgDiv.onclick = function() {
      if ( self.link ) {
        document.location = self.link;
      }
    }
    
    this.msgDiv.style.left = this.outputDiv.offsetWidth + TEXT_DELAY_PX + 'px';
		
		this.xTimer = new XTimer( 1, true );
		this.xTimer.caller = this;
		this.xTimer.onTimeOut = function(){
			if ( parseInt( this.msgDiv.style.left ) > parseInt( this.msgDiv.offsetWidth )*(-1) ) {
				this.msgDiv.style.left = ( parseInt( this.msgDiv.style.left ) - this.speed ) + 'px';
			} else {
				this.msgDiv.style.left = this.outputDiv.offsetWidth + TEXT_DELAY_PX + 'px';
			}
		}
		
		this.xTimer.start();
	}
}
