// JavaScript Document
/*
	Name:		menu.js
	Author:		Chad Hovell
	Desc:		rollover menu - supports only 1 level of submenu
				more than 1 level will require recursively hiding parent menus...
	
	History:
				22 - 02 - 2007
				Created
				shows, hides, inits, names

*/

//makes object visible
function showObj(id) {
	//alert("SHOW " + id);
	document.getElementById(id).style.visibility = "visible";
	document.getElementById(id).style.zIndex = 10;
}

//hides object
function hideObj(id) {
	document.getElementById(id).style.visibility = "hidden";
}

//inits UL with id so all children act a menu buttons
function initMenu(id) {
	var list = document.getElementById(id);
	var count = list.childNodes.length;
	var i;
	var menu;
	var submenu;
	var newId;
	
	//run thru all base level menu items
	for (i=0; i<count; i++) {
		menu = list.childNodes[i];
		
		if ((menu != null) && (menu.childNodes.length > 2)) {
			newId = 'sub' + i;
			
			if (menu.childNodes[0].tagName == null) {
				subMenu = menu.childNodes[3];
			} else {
				subMenu = menu.childNodes[2];
			}
			subMenu.id = newId;
			
			menu.subMenu = newId;
			menu.onmouseover = function() {showObj(this.subMenu);}
			menu.onmouseout = function() {hideObj(this.subMenu);}
			/*submenu.onmouseover = function() {showObj(newId);}
			submenu.onmouseout = function() {hideObj(newId);}/**/
		}
	}
}