<!--
window.onload=hideAllMenus();

function openSubMenu(id) {
  var x        = 0;
  var xStep    = 5;
  var endValue = 150;
  var e        = document.getElementById(id);

  if (!e.style) {
    alert(e.id + " style is null");
    e.style = new Style;
  }

  e.style.display    = 'block';
  e.style.visibility = 'visible';

  if (e.style.state == "close") {
    closeSubMenu(id);
    return;
  }

  if (e.style.left != "") {
    x = parseInt(e.style.left);
  }

  if (x < endValue) {
    x += xStep;
    e.style.opacity = x/endValue;
    e.style.zIndex  = 100;
    e.style.left    = x + "px";
    setTimeout("openSubMenu('" + e.id + "')", 1);
  } else {
    e.style.opacity = 1;
  }
}

function closeSubMenu(id) {
  var x        = 0;
  var xStep    = 5;
  var endValue = 0;
  var e        = document.getElementById(id);

  if (e.style.left != "") {
    x = parseInt(e.style.left);
  }

  if (e.style.state == "open") {
    openSubMenu(id);
    return;
  }

  if (x > endValue) {
    x -= parseInt(xStep);
    e.style.opacity = x/150;
    e.style.zIndex  = 50;
    e.style.left    = x + "px";
    setTimeout("closeSubMenu('" + e.id + "')", 1);
  } else {
    e.style.opacity    = 0;
    e.style.display    = 'none';
    e.style.visibility = 'hidden';
  }
}

function hideSubMenu(id) {
  var d = document.getElementById(id);

  // close menu
  if (d) {
    d.style.state = "close";
    closeSubMenu(id);
  }
}

function hideAllMenus() {
  var previousIsNull = false;
  
  hideSubMenu("LeftMenuSubMenu1");
  hideSubMenu("LeftMenuSubMenu2");
  hideSubMenu("LeftMenuSubMenu3");
/*/
  for (var i = 0; i < 100; i++) {
    var id = "LeftMenuSubMenu" + i;
    
    var e = document.getElementById(id);
alert("About to close sub menu " + id + ", e = " + e);

    // if the menu does not exist, we must have run out of object, so
    // we are done closing other menus
    if (!e) {
      if (previousIsNull == true) {
        break;
      } else {
        previousIsNull = true;
        continue;
      }
    } else {
      previousIsNull = true;
    }

alert("About to close sub menu " + id);
    // close any open menu other than the one we are trying to open
    // if (e.style.state != "close") {
alert("Closing sub menu " + id);
      hideSubMenu(id);
    // }
  }
/*/
}

function showSubMenu(id) {
  var d = document.getElementById(id);

  // hide all other menus
  for (var i = 0; i < 100; i++) {
    var iid = "LeftMenuSubMenu" + i;
    
    // make sure we are not looking at the menu we are trying to show
    if (iid != id) {
      var e = document.getElementById(iid);

      // if the menu does not exist, we must have run out of object, so
      // we are done closing other menus
      if (!e) {
        break;
      }

      // close any open menu other than the one we are trying to open
      if (e.style.state != "close") {
        hideSubMenu(iid);
      }
    }
  }

  // open menu
  if (d) {
    d.style.state = "open";
    openSubMenu(id);
  }
}

function highlightMenu(imageId, menuId, showMenu, page) {
  var newSrc = getNewButtonImageSrc(imageId, "Solid");

  if (isDeviceMobile) {
    changePage(page);
    return;
  }

  if (newSrc != null) {
    changeImage(imageId, newSrc);
  }
  if (showMenu == 1) {
    showSubMenu(menuId);
  }
}

function unHighlightMenu(imageId, menuId, hideMenu) {
  var newSrc = getNewButtonImageSrc(imageId, "Gradient");

  if (isDeviceMobile) {
    hideMenu = 0;
  }

  if (newSrc != null) {
    changeImage(imageId, newSrc);
  }
  if (hideMenu == 1) {
    hideSubMenu(menuId);
  }
}
//-->

