function InitMenu(obj) {
	var bar = document.getElementById(obj).childNodes;

	for (var i=0; i < bar.length; i++) {
		if (bar[i].id) {
			var menu = bar[i];
			menu.visibility = "hidden";
			menu.onmouseover = new Function("ShowMenu('"+menu.id+"')");

			if (menu.attributes && menu.attributes.getNamedItem('menu') != null) {
				att = menu.attributes.getNamedItem('menu').value;
				var Items = document.getElementById(att).childNodes;
	
				for (var j=0; j < Items.length; j++) {
					var menuItem = Items[j];
	
					if (menuItem.attributes && menuItem.attributes.getNamedItem('menu') != null) { 
						menuItem.innerHTML = "<table cellspacing=0 cellpadding=0 width='100%'><tr><td class=arrow>"+menuItem.innerHTML+"</td><td align=right class=arrow>&gt;</td></tr></table>";
						FindSubMenu(menuItem.attributes.getNamedItem('menu').value);
					}
	
					if (menuItem.attributes && menuItem.attributes.getNamedItem('cmd') != null) {
						menuItem.onclick = new Function("Do('"+menuItem.id+"')");
					}
	 
					menuItem.onmouseover = new Function("highlight('"+menuItem.id+"')");
				}
			}
		}
	}
}

function FindSubMenu(subMenu) {
	var menu = document.getElementById(subMenu);
	var Items = menu.childNodes;
	menu.style.visibility = "hidden";

	for (var j=0; j < Items.length; j++) {
		var menuItem = Items[j];

		if (menuItem.attributes && menuItem.attributes.getNamedItem('menu') != null) {
			menuItem.innerHTML = "<table cellspacing=0 cellpadding=0 width='100%'><tr><td class=arrow>"+menuItem.innerHTML+"</td><td align=right class=arrow>&gt;</td></tr></table>";
			FindSubMenu(menuItem.attributes.getNamedItem('menu').value);
		}

		if (menuItem.attributes && menuItem.attributes.getNamedItem('cmd') != null) {
			menuItem.onclick = new Function("Do('"+menuItem.id+"')");
		} 

		menuItem.onmouseover = new Function("highlight('"+menuItem.id+"')");
	}
}

function ShowMenu(obj) {
	HideMenu('menuBar');
	var menu = document.getElementById(obj);
	menu.className="barOver";
	menu.style.visibility = "visible";
	if (menu.attributes.getNamedItem('menu') != null) {
		att = menu.attributes.getNamedItem('menu').value;
		document.getElementById(att).style.visibility = "visible";
	}
}

function highlight(obj) {
	var Obj = document.getElementById(obj);
	var PElement = document.getElementById(obj).parentNode;
	HideMenu(PElement.id);
	if (PElement.hasChildNodes() == true) {
		var Elements = PElement.childNodes;
		for (var i=0; i < Elements.length; i++) {
			Elements[i].className = "menuItem";
		}
	} 
	Obj.className="ItemMouseOver";
	window.defaultStatus = Obj.title;
	ShowSubMenu(obj);
}
   
function Do(obj) {
	var Obj = document.getElementById(obj);
	if (Obj.attributes && Obj.attributes.getNamedItem('cmd') != null) {
		document.location = Obj.attributes.getNamedItem('cmd').value;
	}
}
   
function HideMenu(Obj) {
	obj = document.getElementById(Obj);
	
	if (obj.hasChildNodes()==true) {  
		var child = obj.childNodes;

		for (var j=0; j < child.length; j++) {
			if (child[j].attributes && child[j].attributes.getNamedItem('menu') != null) {
				att = child[j].attributes.getNamedItem('menu').value;
				document.getElementById(att).style.visibility = "hidden";
				if (document.getElementById(att).hasChildNodes() == true) HideMenu(att);
			}

			if (child[j].className == "barOver") {
				child[j].className="Bar";
			}

			if (child[j].className == "ItemMouseOver") {
				child[j].className="menuItem";
			}
		}
	}
}

function ShowSubMenu(obj) {
	var menu = document.getElementById(obj);
	if (menu != null && menu.attributes.getNamedItem('menu') != null) {
		att = menu.attributes.getNamedItem('menu').value;
		document.getElementById(att).style.visibility = "visible";
	}
} 

