/* **************************************************************************
*** GreyWyvern's HTML Block Scroller & Marquee ******************************
*****************************************************************************
* HTML Block Scroller & Marquee JavaScript - v1.4 - Coded by GreyWyvern
*  - Copyright 2003 - Licenced for free distribution under the BSDL
*  -     http://www.opensource.org/licenses/bsd-license.php
*/


var scrollerL = new scrollObject("scrollerL", "scrollLeft", 250, 120, "", "right", 1.35, 2.7, 30, 7000, "scrollClass");
var scrollerR = new scrollObject("scrollerR", "scrollRight", 250, 120, "", "right", 1.35, 2.7, 30, 7000, "scrollClass");
var scrollerS = new scrollObject("scrollerS", "scrollStrip", 520, 120, "", "right", 1.35, 2.7, 30, 7000, "scrollClass");
//scrollerL.block[0] = '<a href="/hj/info/apply/"><img src="/images/hj/teaser2/home/nowhiring-left.gif" width="250" height="120" alt="Now Hiring" border="0"></a>';
//scrollerL.block[1] = '<a href="/hj/info/lore/races/"><img src="/images/hj/teaser2/home/races-left.gif" width="250" height="120" alt="Races" border="0"></a>';
//scrollerL.block[2] = '<a href="/hj/info/lore/cities/"><img src="/images/hj/teaser2/home/cities-left.gif" width="250" height="120" alt="Races" border="0"></a>';
scrollerL.block[0] = '<a href="/hj/info/faq/"><img src="/images/hj/teaser2/home/faq-left.gif" width="250" height="120" alt="FAQ" border="0"></a>';
scrollerL.block[1] = '<a href="/hj/forums/"><img src="/images/hj/teaser2/home/forums-left.gif" width="250" height="120" alt="Forums" border="0"></a>';

//scrollerR.block[0] = '<a href="/hj/info/news/inthemedia.asp"><img src="/images/hj/teaser2/home/interviews-right.gif" width="250" height="120" alt="Interviews" border="0"></a>';
//scrollerR.block[1] = '<a href="/hj/info/lore/timeline/"><img src="/images/hj/teaser2/home/timeline-right.gif" width="250" height="120" alt="Timeline" border="0"></a>';
//scrollerR.block[2] = '<a href="/hj/features/"><img src="/images/hj/teaser2/home/features-right.gif" width="250" height="120" alt="Timeline" border="0"></a>';
scrollerR.block[0] = '<a href="/hj/gallery/"><img src="/images/hj/teaser2/home/gallery-right.gif" width="250" height="120" alt="Gallery" border="0"></a>';
scrollerR.block[1] = '<a href="/hj/info/links/"><img src="/images/hj/teaser2/home/fansites-right.gif" width="250" height="120" alt="Fansites" border="0"></a>';

scrollerS.block[0] = '1';
scrollerS.block[1] = '2';
//scrollerS.block[2] = '3';
//scrollerS.block[3] = '4';

ScrollObjectMade2 = true;

function scrollObject(objName, main, width, height, bkgcol, direct, 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.divup = 1;
  this.height = height;
  this.width = width;
  this.bkgcol = bkgcol;
  this.direct = direct;
  this.deccel = Math.max(deccel, 1);
  this.begin = Math.max(Math.min(begin, (direct == "up" || direct == "down") ? height : width), 1);
  this.speed = speed;
  this.pause = pause;
  this.slide = ((direct == "up" || direct == "down") ? height : width) / this.begin;
//  this.table = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td class=\"" + classname + "\" style=\"width:" + width + "px;height:" + height + "px;\">";
  this.table = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:" + width + "px;height:" + height + "px;\"><tr><td valign=\"top\" width=\"250\">";
  this.scroll = scroll;
  this.scrollLoop = scrollLoop;
}

function scroll() {if (!document.getElementById) return false;
	if(!document.getElementById(this.main)) 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";
      if (this.direct == "up" || this.direct == "down") {
        divList[i].style.left = "0px";
        divList[i].style.top = (i == 1) ? "0px" : ((this.direct == "up") ? "" : "-") + this.height + "px";
      } else {
        divList[i].style.left = (i == 1) ? "0px" : ((this.direct == "left") ? "" : "-") + this.width + "px";
        divList[i].style.top = "0px";
      } divList[i].innerHTML = this.table + scrollerL.block[i - 1] + "</td><td width=\"20\"><img src=\"/images/transparent.gif\" width=\"20\" height=\"1\" alt=\"\"></td><td width=\"250\">" + scrollerR.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)];
  this.slide = Math.max(this.slide / this.deccel, 1);
  var slideInc = (this.direct == "up" || this.direct == "left") ? -parseInt(this.slide) : parseInt(this.slide);
  if ((this.direct == "up" && Math.max(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) <= 0) ||
      (this.direct == "down" && Math.min(parseInt(divList[1].style.top) + slideInc, parseInt(divList[2].style.top) + slideInc) >= 0) ||
      (this.direct == "left" && Math.max(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) <= 0) ||
      (this.direct == "right" && Math.min(parseInt(divList[1].style.left) + slideInc, parseInt(divList[2].style.left) + slideInc) >= 0)) {
    this.slide = ((this.direct == "up" || this.direct == "down") ? this.height : this.width) / this.begin;
    if (++this.blockup >= this.block.length) this.blockup = 0;
    this.divup = (this.divup == 1) ? 2 : 1;
    if (this.direct == "up" || this.direct == "down") {
      divList[3 - this.divup].style.top = ((this.direct == "down") ? "-" : "") + this.height + "px";
      divList[this.divup].style.top = "0px";
    } else {
      divList[3 - this.divup].style.left = ((this.direct == "right") ? "-" : "") + this.width + "px";
      divList[this.divup].style.left = "0px";
//    } divList[3 - this.divup].innerHTML = this.table + this.block[this.blockup] + "</td></tr></table>";
//    } divList[3 - this.divup].innerHTML = this.table + this.block[this.blockup] + "";
    } divList[3 - this.divup].innerHTML = this.table + scrollerL.block[this.blockup] + "</td><td width='20'><img src='/images/transparent.gif' width='20' height='1' alt=''></td><td>" + scrollerR.block[this.blockup] + "</td></tr></table>";

    setTimeout(this.objName + ".scrollLoop();", this.pause);
  } else {
    for (var j = 1; j <= 2; j++) {
      if (this.direct == "up" || this.direct == "down") {
        divList[j].style.top = (parseInt(divList[j].style.top) + slideInc) + "px";
      } else divList[j].style.left = (parseInt(divList[j].style.left) + slideInc) + "px";
    } setTimeout(this.objName + ".scrollLoop();", this.speed);
  }
}