/*
 * menuExpandable3.js - implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 */

if (!document.getElementById)
    document.getElementById = function() { return null; }
/*
function initializeMenu(menuId, actuatorId) {
    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.parentNode.style.backgroundImage = "url(/images/plus.gif)";
    actuator.onclick = function() {
        var display = menu.style.display;
        //this.parentNode.style.backgroundImage =
        //    (display == "block") ? "url(/images/plus.gif)" : "url(/images/minus.gif)";
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}
*/

/* this rewrite is being modeled after the suckerfish dropdowns */
function initializeMenu(menuid)
{
	var navRoot, i, j, node, add_handler, innernode;
	
	navRoot = document.getElementById(menuid);
	
	if (navRoot == null) return;
	for (i=0; i<navRoot.childNodes.length; i++) 
	{
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") 
		{
			add_handler = false;
			for (j=0; j<node.childNodes.length; j++) /*check to see if this node contains an unordered list */
			{
				if ( node.childNodes[j].nodeName == "UL")
				{
					add_handler = true;
					break;
				}
			}
			
			if (add_handler == true)
			{
				for (j=0; j<node.childNodes.length; j++)
				{
					innernode = node.childNodes[j];
					if (innernode.nodeName=="A")
					{
						innernode.onclick = toggleMenu;
					}
				}
			}
		}
	}
}

/* this function is added to all links which can toggle submenus */
function toggleMenu()
{
 	if (this.parentNode.className.indexOf("open") >= 0)
 	{
 		this.parentNode.className = this.parentNode.className.replace("open", ""); /* colapse the tree */
 	}
 	else
 	{
 		this.parentNode.className += " open"; /* expand the tree */
 	}
	return false; /* keep the link from going anywhere */
}