var leftButtonRoots = new Array('members','songlist','album','schedule','store','guestbook','links', 'home')
var pageTitles = new Array('Meet The RoadKings!', 'The RoadKings Song List', 'The RoadKings Photo Album',
                          'The RoadKings Schedule', 'RoadKings Merchandise', 'The RoadKings Guestbook', 'The RoadKings Links', 'The RoadKings - Ass Kickin\' Southern Rock And Blues');
			
var objButtons = new Array()
var objMenuLayers = new Array()
var contentLayer
var gbLayer
var marqueeLayer
var wScrollTimer
var hotindex
var storeWin
var bw

bw=new checkBrowser()

function goStore() {
  storeWin = window.open("http://www.cafepress.com/roadkings","storeWin");
}

function preLoadButtons() {
  var i;
  for (i=0; i<leftButtonRoots.length; i++) {
    o = new objButton(leftButtonRoots[i],'off');
    objButtons[o.name] = o
  }
}

function initPage(xhotIndex) {
  var o, omenu, thisO, b
  hotIndex = (xhotIndex=='album1'|xhotIndex=='album2'|xhotIndex=='album3'|xhotIndex=='album4')?'album':xhotIndex
  for (i=0; i<leftButtonRoots.length; i++) {
    o = objButtons[leftButtonRoots[i]];
    if (hotIndex==i|hotIndex==leftButtonRoots[i]) {
      o.state = "over"
      openAnchor = '<A HREF="#" onMouseOver="buttonMenuOut(\''+o.name+'\')" onMouseOut="buttonMenuIn(\''+o.name+'\')">'
      closeAnchor = '</A>'
      document.images['topbanner'].src = 'images/'+leftButtonRoots[i]+'_top.jpg'
      document.title = pageTitles[i]
	  
	  if (bw.ie) {
	      document.images[o.name] = o.overImage
    	  document.images[o.name].src = o.overImage.src
	  }
	  thisO = o.overImage
    } else {
      o.state = "off"
	  
	  if (bw.ie) {
        document.images[o.name] = o.offImage
        document.images[o.name].src = o.offImage.src
	  }
	  
	  thisO = o.offImage

      openAnchor = '<A HREF="/?pg='+o.name+'" onMouseOver="buttonOver(\''+o.name+'\')" onMouseOut="buttonOff(\''+o.name+'\')">'
      closeAnchor = '</A>'
    }
    html = '<TR><TD>'+openAnchor+'<IMG NAME="'+o.name+'" ID="'+o.name+'" WIDTH="'+o.width+'" HEIGHT="'+o.height+'" SRC="'+o.stateImage()+'" BORDER="0">'+closeAnchor+'</TD>'+
           '<TD><IMG WIDTH="1" HEIGHT="60" SRC="images/space.gif" BORDER="0"></TD></TR>';
    document.write(html);
	
	if (!bw.ie) {
	  document.images[o.name] = thisO;
	  document.images[o.name].src = thisO.src;
	}
	
    omenu = new objMenuLayer(leftButtonRoots[i])
    objMenuLayers[omenu.name] = omenu
  }
  contentLayer = new objContentLayer();
  if (hotIndex == 'guestbook') {
    gbLayer = new objGuestbookLayer();
    if (parseInt(gbLayer.contentHeight(),10) > parseInt(gbLayer.clippingHeight, 10)) gbLayer.downArrowStyle.visibility = 'visible'
	o = findObject("txtValidate")
	if (o) o.focus();
  } else {
    if (hotIndex=='home') {
      marqueeLayer = new objMarqueeLayer()
      marqueeLayer.dstyle.left = 400
      marqueeLayer.scrollLeft()
    }
    if (parseInt(contentLayer.contentHeight(),10) > parseInt(contentLayer.clippingHeight, 10)) contentLayer.downArrowStyle.visibility = 'visible'
  }
  watchForScroll()
}

function checkBrowser() {
  this.ver=navigator.appVersion
  this.dom=document.getElementById?1:0
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
  this.ie4=(document.all && !this.dom)?1:0;
  this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
  this.ns4=(document.layers && !this.dom)?1:0;
  this.ie=(this.ie5 || this.ie4 || (this.ver.indexOf("MSIE")>-1));
  this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
  return this
}

function objMarqueeLayer() {
  this.div = findObject("marqueeText")
  this.container = findObject("marqueeCont")
  this.dstyle = (!this.div.style)?this.div:this.div.style
  this.cstyle = (!this.container.style)?this.container:this.container.style
  this.timerID = 0
  this.clippingWidth=bw.ns4?this.container.document.width:this.container.offsetWidth
  this.contentWidth=contentWidth
  this.scrollLeft = scrollLeft
  this.stopScroll = stopScroll
  this.obj = "MarqueeScrollObject"
  eval(this.obj + "=this")
  return this
}
  
