/*
 * menuExpandable2.js - implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (dave@gazingus.org)
 */

if (!document.getElementById)
    document.getElementById = function() { return null; }

// the next to last line of this function s/b setting menu.display to block if it is none and to none
// if it is block. Isn't wholly working...
function initializeMenu(menuId, actuatorId,imgId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    if (window.opera) return; // I'm too tired

    actuator.onclick = function() {

        var currentDisplay = menu.style.display;
        var currentAlt = document.getElementById(imgId).alt;
        var image = document.getElementById(imgId);
        var imSource = image.src;
        var imAlt = image.alt;
// if currentDisplay is not equal to block AND is not equal to none, then set to block
// (comes back blank the first time through despite that fact that it is assigned 
// a value of block in the stylesheet)
       if (menu.className == "menuopen" && currentDisplay != "block" && currentDisplay != "none" )
       {currentDisplay = "block";}
     
       if (menu.className == "submenuopen" && currentDisplay != "block" && currentDisplay != "none")
       {currentDisplay = "block";}

        document.images[imgId].src = (currentDisplay == "block") ? "images/plus.gif" : "images/minus.gif";     
        document.getElementById(imgId).alt = (currentAlt == "collapse menu") ? "expand menu" : "collapse menu";
        menu.style.display = (currentDisplay == "block") ? "none" : "block";

        //debug line -- opens alert window to display selected values
       //  alert ('class:' + menu.className + 'display:' + currentDisplay + ' ' + 'image:' + imSource + ' ' + 'currentAlt:' + currentAlt );
        
        return false;

    }

}
//function getLeaf(url) { return url.substring(url.lastIndexOf("/")+1); } function highlightCurrentMenuItem() { var currentLocation = getLeaf(document.location.href); var menu = document.getElementById("menuID"); links = menu.getElementsByTagName("a"); for (i=0; i<links.length; i++) { var currentHref = links[i].getAttribute("href"); var currentLeafName = getLeaf(currentHref); if (currentLeafName==currentLocation) { // Setting class is needed for Mozilla compatibility - className appears to be correct // according to the DOM spec links[i].setAttribute("class", "current"); links[i].setAttribute("className", "current"); // More obvious to use parentNode.parentNode.firstChild, but this // may give a whitespace text node. var menuHeader = links[i].parentNode.parentNode.getElementsByTagName("div").item(0); menuHeader.setAttribute("class", "current"); menuHeader.setAttribute("className", "current"); } } }
     