/****************************************************************
* Class Scroll                                                  *
*                                                               *
* Properties: -                                                 *
* Methods: set                                                  *
*            Input: (proc Function, lines Array, speed Integer) *
*            Output: -                                          *
****************************************************************/

function Scroll()
{
  function loop(proc, currentline, lines, speed, position, dir)
  {
    proc(lines[currentline].substring(0, position) + ']');
    position += dir;
    if (position > lines[currentline].length)
      window.setTimeout(function() { loop(proc, currentline, lines, speed, position - 1, -dir); }, 10 * speed);
    else
    {
      if (position < 0)
      {
        currentline++;
        if (currentline == lines.length)
          currentline = 0;
        position = 0;
        dir = 1;
      }
      window.setTimeout(function() { loop(proc, currentline, lines, speed, position, dir); }, speed);
    }
  }

  this.set = function(proc, lines, speed)
  {
    loop(proc, 0, lines, speed, 0, 1);
  };
}
