// Updated 6/26/2003

function ie4() {return (document.all) ? true : false}
function ns4() {return (document.layers) ? true : false }
function ns6() {return (document.getElementById && !document.all) ? true : false}
function ms() {return (document.all) ? true : false}
function mac() {return (navigator.appVersion.indexOf("Mac") != -1)}
function stdDOM() {return (document.getElementById) ? true : false}

ImagePath = "images/"
Layers = new Array()

function showProps(vObj) {
  var s = ""
  for (var i in vObj) s += (i+" = "+vObj[i]).substring(0,49)+"  |  "
  alert(s)
}

// -- Layers

function showLayer() {
  if (stdDOM() || ie4()) this.style.visibility = "visible"
  else this.visibility = "show"
}

function hideLayer() {
  if (stdDOM() || ie4()) this.style.visibility = "hidden"
  else this.visibility = "hide"
}

function layerObj0(vName) {
  if (vName.indexOf("Layer") == -1) vName += "Layer"
  if (ms()) {
    var vLayer = document.all[vName]
	vLayer.expr = "document.all."+vName
	vLayer.x = vLayer.offsetLeft
	vLayer.y = vLayer.offsetTop
    vLayer.z = vLayer.style.zIndex
	vLayer.w = vLayer.offsetWidth
	vLayer.h = vLayer.offsetHeight
    vLayer.moveTo = moveLayerTo
    vLayer.moveBy = moveLayerBy
  }
  else {
    if (ns4()) {
      var vLayer = document.layers[vName]
      vLayer.expr = "document."+vName
  	  vLayer.w = vLayer.clip.width
	  vLayer.h = vLayer.clip.height
	}
	else {
	  var vLayer = document.getElementById(vName)
      vLayer.expr = "document.getElementById('"+vName+"')"
	  vLayer.x = vLayer.offsetLeft
	  vLayer.y = vLayer.offsetTop
  	  vLayer.w = vLayer.clip.width
	  vLayer.h = vLayer.clip.height
      vLayer.moveTo = moveLayerTo
      vLayer.moveBy = moveLayerBy
	}
  }
  vLayer.show = showLayer
  vLayer.hide = hideLayer
  vLayer.restack = restackLayer
  vLayer.center = centerLayer
  vLayer.centerHoriz = centerLayerHoriz
  vLayer.moveToWinPos = moveLayerToWinPos
  return vLayer
}	

function layerObj1(vName) {
  if (vName.indexOf("Layer") == -1) vName += "Layer"
  if (ms()) {
    var vLayer = document.all[vName]
	vLayer.expr = "document.all."+vName
	vLayer.x = vLayer.offsetLeft
	vLayer.y = vLayer.offsetTop
    vLayer.z = vLayer.style.zIndex
	vLayer.w = vLayer.offsetWidth
	vLayer.h = vLayer.offsetHeight
  }
  else {
    if (ns4()) {
      var vLayer = document.AllLayer.document.layers[vName]
      vLayer.expr = "document.AllLayer.document."+vName
  	  vLayer.w = vLayer.clip.width
	  vLayer.h = vLayer.clip.height
	}
	else {
      var vLayer = document.getElementById(vName)
	  var vAll = document.getElementById("AllLayer")
      vLayer.expr = "document.getElementById('"+vName+"')"
	  vLayer.x = vLayer.offsetLeft
	  vLayer.y = vLayer.offsetTop
  	  vLayer.w = vLayer.scrollWidth
	  vLayer.h = vLayer.scrollHeight
	}
  }
  vLayer.moveTo = moveLayerTo
  vLayer.moveBy = moveLayerBy
  vLayer.show = showLayer
  vLayer.hide = hideLayer
  vLayer.restack = restackLayer
  vLayer.center = centerLayer
  vLayer.centerHoriz = centerLayerHoriz
  vLayer.moveToWinPos = moveLayerToWinPos
  vLayer.centerToPoint = centerToPoint
  return vLayer
}	

layerObj = layerObj0

function allLayer(vName) {
  if (ms()) {
    var vObj = document.all[vName]
	vObj.expr = "document.all."+vName
    vObj.x = vObj.offsetLeft
    vObj.y = vObj.offsetTop
    vObj.z = vObj.style.zIndex
	vObj.w = vObj.offsetWidth
	vObj.h = (mac()) ? vObj.offsetHeight : vObj.scrollHeight
  }
  else {
    if (ns4()) {
      var vObj = document.layers[vName]
      vObj.expr = "document."+vName
	}
	else {
      var vObj = document.getElementById(vName)
      vObj.expr = "document.getElementById('"+vName+"')"
	  vObj.x = vObj.offsetLeft
	  vObj.y = vObj.offsetTop
  	  vObj.w = vObj.offsetWidth
	  vObj.h = vObj.offsetHeight
    }	  
  }
  vObj.moveTo = moveLayerTo
  vObj.moveBy = moveLayerBy
  vObj.show = showLayer
  vObj.hide = hideLayer
  vObj.restack = restackLayer
  return vObj
}

