strNavActiveSection = "";
oTimer = null;

strUserAgent = navigator.userAgent.toLowerCase();
isMac = (strUserAgent.indexOf("mac") != -1);
isGaleon = (strUserAgent.indexOf("galeon") != -1);
isIE = ((strUserAgent.indexOf("msie") != -1) && (strUserAgent.indexOf("gecko") == -1) && (strUserAgent.indexOf("opera") == -1) && (strUserAgent.indexOf("netscape") == -1)); 


if (!(isMac && isIE) && !isGaleon) {
  if (window.addEventListener)
    window.addEventListener("load", fncPageLoadAll, false);
  else if (window.attachEvent)
    window.attachEvent("onload", fncPageLoadAll);
  else if (document.getElementById)
    window.onload=fncPageLoadAll;
}
  

function fncPageLoadAll() {
  fncCreateShadowBox('idFooter', 'NavPopup');
}

function fncSetBackgroundColor(oElement, strColor) {
  oElement.style.backgroundColor = strColor;
}
    

//---------------------------------------------------------------------------
// POPUP NAV FUNCTIONS

function fncNavPopupDelayHide() {
  oTimer = setTimeout("fncNavPopupHide()",500);
}
function fncNavPopupCancelHide() {
  clearTimeout(oTimer);
}

function fncNavPopupOver(oItem) {
  oItem.style.color = "#ACF762";
}
function fncNavPopupOut(oItem) {
  oItem.style.color = "#FFFFFF";
}

function fncNavPopupShow(strSection) {
  // first argument is any horizontal offset for popup menu
  // second argument is specified width for popup menu
  if (arguments) {
    intMenuShift = 0;
    intMenuWidth = -1;
    if (arguments.length >= 2) {
      if (typeof(arguments[1]) == "number") {
        intMenuShift = arguments[1];
      }
    }
    if (arguments.length >= 3) {
      if (typeof(arguments[2]) == "number") {
        intMenuWidth = arguments[2];
      }
    }
    
    fncNavPopupHide();
    strNavActiveSection = strSection;
    
    if (typeof(document.getElementById('idNavButton_' + strSection)) != "undefined") {
      oPopupNavButton = document.getElementById('idNavButton_' + strSection);
      oPopupNavButton.style.color = "#ACF762";
    }
    
    if (typeof(document.getElementById('idNavPopup_' + strSection)) != "undefined" && document.getElementById('idNavPopup_' + strSection)) {
      oPopupNavMenu = document.getElementById('idNavPopup_' + strSection);
      oPopupNavMenu.style.display = "block";
      if (intMenuWidth > 0) {
        oPopupNavMenu.style.width = intMenuWidth + "px";
      }
      intLocation = (fncGetAbsoluteX(oPopupNavButton)) + (intMenuShift);
      oPopupNavMenu.style.left = intLocation + "px";
      fncSetNavPopupShadow('idNavPopup_' + strSection);
    }
  }
}

function fncNavPopupHide() {
  if (strNavActiveSection.length > 0) {
    if (typeof(document.getElementById('idNavButton_' + strNavActiveSection)) != "undefined") {
      oPopupNavButton = document.getElementById('idNavButton_' + strNavActiveSection);
      oPopupNavButton.style.color = "#FFFFFF";
    }
    if (typeof(document.getElementById('idShadowNavPopup')) != "undefined" && document.getElementById('idShadowNavPopup')) {
      document.getElementById('idShadowNavPopup').style.display = "none";
    }
    if (typeof(document.getElementById('idNavPopup_' + strNavActiveSection)) != "undefined" && document.getElementById('idNavPopup_' + strNavActiveSection)) {
      oPopupNavMenu = document.getElementById('idNavPopup_' + strNavActiveSection);
      oPopupNavMenu.style.display = "none";
    }
  }
}


//---------------------------------------------------------------------------
// UTILITY FUNCTIONS

function fncGetAbsoluteX(oObjectToGetPosition) {
  // Utility function to get the absolute X-coordinate of an object on the page
  var intCoords = {x: 0};
  while (oObjectToGetPosition) {
    intCoords.x += oObjectToGetPosition.offsetLeft;
    oObjectToGetPosition = oObjectToGetPosition.offsetParent;
  }
  return intCoords.x;
}
function fncGetAbsoluteY(oObjectToGetPosition) {
  // Utility function to get the absolute Y-coordinate of an object on the page
  var intCoords = {y: 0};
  while (oObjectToGetPosition) {
    intCoords.y += oObjectToGetPosition.offsetTop;
    oObjectToGetPosition = oObjectToGetPosition.offsetParent;
  }
  return intCoords.y;
}

function fncGetWidth(oObjectToGetWidth) {
  // Utility function to get the width of an object on the page
	if (oObjectToGetWidth.style.pixelWidth) {
		return oObjectToGetWidth.style.pixelWidth;
	}
  if (oObjectToGetWidth.style.width) {
      return oObjectToGetWidth.style.width;
  } 
  return oObjectToGetWidth.offsetWidth;
}

function fncGetHeight(oObjectToGetHeight) {
  // Utility function to get the height of an object on the page
	if (oObjectToGetHeight.style.pixelHeight) {
		return oObjectToGetHeight.style.pixelHeight;
	}
  if (oObjectToGetHeight.style.height) {
      return oObjectToGetHeight.style.height;
  }
  return oObjectToGetHeight.offsetHeight;
}


//---------------------------------------------------------------------------
// PROTOTYPE FUNCTIONS

/* Non-IE browsers do not have the insertAdjacentElement function so we create it here */
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement){	HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode)
	{
		switch (where){
		case 'beforeBegin':
			this.parentNode.insertBefore(parsedNode,this)
			break;
		case 'afterBegin':
			this.insertBefore(parsedNode,this.firstChild);
			break;
		case 'beforeEnd':
			this.appendChild(parsedNode);
			break;
		case 'afterEnd':
			if (this.nextSibling) this.parentNode.insertBefore(parsedNode,this.nextSibling);
			else this.parentNode.appendChild(parsedNode);
			break;
		}
	}

	HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
	{
		var r = this.ownerDocument.createRange();
		r.setStartBefore(this);
		var parsedHTML = r.createContextualFragment(htmlStr);
		this.insertAdjacentElement(where,parsedHTML)
	}


	HTMLElement.prototype.insertAdjacentText = function(where,txtStr)
	{
		var parsedText = document.createTextNode(txtStr)
		this.insertAdjacentElement(where,parsedText)
	}
}