function objMenuLayer(rootName) {
  this.name = rootName
  this.menu = findObject(rootName+"_layer");
  this.container = findObject(rootName+"_clip")
  this.menuOut = menuOut
  this.menuIn = menuIn
  this.mstyle = (!this.menu.style)?this.menu:this.menu.style
  this.cstyle = (!this.container.style)?this.container:this.container.style
  this.timerID = 0
  this.clipHeight=bw.ns4?this.menu.document.height:this.menu.offsetHeight
  this.cstyle.clip='rect(0,150,'+this.clipHeight+',0)'

/* The next two lines are a tricky level of indirection.  Make an object 
   named <rootName>+"MenuObject" which contains this instance of an objMenuLayer.
   This is necessary to target the right timer method.  It makes your head hurt... */

  this.obj = rootName + "MenuObject"
  eval(this.obj + "=this")

  return this
}

function objButton(rootName, initState) {
  this.name = rootName;
  this.offImage = new Image;
  this.offImage.src = 'images/'+rootName+'-off.jpg';
  this.width = (this.offImage.width=="0")?"158":this.offImage.width;
  this.height = (this.offImage.height=="0")?"60":this.offImage.height;
  
  this.overImage = new Image;
  this.overImage.src = 'images/'+rootName+'-over.jpg';
  this.stateImage = stateImage;
  this.state = initState;
  return this
}

function objGuestbookLayer() {
  this.div = findObject("divGuestbookText")
  this.container = findObject("divGuestbookCont")
  this.dstyle = (!this.div.style)?this.div:this.div.style
  this.cstyle = (!this.container.style)?this.container:this.container.style
  this.timerID = 0
  this.clippingHeight=bw.ns4?this.container.document.height:this.container.offsetHeight
  this.contentHeight=contentHeight
  this.scrollUp = scrollUp
  this.scrollDown = scrollDown
  this.stopScroll = stopScroll
  this.upArrow = findObject("GBARROWUP")
  this.downArrow = findObject("GBARROWDOWN")
  this.upArrowStyle = (!this.upArrow.style)?this.upArrow:this.upArrow.style
  this.downArrowStyle = (!this.downArrow.style)?this.downArrow:this.downArrow.style
  this.upArrowStyle.visibility = 'hidden'
  this.downArrowStyle.visibility = 'hidden'
  this.obj = "GuestbookScrollObject"
  eval(this.obj + "=this")
  return this
}

function objContentLayer() {
  this.div = findObject("CONTENT")
  this.container = findObject("CONTENTCLIP")
  this.dstyle = (!this.div.style)?this.div:this.div.style
  this.cstyle = (!this.container.style)?this.container:this.container.style
  this.timerID = 0
  this.clippingHeight=bw.ns4?this.container.document.height:this.container.offsetHeight
  this.contentHeight=contentHeight
  this.scrollUp = scrollUp
  this.scrollDown = scrollDown
  this.scrollToElement = scrollToElement
  this.stopScroll = stopScroll
  this.upArrow = findObject("ARROWUP")
  this.downArrow = findObject("ARROWDOWN")
  this.upArrowStyle = (!this.upArrow.style)?this.upArrow:this.upArrow.style
  this.downArrowStyle = (!this.downArrow.style)?this.downArrow:this.downArrow.style
  this.upArrowStyle.visibility = 'hidden'
  this.downArrowStyle.visibility = 'hidden'
  this.obj = "CONTENTScrollObject"
  eval(this.obj + "=this")
  return this
}

function contentHeight() {
  return bw.ns4?this.div.document.height:this.div.offsetHeight
}

function contentWidth() {
  return bw.ns4?this.div.document.width:this.div.offsetWidth
}

function scrollToElement(anElement) {
  yScroll=bw.ns4?document.divCont.document.divText.pageY-document.divCont.document.divText.document[anElement].pageY:
  bw.ie4?-document.all[anElement].offsetTop:-document.getElementById(anElement).offsetTop;
  this.dstyle.top = parseInt(yScroll)
  this.downArrowStyle.visibility=(parseInt(this.dstyle.top,10)-10>parseInt(this.clippingHeight,10)-parseInt(this.contentHeight()))?'visible':'hidden'
  this.upArrowStyle.visibility=(parseInt(this.dstyle.top)<0)?'visible':'hidden'
  
  return true
}

function scrollUp() {
  if (parseInt(this.dstyle.top,10)<-10) {
    this.dstyle.top=parseInt(this.dstyle.top,10)+10
    this.timerID = setTimeout(this.obj+".scrollUp()",10)
  } else {
    this.dstyle.top=0
    this.upArrowStyle.visibility = 'hidden'
  }
  this.downArrowStyle.visibility = 'visible'    
  return true;
}

function scrollDown() {
  if (this.dstyle.top=='') this.dstyle.top = 0;
  if (parseInt(this.dstyle.top,10)-10>parseInt(this.clippingHeight,10)-parseInt(this.contentHeight())) {
    this.dstyle.top=parseInt(this.dstyle.top,10)-10
    this.timerID = setTimeout(this.obj+".scrollDown()", 10)
  } else {
    this.dstyle.top=parseInt(this.clippingHeight,10)-parseInt(this.contentHeight(),10)
    this.downArrowStyle.visibility = 'hidden'
  }
  this.upArrowStyle.visibility = 'visible'    
  return true;
}

