﻿window.setInterval("scrollTick()",30);

function scrollTick() {
    for (i in scrollers)
    {
        scrollers[i].step();
    }
}

var scrollers = new Array();

function createVerticalScroller(pixelheight,linesshowing,pauseticks,lines,scroller,scrolling)
{
    // Write the HTML out to the document
    var id = "scroller"+scrollers.length
    if (linesshowing>lines.length) { linesshowing=lines.length };
    var mainheight = pixelheight*linesshowing;
    document.write("<div class='"+scroller+"' style='height:"+mainheight+"px'>");
    document.write("<div class='"+scrolling+"' id='"+id+"'>");
    for (i in lines) {
        document.write("<div style='height:"+pixelheight+"px'>"+lines[i]+"</div>");
    }
    for (i in lines) {
        if (i<linesshowing) {
            document.write("<div style='height:"+pixelheight+"px'>"+lines[i]+"</div>");
        }
    }
    document.write("</div>");
    document.write("</div>");
    // Create the object
    
    var scroller = new Object();
    scroller.id = id;
    scroller.lines=lines.length;
    scroller.lineheight=pixelheight;
    scroller.showing=linesshowing;
    scroller.position=1;
    scroller.pauseticks=pauseticks;
    scroller.pause=pauseticks;
    scroller.step = function step()
    {
      var el = document.getElementById(this.id);
      this.position-=1;
      if (this.position == -(this.lines)*this.lineheight)
      {
        this.position=1;
        this.pause=this.pauseticks;        
      }
      else
      {
        if ((this.position)%20 == 0)
        {
          if (this.pause==0)
          {
            this.pause=this.pauseticks;
          }
          else
          {
            this.pause-=1;
            this.position+=1;
            return;
          }
        }
      }
      el.style.top=this.position+"px";
    }
    
    scrollers[scrollers.length]=scroller;
}

    

