// 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

*/

//debug to print all object props
function writeProps(obj) {
	var i;
	var output;
	output += '<table>';
	for (i in obj) {
		output += '<tr><td>' + i + "</td><td>" + obj[i] + "</tr></td>";
	}
	output += '<table>';
	document.write(output);
}

//shortcut to get element
function getElement(id) {
	return document.getElementById(id);
}

//debug to print all object props
function submitForm(id) {
	var obj = getElement(id);
	obj.submit();
}

//makes object visible
function showObj(id) {
	var obj = getElement(id);
	obj.style.visibility = "visible";
	obj.style.zIndex = 10;
}

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

//inits UL with id so all children act a menu buttons
function initMenu(id) {
	var list = getElement(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;
			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);}/**/
		}
	}
}