var _isIE, _isNS, _isDOM;

_isIE = (navigator.appName == "Microsoft Internet Explorer");
_isNS = (navigator.appName == "Mozilla" || navigator.appName == "Netscape");
_isDOM = _isNS && (navigator.appVersion.indexOf("4.") == -1);

var allObjs = new Array();


function dom_object(obj) {
	this.docObj = obj;
	this.name = obj.id;
	this.hide = domHide;
	this.show = domShow;
	this.getHeight = domGetHeight;
	this.setTop = domSetTop;
	this.setLeft = domSetLeft;
	this.setInnerHTML = domSetInnerHTML;
	this.unDisplay = domUnDisplay;
}


function ie_object(obj) {
	this.docObj = obj;
	this.name = obj.id;
	this.hide = domHide;
	this.show = domShow;
	this.getHeight = ieGetHeight;
	this.setTop = domSetTop;
	this.setLeft = domSetLeft;
	this.setInnerHTML = domSetInnerHTML;
	this.unDisplay = domUnDisplay;
}

function ns_object(obj) {
	this.docObj = obj;
	this.name = obj.name;
	this.hide = nsHide;
	this.show = nsShow;
	this.setInnerHTML = nsSetInnerHTML;
	this.getHeight = nsGetHeight;
	this.setTop = nsSetTop;
	this.setLeft = nsSetLeft;
	this.unDisplay = nsHide;
}

function ie_image(obj) {
	this.imgObj = obj;
	this.getTop = ieGetImgTop;
	this.getLeft = ieGetImgLeft;
}

function ns_image(obj) {
	this.imgObj = obj;
	this.getTop = nsGetImgTop;
	this.getLeft = nsGetImgLeft;
}

function ieGetImgTop() { return parseInt(this.imgObj.offsetTop); }
function ieGetImgLeft() { return parseInt(this.imgObj.offsetLeft); }
function ieGetHeight() { return parseInt(this.docObj.clientHeight); }
function domHide() { this.docObj.style.visibility = "hidden"; }
function domShow() { this.docObj.style.visibility = "visible"; }
function domSetInnerHTML(s) { this.docObj.innerHTML = s; }
function domGetHeight() { return parseInt(document.defaultView.getComputedStyle(this.docObj, "").getPropertyValue("height")); }
//function domSetHeight(y) { this.docObj.style.height = y + "px"; }
//function domSetWidth(y) { this.docObj.style.width = x + "px"; }
function domUnDisplay() { this.docObj.style.display = 'none'; }
function domSetLeft(x) { this.docObj.style.left = x + "px"; }
function domSetTop (y) { this.docObj.style.top = y + "px"; }

function nsGetImgTop() { return parseInt(this.imgObj.y); }
function nsGetImgLeft() { return parseInt(this.imgObj.x); }
function nsHide() { this.docObj.visibility = "hidden"; }
function nsShow() { this.docObj.visibility = "inherit"; }
function nsGetHeight() { return this.docObj.document.height; }
function nsSetHeight(y) { this.docObj.clip.height = y; }
function nsSetWidth(x) { this.docObj.clip.width = x; }
function nsSetTop(y) { this.docObj.top = y; }
function nsSetLeft(x) { this.docObj.left = x; }
function nsUnDisplay() { this.docObj.clip.left = 0; this.docObj.clip.right = 0; this.docObj.clip.bottom = 0; this.docObj.clip.top = 0; }

function nsSetInnerHTML(s) {
	this.docObj.document.clear();
	this.docObj.document.write(s);
	this.docObj.document.close();
}

function findNSLayer(objName) {
   for (i = 0; i < document.layers.length; i++) {
     if (document.layers[i].name == objName) return document.layers[i];
   }
}

// Note: images not in the same DIV/doc are not
// currently supported under Netscape
function getImgObj(objName) {
  if (allObjs[objName]) return allObjs[objName];
  var theObj = null;
  if (_isIE || _isDOM) {
    if (!document.images[objName]) {
      alert("IE cannot find image " + objName);
      return null;
    }
    theObj = new ie_image(document.images[objName]);
  } else if (_isNS) {
    if (!document.images[objName]) {
      alert("NS cannot find image " + objName);
      // If required, add sub-doc search here
    }
    theObj = new ns_image(document.images[objName]);
  }
  allObjs[objName] = theObj;
  return theObj;
}

function getDocObj(objName) {
  if (allObjs[objName]) return allObjs[objName];
  var theObj = null;
  if (_isIE) {
    if (!document.all[objName]) {
      return null;
    }
    theObj = new ie_object(document.all[objName]);
  } else if (_isDOM) {
    if (!document.getElementById(objName)) {
      return null;
    }
    theObj = new dom_object(document.getElementById(objName));
  } else if (_isNS) {
    var nsLayer = document.layers[objName];
    if (!nsLayer) {
      nsLayer = findNSLayer(objName);
      if (!nsLayer) {
        return null;
      }
    }
    theObj = new ns_object(nsLayer);
  }
  allObjs[objName] = theObj;
  return theObj;
}

function placeAndShow(o,e,xPos,yOffset) {
 if ( (ns4) || (ie4) || (ns6) ) {
  var y;
  if ((ns4)||(ns6)) {y=e.pageY;}
  if (ie4) {y=event.y;}
  if (ie5) {y=event.y+self.document.body.scrollTop;}
  y = y + yOffset;
  o.setLeft(xPos);
  o.setTop(y);
  o.show();
 }
}

function scrollRestore(value) {
  window.scrollTo(0,value);
}

function disablePage(transition, idName) {
   if(null==transition || 'ToDisable'==transition) waitscreen(idName);
}

function waitscreen(idName) {
   getDocObj(idName).show();
   // scroll back to top of page so user can see the wait screen
   scrollRestore(0);
   document.body.style.overflow='hidden';
}

// Reload if this browser is netscape.
function _Reload(){ 
//   document.location.reload();
}

if(document.layers || (document.getElementById && !document.all))
   {onresize = _Reload();}

