var Ticker = Class.create();
Ticker.prototype = {
    message: null,
    helpDiv:null,
    interval: 0,
    target: null, source: null,
    tWidth: 0, sWidth: 0,
    initialize: function(target, source, options) 
    {
       /*var helpSpan = document.createElement('span');
      document.body.appendChild(helpSpan);
       this.helpSpan = $(helpSpan).setStyle({left: '-1000px'})*/
       this.target = $(target); 
       this.tWidth = this.target.getWidth();
       this.source = $(source);
    //  this.helpSpan.innerHTML = this.source.innerHTML;
       this.sOrgWidth = this.source.getWidth();
       this.sWidth = this.source.getWidth();
      // this.source.setStyle({width:'110%'});
      // this.text = this.source.textContent;
       // Nach dem Ausmessen, innen erweitern (damit Text nie ausser Bildes laeuft)
      // if(this.tWidth > this.sWidth)
          this.source.innerHTML += this.source.innerHTML;
       
       this.innerHTML = this.source.innerHTML;
       this.options = Object.extend({
            updateRate:100,
            beforeStart:function(){ 
               this.counter++;
            }.bind(this) 
         }, options || {});
        this.target.appendChild(this.source);
        this.source.show();
        this.source.setStyle({marginLeft: '0px',display: 'block'})
        
	this.start();
    },
    start: function()
    {
	   this.interval = new PeriodicalExecuter( 
	      function() {
           // this.text=this.text.slice(1,this.text.length)+this.text.slice(0,1);
           // this.source.textContent = this.text;
	         var currentLeft = parseInt(this.source.getStyle('margin-left'));
	         var newLeft = ((currentLeft - this.tWidth) > -(this.sWidth*2)) ? currentLeft-1 : currentLeft+this.sWidth-1;
	         this.source.setStyle({marginLeft: newLeft + 'px'});
	      }.bind(this), this.options.updateRate);
    },
    stop: function()
    {
      this.interval.stop();
    }
};