/* script for scroller*/

function scrollObject(objName, main, height, width, bkgcol, deccel, begin, speed, pause, classname) {
  this.objName = objName;
  this.main = main;
  this.one = main + "Block1";
  this.two = main + "Block2";
  this.block = new Array();
  this.blockup = 1;
  this.height = height;
  this.width = width;
  this.bkgcol = bkgcol;
  this.deccel = Math.max(deccel, 1);
  this.begin = Math.max(Math.min(begin, this.height), 1);
  this.speed = speed;
  this.pause = pause;
  this.slide = height / this.begin;
  this.table = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td class=\"" + classname + "\" style=\"width:" + width + "px;height:" + height + "px;\">";
  this.scroll = scroll;
  this.scrollLoop = scrollLoop;
}

function scroll() {if (!document.getElementById) return false;
  document.getElementById(this.main).innerHTML = "<div id=\"" + this.one + "\"></div><div id=\"" + this.two + "\"></div>";
  var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
  for (var i = 0; i <= 2; i++) {
    if (i > 0) {
      divList[i].style.position = "absolute";
      divList[i].style.left = "0px";
      (i == 1) ? divList[i].style.top = "0px" : divList[i].style.top = this.height + "px";
      divList[i].innerHTML = this.table + this.block[i - 1] + "</td></tr></table>";
    } else {
      divList[i].style.position = "relative";
      divList[i].style.background = this.bkgcol;
    }
    divList[i].style.width = this.width + "px";
    divList[i].style.height = this.height + "px";
    divList[i].style.overflow = "hidden";
  } setTimeout(this.objName + ".scrollLoop();", this.pause);
}

function scrollLoop() {
  var divList = [document.getElementById(this.main), document.getElementById(this.one), document.getElementById(this.two)];
  for (var j = 1; j <= 2; j++) divList[j].style.top = (parseInt(divList[j].style.top) - this.slide) + "px";
  this.slide = Math.max(parseInt(this.slide / this.deccel), 1);
  if (Math.min(parseInt(divList[1].style.top), parseInt(divList[2].style.top)) <= -this.height) {
    this.slide = this.height / this.begin;
    if (++this.blockup >= this.block.length) this.blockup = 0;
    var wDiv = (parseInt(divList[1].style.top) <= -this.height) ? 1 : 0;
    divList[2 - wDiv].style.top = this.height + "px";
    divList[2 - wDiv].innerHTML = this.table + this.block[this.blockup] + "</td></tr></table>";
    divList[1 + wDiv].style.top = "0px";
    setTimeout(this.objName + ".scrollLoop();", this.pause);
  } else setTimeout(this.objName + ".scrollLoop();", this.speed);
}