function Roller(name, id, shiftBy, interval)
{
  this.name     = name;
  this.id       = id;
  this.shiftBy  = shiftBy ? shiftBy : 1;
  this.interval = interval ? interval : 100;
  this.runId	= null;

  this.div = document.getElementById(id);

  this.left = 100;//530
  this.shiftLeftAt = this.div.firstChild.offsetWidth;
  this.span=this.div.firstChild;
  this.div.style.width = 2 * screen.availWidth;
  this.div.style.visibility = 'visible';
}

function startRoller()
{
  this.stop();
  this.left -= this.shiftBy;
  if (this.left <= -this.shiftLeftAt)
  {
    this.left = 100;//530
  }
  this.div.style.left = (this.left + 'px');
  this.runId = setTimeout(this.name + '.start()', this.interval);
}

function stopRoller()
{
  if(this.runId)
    clearTimeout(this.runId);
  this.runId = null;
}

function changeRollerInterval(newinterval)
{
  if (typeof(newinterval) == 'string')
    newinterval =  parseInt('0' + newinterval, 10); 
  if (typeof(newinterval) == 'number' && newinterval > 0)
    this.interval = newinterval;
    this.stop();
    this.start();
}

/* Prototypes for Roller */
Roller.prototype.start = startRoller;
Roller.prototype.stop = stopRoller;
Roller.prototype.changeInterval = changeRollerInterval;

