function startSlideAd(){
  if( !document.getElementById )
    return;
    
  if( !document.getElementById( "slide-ad" ) )
    return

  sa = new SlideAd();
  sa.Run();
}

function SlideAd(){
  this.root;  
  this.elements = new Array();
  this.currentElement = 0;
  this.startPos = 0;
  this.isRunning = false;

  this.Construct();
  }

SlideAd.prototype.Construct = function(){  
  this.root = document.getElementById( "slide-ad" );
  this.startPos = this.root.clientWidth;
  
  for( var i = 0; i < this.root.childNodes.length; i++ ){
    this.elements[ i ] = new SlideElement( this, this.root.childNodes[ i ], i );
  }
}

SlideAd.prototype.Run = function(){
  if( this.elements == 0 )
    return;

  if( this.currentElement ==  this.elements.length )
    this.currentElement = 0;

  var el = this.elements[ this.currentElement++ ];
  el.Move();
  
  // this.elements[ this.currentElement++ ].Move();
}


function SlideElement( container, element, nr ){
  this.container = container;
  this.element = element;
  this.pos;
  this.toobj;
  
  this.obj = "SlideElementObject"+nr;  eval(this.obj + "=this");   
  this.Reset();
}

SlideElement.prototype.Reset = function(){
  this.isRunning = false;
  this.element.style.visibility = "hidden";
  this.pos = this.container.startPos;    
  this.element.style.left = this.pos + "px";
  this.container.isRunning = false;
}

SlideElement.prototype.Move = function(){ 
  this.element.style.visibility = "visible"
  this.pos -= 2;
    
  if( this.pos > -this.element.clientWidth ){  
    this.element.style.left = this.pos + "px";
    this.toobj =  window.setTimeout(this.obj+".Move()", 20 );
  }
  else{
    window.clearTimeout( this.toobj );
    this.Reset();
    this.container.Run();
  }
}
