/* ***********************************************************
Example 4-5 (DHTMLapi.js)
"Dynamic HTML:The Definitive Reference"
by Danny Goodman
Published by O'Reilly & Associates  ISBN 1-56592-494-0
http://www.oreilly.com
Copyright 1998 Danny Goodman.  All Rights Reserved.
************************************************************ */
// DHTMLapi.js custom API for cross-platform
// object positioning by Danny Goodman (http://www.dannyg.com)

// Global variables
var isNav4, isIE, isDom
var coll = ""
var styleObj = ""

if (parseInt(navigator.appVersion) >= 4  ) {
   if (navigator.appName == "Netscape") {
      if (parseInt(navigator.appVersion) < 5) {
         isNav4 = true
         coll = "document."
      }
      else {
         document.all = document.getElementsByTagName("*")
         isDom = true
         isIE = true
         coll = "document.all."
         styleObj = ".style"
      }
   }
   else {
      isIE = true
      coll = "document.all."
      styleObj = ".style"
   }
}



// Convert object name string or object reference
// into a valid object reference
function getObject(obj) {
   var theObj
   if (typeof obj == "string") {
      theObj = eval(coll + obj + styleObj)
   } else {
      theObj = obj
   }
   return theObj
}

// Shift IE text down 3 pixels to account for NS padding
function shiftDown() {
   document.all.topnav1.style.paddingTop = "3px"
   document.all.topnav2.style.paddingTop = "3px"
   document.all.topnav3.style.paddingTop = "3px"
   document.all.topnav4.style.paddingTop = "3px"
   document.all.topnav5.style.paddingTop = "3px"
   document.all.topnav6.style.paddingTop = "3px"

}

function launchCenter(url, name, height, width) {
  var str = "status=yes,directories=no,toolbar=no,location=no,menubar=yes,resizable=yes,"
  str += "height=" + height + ",innerHeight=" + height;
  str += ",width=" + width + ",innerWidth=" + width;
  if (window.screen) {
    var ah = screen.availHeight - 30;
    var aw = screen.availWidth - 10;

    var xc = (aw - width) / 2;
    var yc = (ah - height) / 2;

    str += ",left=" + xc + ",screenX=" + xc;
    str += ",top=" + yc + ",screenY=" + yc;
  }
  return window.open(url, name, str);
}

function loadMain(thewindow) {
   var theheight, thewidth
   if (isNav4) {
      theheight = innerHeight + 70
      thewidth = innerWidth + 10
   }
   else  {
      if (isDom) {
         theheight = innerHeight + 70
         thewidth = innerWidth + 10
      }
      else {
         theheight = thewindow.document.body.clientHeight + 20
         thewidth = thewindow.document.body.clientWidth + 10
      }
   }
   var adminwin = launchCenter("console_template.htm","WAS_Admin_Console", theheight, thewidth)
   //adminwin.focus()
}

function openHelp() {
  var str = "status=yes,directories=no,toolbar=no,location=no,menubar=yes,resizable=yes,width=600,height=400"
  var helpwin = window.open("help.html", "Help", str)
}

function openWin(docname,wd,ht) {
  var str = "scrollbars=no,status=no, directories=no,toolbar=no,location=no,menubar=no,resizable=yes,"
  str += "height=" + ht + ",width=" + wd
  var thewin = window.open(docname, "Secondary",str)
}

// Positioning an object at a specific pixel coordinate
function shiftTo(obj, x, y) {
   var theObj = getObject(obj)
   if (isNav4) {
      theObj.moveTo(x,y)
   } else {
      theObj.pixelLeft = x
      theObj.pixelTop = y
   }
}

// Moving an object by x and/or y pixels
function shiftBy(obj, deltaX, deltaY) {
   var theObj = getObject(obj)
   if (isNav4) {
      theObj.moveBy(deltaX, deltaY)
   } else {
      theObj.pixelLeft += deltaX
      theObj.pixelTop += deltaY
   }
}

// Setting the z-order of an object
function setZIndex(obj, zOrder) {
   var theObj = getObject(obj)
   theObj.zIndex = zOrder
}

// Setting the background color of an object
function setBGColor(obj, color) {
   var theObj = getObject(obj)
   if (isNav4) {
      theObj.bgColor = color
   } else {
      theObj.backgroundColor = color
   }
}

// Setting the visibility of an object to visible
function show(obj) {
   var theObj = getObject(obj)
   theObj.visibility = "visible"
}

// Setting the visibility of an object to hidden
function hide(obj) {
   var theObj = getObject(obj)
   theObj.visibility = "hidden"
}

// Retrieving the x coordinate of a positionable object
function getObjectLeft(obj)  {
   var theObj = getObject(obj)
   if (isNav4) {
      return theObj.left
   } else {
      return theObj.pixelLeft
   }
}

// Retrieving the y coordinate of a positionable object
function getObjectTop(obj)  {
   var theObj = getObject(obj)
   if (isNav4) {
      return theObj.top
   } else {
      return theObj.pixelTop
   }
}


function NSResize() {
   location.reload()
   top.header.location.reload()
   top.detail.location.reload()
   return false
}

if (isNav4) {
   window.captureEvents(Event.RESIZE)
   window.onresize = NSResize
}

