var spaceslength=130;
var spaces="";

for (var c = 0; c < spaceslength; c++)
{
	spaces += " ";
}

function init_statusscroller() 
{
	timer = setTimeout('scroll(130)', 500);
}

function scroll(position) {
  var statmsg = "";
  var cmd = "";

  if (position > spaceslength) {
    position--;
    cmd = "scroll(" + position + ")";
    timer = setTimeout(cmd, delay);
  }
  else if (position <= spaceslength && position > 0) {
    statmsg = spaces.substring(0, position);
    statmsg += msg;

    position--;
    cmd = "scroll(" + position + ")";
    window.status = statmsg;

    timer = setTimeout(cmd, delay);
  }
  else if (position <= 0) {
    if (-position < msg.length) {
      statmsg += msg.substring(-position, msg.length);
      statmsg += spaces.substring(0, spaces.length / 4);
      statmsg += msg;

      position--;
      cmd = "scroll(" + position + ")";
      window.status = statmsg;

      timer = setTimeout(cmd, delay*3);
    }
    else {
      cmd = "scroll(" + spaces.length / 4 + ")";
      timer = setTimeout(cmd, delay);
    }
  }
}

init_statusscroller();