//Menu script - menu1.js
//Tad

function killMenu(which) {
	if(which == intActiveMenu) {
		// get the list of menu layers
		arMenuList = eval("arMenu" + which + "List");
	
		// loop through the list, hiding all the menu layers, and resetting the arrows
		for(i=0; i<arMenuList.length; i++) {
			strCurrLayer = arMenuList[i];
			styleRef(strCurrLayer).visibility = strHide;
		}
	}
}

function doMenu() {

	killMenu(arguments[0]);
	killMenu();
	intActiveMenu = arguments[0];
	
	 // show the top level menu
	strMenuItem = "menu" + arguments[0];
	styleRef(strMenuItem).visibility = strShow;

	strImgName = "imgmenu" + arguments[0];
	
	// show the lower level menus and arrows
	for(i=1; i<arguments.length; i++) {
		styleRef(strMenuItem).visibility = strShow;
	}
}

function activateMenu(which) {
	if(which != intActiveMenu) {

		if((!which) || (typeof which == "object")) {
			which = intActiveMenu;
		}
	
		if(intActiveMenu != 0) {
			killMenu(intActiveMenu);
			if(which == intActiveMenu) {
				intActiveMenu = 0;
				which = 0;
			}
		}
		
		if(which != intActiveMenu) {
			styleRef("menu" + which).visibility = strShow;
			intActiveMenu = which;
		}
		
	}
}

function init() {

	var i, nn=85;
	
	if(document.all) {
		strHide = "hidden";
		strShow = "visible";
		document.body.onclick = activateMenu;
	} else if(document.layers) {
		strHide = "hide";
		strShow = "show";
		window.captureEvents(Event.MOUSEUP);
		window.onmouseup = activateMenu;
	}

	strLastCommand = "";
	intActiveMenu = 0;

	for (i=0; i<nn; i++) {
		eval("arMenu" + (i+1) + "List = new Array('menu" + (i+1) + "')");
	}
}


