/* ScrollTextWindow */
var speed = 30;
var ScrollLoop;
var ScrollTextTimer = 0;

//Object constructor
function makeScrollTextObj(obj, nest)
{
  nest = (!nest) ? "" : 'document.' + nest + '.';
  this.el = bw.dom ? document.getElementById(obj) : bw.ie4 ? document.all[obj] : bw.ns4 ? eval(nest + 'document.' + obj) : 0;
  this.css = bw.dom ? document.getElementById(obj).style : bw.ie4 ? document.all[obj].style : bw.ns4 ? eval(nest + 'document.' + obj) : 0;
  this.scrollHeight = bw.ns4 ? this.css.document.height : this.el.offsetHeight;
  this.clipHeight = bw.ns4 ? this.css.clip.height : this.el.offsetHeight;
  this.up = goUp;
  this.down = goDown;
  this.moveIt = s_moveIt;
  this.x = 0;
  this.y = 0;
  this.obj = obj + "Object";
  eval(this.obj + "=this");
  return this;
}

function makeScrollToolObj(obj)
{
  this.css = bw.dom ? document.getElementById(obj).style : bw.ie4 ? document.all[obj].style : bw.ns4 ? eval('document.' + obj) : 0;
  this.obj = obj + "Object";
  eval(this.obj + "=this");
  return this;
}

function s_moveIt(x, y)
{
  if(x != null)
  {
    this.x = x;
    this.css.left = this.x + px;
  }
  if(y != null)
  {
    this.y = y;
    this.css.top = this.y + px;
  }
}
//Makes the object go up
function goDown(move)
{
  if(this.y > oCont.clipHeight-this.scrollHeight)
  {
    this.moveIt(0, this.y-move);
    if(ScrollLoop)
      ScrollTextTimer = setTimeout(this.obj + ".down(" + move + ")", speed);
  }
}

//Makes the object go down
function goUp(move)
{
  if(this.y < 0)
  {
    this.moveIt(0, this.y-move);
    if(ScrollLoop)
      ScrollTextTimer = setTimeout(this.obj + ".up(" + move + ")", speed);
  }
}

//Calls the scrolling functions. Also checks whether the page is loaded or not.
function scroll(speed)
{
  if(scrolltextLoaded)
  {
    ScrollLoop = true;
    if(speed > 0)
      oScroll.down(speed);
    else
      oScroll.up(speed);
  }
}

//Stops the scrolling (called on mouseout)
function noScroll()
{
  ScrollLoop = false;
  if(ScrollTextTimer)
  {
    clearTimeout(ScrollTextTimer)
    ScrollTextTimer = 0;
  }
}

//Makes the object
var scrolltextLoaded = false;
function ScrollTextInit()
{
  oCont = new makeScrollTextObj('divMainText');
  oScroll = new makeScrollTextObj('divMain', 'divMainText');
  oScroll.moveIt(0, 0);
  oCont.css.visibility = "visible";
  oScroll.css.visibility = "visible";

  if(oCont.clipHeight < oScroll.scrollHeight)
  {
    oScrollUpTool = new makeScrollToolObj('divScrollUpTool');
    oScrollUpTool.css.visibility = "visible";
    oScrollDownTool = new makeScrollToolObj('divScrollDownTool');
    oScrollDownTool.css.visibility = "visible";
  }
  scrolltextLoaded = true;
}
