
// DESCRIPTION: Horizontal Menu
// Global variables and initialization of variables
var horizNavTimer;
var selectedNavItem;

function findHorizNavItem(){
  navRoot=document.getElementById("horizNav");
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.className=="selected") selectedNavItem=node.offsetLeft;
  }
}

function restoreHorizNavItem(){
  navRoot = document.getElementById("horizNav");
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.offsetLeft==selectedNavItem) node.className="selected";
  }
}

function clearHorizNav(){
  navRoot = document.getElementById("horizNav");
  for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.nodeName=="LI") {
      node.className="not-selected";
    }
  }
}

// Only function after page has loaded
window.onload = function(){
  if ((document.getElementById) && (document.getElementById("horizNav"))) {
    navRoot = document.getElementById("horizNav");
    findHorizNavItem();
    for (i=0; i<navRoot.childNodes.length; i++) {
      node = navRoot.childNodes[i];
      if (node.nodeName=="LI") {
        node.onmouseover=function() {
          clearHorizNav();
          this.className="over";
          clearTimeout(horizNavTimer);
        }
        node.onmouseout=function() {
          horizNavTimer = setTimeout("clearHorizNav();restoreHorizNavItem();",500);
        }
      }
    }
  }
}