var TextScroller = {

  init: function( containerId, scrollerParams )
  {
    this.items = new Array();

    var children = $( containerId ).childNodes;
    for( var i = 0; i < children.length; i++ )
    {
      if( children[ i ].tagName == "DIV" || children[ i ].tagName == "div" ) 
      {
        this.items[ this.items.length ] = children[ i ];
        children[ i ].style.left = scrollerParams.x;
        children[ i ].style.width = scrollerParams.width;
        children[ i ].style.height = scrollerParams.height;
        children[ i ].style.display = "none";
      }
    }

    this.scrollerParams = scrollerParams;

    this.y = scrollerParams.y + this.scrollerParams.height;
    this.index = 0;
    this.scroll();
  },


  scroll: function()
  {
    var step = 1;

    if ( this.y >= this.scrollerParams.y )
    {
      this.y -= step;

      this.defineItemParameters( this.index - 1, this.y - this.scrollerParams.height, true ); 
      this.defineItemParameters( this.index, this.y, true ); 

      // this.timer = setTimeout( "TextScroller.scroll()", pause );
      setTimeout( "TextScroller.scroll()", this.scrollerParams.scrollPause );
    }
    else 
    {
      this.defineItemParameters( this.index - 1, 0, false ); 

      this.y = this.scrollerParams.y + this.scrollerParams.height;
      this.index = ( this.index == this.items.length ) ? 0 : ( this.index + 1 );

      this.defineItemParameters( this.index, this.y, true ); 

      // clearTimeout( this.timer );
      // this.timer = setTimeout("TextScroller.scroll()", standstill );
      setTimeout("TextScroller.scroll()", this.scrollerParams.standStillPause );
    }
  },


  defineItemParameters: function( index, y, visible )
  {
    if( Browser.ie )
    {
      if( index >= 0 && index < this.items.length )
      {
        var item = this.items[ index ];
        item.style.top = y;
        item.style.clip = "rect(" + ( this.scrollerParams.y - y ) + " auto " + ( this.scrollerParams.y - y + this.scrollerParams.height ) + " auto)";
        item.style.display = ( visible ) ? "block" : "none";
      }
    }
    else
    if( Browser.n )
    {
    }
  }

}