function centerAllLayer(vX,vY) {
  dAll.moveTo(Math.max(0,Math.round((screenWidth()-vX)/2)),Math.max(0,Math.round((screenHeight()-vY)/2)))
}

function centerAllHoriz(vY) {
  var vAdj = (stdDOM() || ie4()) ? 0 : 6
  dAll.moveTo(Math.max(40-vAdj,Math.round((screenWidth()-dAll.w)/2))+vAdj,vY)
}

function centerLayer() {
  var vX = Math.round((screenWidth()-this.w)/2)
  var vY = Math.round((screenHeight()-this.h)/2)
  this.moveToWinPos(vX,vY)
}

function centerLayerHoriz() {
  var vScreenX = (stdDOM() || ie4()) ? document.body.offsetLeft : window.pageXOffset
  var vX = Math.round((screenWidth()-this.w)/2)
  this.moveTo(vX+vScreenX,this.y)
}

function centerToPoint(vX,vY) {
  this.moveTo(vX-Math.round(this.w/2),vY-Math.round(this.h/2))
}

function screenWidth() {
return (stdDOM() || ie4()) ? document.body.clientWidth : window.innerWidth-16
}

function screenHeight() {
  if (stdDOM() || ie4()) return document.body.clientHeight
  else return window.innerHeight
}

function restackLayer(vZ) {
  if (stdDOM() || ie4()) this.style.zIndex = vZ
  else this.zIndex = vZ
  this.z = vZ
}

// --- Moving Layers

function moveLayerTo(vX,vY) {
  if (stdDOM() || ie4()) {
    this.style.left = vX
	this.style.top = vY
    this.x = vX
    this.y = vY
  }
  else this.moveTo(vX,vY)
}

function moveLayerBy(vX,vY) {
  if (stdDOM() || ie4()) {
    this.style.left = this.x+vX
    this.style.top = this.y+vY
    this.x += vX
    this.y += vY
  }
  else this.moveBy(vX,vY)
}

function moveLayerToWinPos(vX,vY) {
  if (stdDOM() || ie4()) {
    var vScreenX = document.body.scrollLeft
	var vScreenY = document.body.scrollTop
  }
  else {
    var vScreenX = window.pageXOffset
	var vScreenY = window.pageYOffset
  }
  this.moveTo(vScreenX+vX-dAll.x,vScreenY+vY-dAll.y)
}


function writeLayer(vLayer,vText) {
  if (stdDOM() || ie4()) {
    vLayer.innerHTML = vText
	vLayer.w = vLayer.scrollWidth
	vLayer.h = vLayer.scrollHeight
  }	
  else {
    vLayer.document.open()
	vLayer.document.write(vText)
	vLayer.document.close()
//	vLayer.w = vLayer.clip.width
//	vLayer.h = vLayer.clip.height
  }
}  

// -- Images

function cacheImage(vLayer,vLoc,vSrc,vTrig) {
  var vImage = new Image()
  vImage.layer = (typeof(vLayer) == "string") ? layerObj(vLayer) : vLayer
  vImage.loc = vLoc
  if (vTrig != null) vTrig.bindTo(vImage)
  vImage.src = ImagePath+vSrc
  vImage.show = showImage
  vImage.pop = popObj
  return vImage
}

function showImage() {imageObj(this.layer,this.loc).src = this.src}

function popObj() {this.show(); this.layer.show()}
  
function imageObj(vLayer,vLoc) {
  var vImage = (stdDOM() || ie4() || (vLayer == null)) ? document.images[vLoc] : vLayer.document.images[vLoc]
  vImage.layer = vLayer
  return vImage
}

function swapImage(vLayer,vLoc,vSrc) {
  var vObj = imageObj(vLayer,vLoc)
  vObj.src = vSrc
}

// -- Rollovers

function Rollover(vName,vLayer,vLoc,vActive,vTrig) {
  this.off = cacheImage(vLayer,vLoc,vName+".gif",vTrig)
  this.over = cacheImage(vLayer,vLoc,vName+"_over.gif",vTrig)
  if (vActive) this.active = cacheImage(vLayer,vLoc,vName+"_active.gif",vTrig)
  this.on = false
  this.layer = vLayer
  this.loc = vLoc
  this.show = showRollover
  this.roll = roll
  this.pop = popObj
}

function roll() {
  with (this) {
    if (!on) {
  	  switch ((ms()) ? event.type : roll.caller.arguments[0].type) {
	    case "mouseover" : vState = over; break
	    case "mouseout"  : if (!on) vState = off; break
	    case "click"     : vState = active; on = true
 	  }
      swapImage(layer,loc,vState.src)
	}
  }
}

function showRollover() {
  with (this) {
    var vObj = imageObj(layer,loc)
    var vActiveState = (typeof(active) == "undefined") ? over : active
    vObj.src = (on) ? vActiveState.src : off.src
  }
}

