/**
 * Functions for an expandable menu based on CSS and unordered lists.
 * Supported browsers are DOM 1.0 browsers (those implementing 
 * 'document.getElementById') and those implementing 'document.all[]'.
 *
 * $Id: menu.js 5268 2004-01-21 09:21:40Z torebu $
 * $Name$
 */

/**
 * A getElementByID implementation for IE 4
 */
function IE4GetElementById(id) {
   return document.all[id];
}
// Set IE4 to use compability function.
if (document.all && !document.getElementById) {
   document.getElementById = IE4GetElementById;
}

/**
 * Toggle the visibility of a menu category by setting 
 * the 'display' property.
 *
 * @param ID The ID of the element to toggle.
 */
function toggleCat(ID) {
    var elem = document.getElementById(ID);
    var display = elem.style.display;

    // Check for 'block' instead of 'none', as elements that are hidden
    // when the page first is displayed will have a blank 'display' value.
    if (display == "block") {
        elem.style.display = "none";
    }
    else {
        elem.style.display = "block";
    }
}


/**
 * Write some CSS to hide all categories if JavaScript is enabled and
 * the current browser is supported. 
 */
function writeHideCategories() {
    if (document.getElementById) {
        document.write("<style type=\"text/css\">ul.top-menu ul {display: none; }</style>");
    }
}


/**
 * Expand the menu to show the active document.
 *
 * @param id ID attribute for the active document.
 */
function showActive(ID) {
    var elem = document.getElementById(ID);
    var parent = elem.parentNode;

    // NodeType 1 is element
    while (parent != null && parent.nodeType == 1 && parent.className != "top-menu") {
        parent.style.display = "block";
        parent = parent.parentNode;
    }
}

