astrNavSections = new Array;
strOpenSectionID = "";
tmrMenuOff = null;
window.onclick = fncHideAllNav();

strUserAgent = navigator.userAgent.toLowerCase();
isMacOS9 = false;
isIE = false;
isMacOSX = false;
isKonqueror = false;
isOpera = false;
isMac = (strUserAgent.indexOf("mac")!=-1);
isSafari = (strUserAgent.indexOf("safari")!=-1);
isOpera = (strUserAgent.indexOf("opera")!=-1);
isKonqueror = (strUserAgent.indexOf("konqueror")!=-1);
if (isMac) {isMacOSX = (strUserAgent.indexOf("5.2")!=-1);}
if (isMac && !isMacOSX) { isMacOS9 = true; }
isIE = ((strUserAgent.indexOf("msie") != -1) && (strUserAgent.indexOf("gecko") == -1) && (strUserAgent.indexOf("opera") == -1) && (strUserAgent.indexOf("netscape") == -1));


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 fncShowSubNav(oSection,strSectionID,intMenuShiftX) {
  if (isKonqueror || isOpera || (isMacOS9 && isIE)) {
    fncBuildSimpleNav(strSectionID);
  }
  else {
    fncHideSubNav(strOpenSectionID);
    if (document.getElementById(strSectionID) != null) {
      // subnav exists
      var oSubNav = document.getElementById(strSectionID);
      
      var intSectionX = fncGetAbsoluteX(oSection);
      var intSectionY = fncGetAbsoluteY(oSection);
      intSectionY = intSectionY + 20;
      
      if (intMenuShiftX.length < 0) {
        intSectionX = intSectionX - 30;
      }
      else {
        intSectionX = intSectionX + intMenuShiftX
      }
      
      if (isMac && isIE) {
        intSectionY = intSectionY - 20;
        intSectionX = intSectionX - 60;
      }
      else if (isSafari) {
        intSectionY = intSectionY - 8;
      }
      oSubNav.style.top = intSectionY + "px";
      oSubNav.style.left = intSectionX + "px";
      
      oSubNav.style.display = "block";   
      strOpenSectionID = strSectionID;      
    }
  }
}     

function fncHideSubNav(strSectionID) {
  if (document.getElementById(strSectionID) != null) {
    fncCancelTimer();
    document.getElementById(strSectionID).style.display = "none";
  }
}

function fncDelayedHideSubNav(strSectionID) {
  if (document.getElementById(strSectionID) != null) {
    // subnav exists
    tmrMenuOff = setTimeout("document.getElementById('"+strSectionID+"').style.display='none';", 200);
    
  }
}

function fncHideAllNav() {
  if (astrNavSections.length > 0) {
    for(var i=0;i<=astrNavSections.length;i++) {
      if (typeof(astrNavSections[i][0]) != "undefined") {
        if (document.getElementById('idSection'+astrNavSections[i][0]) != null) {
          if (document.getElementById('idSection'+astrNavSections[i][0]).style.display != "none") {
            fncCancelTimer();
            fncHideSubNav('idSection'+astrNavSections[i][0]);
          }
        }
      }
    }
  }
}

function fncCancelTimer() {
  clearTimeout(tmrMenuOff);
}


function fncMouseOverSubNavItem(oSubNavItem) {
  oSubNavItem.className = "clsSubNavItemHover";
}

function fncMouseOutSubNavItem(oSubNavItem) {
  oSubNavItem.className = "clsSubNavItem";
}

function fncBuildSimpleNav(strSectionID) {
  var strLinkList = " ";
  if (astrNavSections[strSectionID][1] != null) {
    var astrLabels = astrNavSections[strSectionID][1].split("^");
    var astrLinks = astrNavSections[strSectionID][2].split("^");
    for (var i=0;i<=astrLabels.length-1;i++) {
      if (i >= 3 && (i % 3 == 0)) {
        strLinkList = strLinkList + "<br>";
      }
      else if (i > 0) {
        strLinkList = strLinkList + "&nbsp;&nbsp;|&nbsp;&nbsp;";
      }
      strLinkList = strLinkList + "<a href='" + astrLinks[i] + "'>" + astrLabels[i] + "</a>";
    }
  }
  document.getElementById("idSubNavSimpleLinks").innerHTML = strLinkList;
  
  if (strLinkList.length < 3) {
    document.getElementById("idSubNavSimpleLinks").style.visibility = "hidden";
  }
  else {
    document.getElementById("idSubNavSimpleLinks").style.visibility = "visible";
  }
}


if (!Array.prototype.push) {
  Array.prototype.push = function () {
    for (var i = 0; i < arguments.length; i++) {
        this[this.length] = arguments[i];
    }
   return this.length;
  };
}