// -- Toggles

function Toggle(vArray,vLayer,vLoc,vActive,vTrig) {
  var t = new Array()
  for (var i in vArray) {
    var vObj = new Rollover(vArray[i],vLayer,vLoc+i,vActive,vTrig)
    t[i] = vObj
  }	
  t.layer = t[0].layer
  t.state = -1
  t.show = showToggle
  t.pop = popObj
  t.click = toggleClick
  return t
}

function toggleClick(vIndex) {
  if (vIndex != this.state) {
    if (this.state >= 0) {
	  this[this.state].on = false
      this[this.state].show()
	}
    if (vIndex >= 0) {
      this[vIndex].on = true
      this[vIndex].show()
	}
    this.state = vIndex
	return true
  }
  else return false
}

function showToggle() {for (var i = 0; i < this.length; i++) this[i].show()}

// -- other

function rand(vNum) {return Math.round(vNum*Math.random())}

function doNothing() {}

// -- Triggers

function Trigger(vFunc) {
  this.func = vFunc
  this.bindTo = bindTo
  this.loaded = 0
  this.total = 0
  this.ready = false
  this.set = setTrigger
  this.reset = resetTrigger
  this.disable = disableTrigger
}

function setTrigger() {
  this.ready = true
  if (this.loaded == this.total) {
    this.func()
    this.reset()
  }
}

function checkTrigger() {
  this.onload = null
  if (++this.trigger.loaded >= this.trigger.total && this.trigger.ready) {
    this.trigger.func()
    this.trigger.reset()
  }
 if (typeof(this.trigger.onloadrtn) == "function") this.trigger.onloadrtn()
}

function bindTo(vObj) {
  vObj.trigger = this
  this.total++
  if (typeof(this.bindrtn) == "function") this.bindrtn()
  vObj.onload = checkTrigger
}

function resetTrigger() {
  this.loaded = 0
  this.total = 0
  this.ready = false
}

function disableTrigger() {
  if (typeof(this) == "object") this.ready = false
}

function fileParam() {
  var vParam = window.location.search
  vParam = vParam.substring(1,vParam.length)
  return vParam
}

function cssLayer(vName,vLeft,vTop,vWidth) {
  var vLayerName = vName+"Layer"
  var vStr = "#"+vLayerName+" {position:absolute; left:"+vLeft+"px; top:"+vTop+"px; width:"+vWidth+"px; visibility:hidden; z-index:"+Layers.length+"}"
  Layers[Layers.length] = vLayerName
  return document.write(vStr)
}

function htmlImage(vName,vWidth,vHeight) {
  var vStr = "<img name='"+vName+"' width="+vWidth+" height="+vHeight+" border=0 hspace=0 vspace=0>"
  return vStr
}

function htmlLink(vHref,vOver,vOut,vClick,vInner) {
  var vStr = "<a href=\""+vHref+"\""
  if (vOver != null) vStr += " onmouseover=\""+vOver+"\""
  if (vOut != null) vStr += " onmouseout=\""+vOut+"\""
  if (vClick != null) vStr += " onclick=\""+vClick+"\""
  vStr += ">"+vInner+"</a>"
  return vStr
}

function imageX(vObj) {
  var vX = 0
  if (stdDOM() || ie4()) {
    do {
  	  vX += vObj.offsetLeft
      vObj = vObj.offsetParent
    }
	while (vObj != null)
  }
  else vX = vObj.layer.x + vObj.x
  return vX
}

function imageY(vObj) {
  var vY = 0
  if (stdDOM() || ie4()) {
    do {
  	  vY += vObj.offsetTop
      vObj = vObj.offsetParent
    }
	while (vObj != null)
  }
  else vY = vObj.layer.y + vObj.y
  return vY
}

function shim(vWidth,vHeight) {
  return "<img src='images/shim.gif' width="+vWidth+" height="+vHeight+" border=0 hspace=0 vspace=0>"
}

function cookieParam(vParamName) {
  var vParam = null
  var vCookie = new String(document.cookie)
  var vHeader = vParamName+"="
  var vBegin = vCookie.indexOf(vHeader)
  if (vBegin != -1) {
    vCookie = vCookie.substring(vBegin + vHeader.length)
    var vEnd = vCookie.indexOf(";")
    vParam = (vEnd == -1) ? vCookie : vCookie.substring(0,vEnd)
  }
  return vParam
}

function saveCookie(vParamName,vValue) {
  var vDate = new Date()
  vDate.setTime(vDate.getTime() + 60*60*24*365*1000)
  document.cookie = vParamName+"="+vValue+"; expires="+vDate.toGMTString()
}

function bgColor(vColor) {
  var vObj = (stdDOM() || ie4()) ? document.body : document
  vObj.bgColor = vColor
}

function getScript(vName) {
  return document.write("<"+"script language='javascript1.2' src='"+vName+".js'></"+"script>")
}