/**
 * @author Justin Johnson <justin@fryewiles.com>, Justin@booleangate.org
 * @version 0.0.7a 20070703
 */


var last_hovered_nav = null;
	
default_menu_controls = function() {
	/* Creates onmouseover/out attributes that assign the
	 * proper classes for the header navigation elements.
	 */
	if ( document.getElementById ) {
		navRoot = document.getElementById("top-rung");

		for (i=0; i<navRoot.childNodes.length; i++) {
			node = navRoot.childNodes[i];
			
			if (node.nodeName.toLowerCase() == "li") {
				// Mouseover: show submenu, don't hide it unless showing a different submenu
				
				node.onmouseover = function() {
					default_menu_hide_subnav(last_hovered_nav);
					try {
						var subnav = document.getElementById(this.id + "-sub");
					
						if ( subnav ) {
							last_hovered_nav = this;
							
							subnav.className = subnav.className.replace(" fhidden", "");
						}
					} catch (err) {
					}
				}
			}
		}
	}
}

default_menu_hide_subnav = function(obj) {
	if ( !obj ) { return; }
	
	var subnav = document.getElementById(obj.id + "-sub");
	
	if ( subnav ) {
		subnav.className += " fhidden";
	}	
}

window.onload = default_menu_controls;