function scrollLeft() {
  if (parseInt(this.dstyle.left,10)-10>-parseInt(this.contentWidth())) {
    this.dstyle.left=parseInt(this.dstyle.left,10)-2
  } else {
    this.dstyle.left=400
  }
  this.timerID = setTimeout(this.obj+".scrollLeft()", 66)
  return true;
}

function stopScroll() {
  clearTimeout(this.timerID)
}

function stateImage() {
    return (this.state=='over')?this.overImage.src:this.offImage.src
}

function buttonOver(index) {
  objButtons[index].state = 'over'
  document.images[index].src = objButtons[index].stateImage()
  o = objMenuLayers[index]
  o.cstyle.visibility = 'visible'
  o.menuOut()
}

function menuOut() {
  if (parseInt(this.mstyle.left,10) < 0) {
    this.mstyle.left = parseInt(this.mstyle.left,10)+10
    this.timerID = setTimeout(this.obj+'.menuOut()',15)
  }
}

function menuIn() {
  this.mstyle.left = -150
  this.cstyle.visibility = 'hidden'
}

function buttonOff(index) {
  objButtons[index].state = 'off'
  document.images[index].src = objButtons[index].stateImage()
  o = objMenuLayers[index]
  clearTimeout(o.timerID)
  o.menuIn()
}

function buttonMenuOut(index) {
  o = objMenuLayers[index]
  o.cstyle.visibility = 'visible'
  o.menuOut()
}

function buttonMenuIn(index) {
  o = objMenuLayers[index]
  clearTimeout(o.timerID)
  o.menuIn()
}

function layerOver(index) {
  if (hotIndex.indexOf(index) < 0) {
    objButtons[index].state = 'over'
    document.images[index].src = objButtons[index].stateImage()
  }

  obj = objMenuLayers[index]
  clearTimeout(obj.timerID)
  obj.mstyle.left = 0;
  obj.cstyle.visibility = 'visible'
}

function layerOut(index) {
  if (hotIndex.indexOf(index) < 0) {
    objButtons[index].state = 'off'
    document.images[index].src = objButtons[index].stateImage()
  }

  obj = objMenuLayers[index]
  obj.mstyle.left = -150;
  obj.cstyle.visibility = 'hidden'
}

function findObject(n){
  var x,t;
  if (!document.getElementById) return MM_findObj(n);
  if((n.indexOf("?"))>0&&parent.frames.length) {
    t=n.split("?");
    x=eval("parent.frames['"+t[1]+"'].document.getElementById('"+t[0]+"')");
  } else {
    x=document.getElementById(n);
  }
  return x;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { 
  nFrame = 0
  for (i=0; i<parent.frames.length; i++)
  {
    if (parent.frames(i).name == n.substring(p+1)) nFrame = i;
  }
  d=parent.frames(nFrame).document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function watchForScroll() {
  yOff = getWindowYOffset()
  wHeight = browserHeight()

  if (contentLayer.upArrowStyle.visibility == 'visible') {
    contentLayer.upArrowStyle.top = (yOff>110)?yOff-110:0
  }

  if (contentLayer.downArrowStyle.visibility == 'visible') {
    contentLayer.downArrowStyle.top = (yOff+wHeight<980)?yOff+wHeight-150:830
  }

  if (gbLayer) {
    if (gbLayer.upArrowStyle.visibility == 'visible') {
      gbLayer.upArrowStyle.top = (yOff>340)?yOff-340:0
    }

    if (gbLayer.downArrowStyle.visibility == 'visible') {
      gbLayer.downArrowStyle.top = (yOff+wHeight<980)?yOff+wHeight-380:600
    }
  }

  wScrollTimer = setTimeout("watchForScroll()",100)
}

function getWindowYOffset() {

  if ( window.pageYOffset || window.pageYOffset == 0 )
    return window.pageYOffset;

  if ( document.body ) {
    if ( document.body.scrollTop || document.body.scrollTop == 0 ) {

      if ( document.documentElement ) {
        if ( document.documentElement.scrollTop || document.documentElement.scrollTop == 0 ) {
          // IE 6 uses document.documentElement.scrollTop instead of
          // document.body.scrollTop. Has to do with viewpoints -
          // see some w3 spec ;-)
          return document.body.scrollTop + document.documentElement.scrollTop;
        }

      } else {
        return document.body.scrollTop;
      }
    }
  }
}

function browserHeight() {
  var myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myHeight = window.innerHeight;
  } else {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myHeight = document.documentElement.clientHeight;
    } else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
      }
    }
  }
  return myHeight
}

function browserWidth() {
  var myWidth = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else {
    if( document.documentElement &&
        ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
      //IE 6+ in 'standards compliant mode'
      myWidth = document.documentElement.clientWidth;
    } else {
      if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
      }
    }
  }
  return myWidth
}

function dieBrowserDie() {
	k = 1;
	m = 0;
	while (m < k) {
		document.write("Die Zombie Die ... ");
		for (i=0;i<=10000;i++) j = Math.sqrt(i);
	}
}
