

// Javascript/DHTML Menu Script
// By Luke Pacholski <http://lukpac.org/>
//
// Basic code by Mark Lippert at http://patmccurdy.com
//	 based on http://www.builder.com/Programming/Scripter/052300/
//
// Additional code from http://developer.netscape.com/viewsource/smith_menu/smith_menu.html

function Menu(label) {
    this.items = new Array();
    this.actions = new Array();
    this.addMenuItem = addMenuItem;

    if (!window.menus) window.menus = new Array();
    this.label = label || "menuLabel" + window.menus.length;
    window.menus[this.label] = this;
    window.menus[window.menus.length] = this;
}

function addMenuItem(label, action) {
    this.items[this.items.length] = label;
    this.actions[this.actions.length] = action;
}


//Create submenus
function drawSubMenu(count, SUBabsTOP, SUBabsLEFT) {
	var subSTR = '';
	
	//compile sub menu 
	if (ns4) {
		subSTR += '<layer name=' + menus[count].label + ' visibility=hide top=' + SUBabsTOP + ' left=' + SUBabsLEFT + ' onmouseover="this.visibility=\'show\'" onmouseout="this.visibility=\'hide\'">';
	}
	subSTR += '<table cellpadding=0 cellspacing=0 border=0 class=SUBmenubar ';
	if (!ns4) {
		subSTR += ' id="' + menus[count].label + '"';
	}
	if (ie4) {
		subSTR += ' style="visibility:hidden; position:absolute; top:' + SUBabsTOP + 'px; left:' + SUBabsLEFT + 'px;" onmouseover="document.all[\'' + menus[count].label + '\'].style.visibility=\'visible\'" onmouseout="document.all[\'' + menus[count].label + '\'].style.visibility=\'hidden\'">';
	}else if (op5) {
		subSTR += ' style="visibility:hidden; position:absolute; top:' + SUBabsTOP + 'px; left:' + SUBabsLEFT + 'px; width:' + (imgW+6) + 'px" onmouseover="document.all[\'' + menus[count].label + '\'].style.visibility=\'visible\';">';
	}else if (mz7 || ns6) {
		subSTR += ' style="display:none; position:absolute; left:' + SUBabsLEFT + 'px; top:' + SUBabsTOP + 'px; z-index:11">';
	}else {
		subSTR += '>';
	}
	for (i=0; i < menus[count].actions.length; i++) {
		if (menus[count].actions[i] != "" && menus[count].items[i] != "") {
			subSTR += '<tr onClick="self.location=\'' + menus[count].actions[i] + '\'"><td class=SUBmenubarTD' + space +' onMouseOver="this.bgColor=\'' + HiliteColor + '\'" onMouseOut="this.bgColor=\'\'" NOWRAP>&nbsp;&nbsp;<a href="' + menus[count].actions[i] + '"' + shiftUP + '>' + menus[count].items[i] + '</a>&nbsp;&nbsp;&nbsp;</td></tr>';
		}
	}
	subSTR += '</table>';
	if (ns4) {
		subSTR += '</layer>';
	}
	
	//actually draw it
	document.write(subSTR);
}

function showMenu(menuName){
	if (ns4){
		document.layers[menuName].visibility='show';
	}else if (ie4) {
		clearMenus();
		document.all[menuName].style.visibility='visible';
	}else if (op5) {
		clearMenus();
		document.all[menuName].style.visibility='visible';
	}else if (ns6 || mz7) {
		clearMenus();
		document.getElementById(menus[menuName].label).style.display='';
		document.getElementById(menus[menuName].label).style.visibility='visible';
	}

}

function hideMenu(menuName){
	if (ns4){
		document.layers[menuName].visibility='hide';
	}else if (ie4) {
		document.all[menuName].style.visibility='hidden';
	}else if (op5) {
		document.all[menuName].style.visibility='visible';
	}else if (ns6 || mz7) {
		//clearMenus();
		//document.getElementById(menus[menuName].label).style.display='';
	}

}

//this gets me out of a couple of sticky spots
function clearMenus() { 
	if (ns6 || mz7) {
		for(j=0; j < menus.length; j++) {
			document.getElementById(menus[j].label).style.display='none';
			document.getElementById(menus[j].label).style.visibility='hidden';
		}
	}else {
		for(j=0; j < menus.length; j++) {
			document.all[menus[j].label].style.visibility='hidden';
		}
	}
}

//
//**old browser excluded
//if (!old) {
	
	// white line spacer width - used to determine the width of each sub-table
	if (op5){
		var imgW = 116;
	}else{
		var imgW = 124;
	}
	
	
	
	var SUBlinkCellOpen = '<tr><td class=SUBmenubarTD';
	//var nsBR = ""; if (ns6) { nsBR = "<br class=br>"; }
	var space = ''; 
	space = ' height=19';
	var shiftUP = '';
	if (ie4) { var shiftUP = ' style="position:relative; top:0px;"'; }
	if (ns6) { var shiftUP = ' style="position:relative; top:0px;"'; }
	if (op5) { var shiftUP = ' style="position:relative; top:-3px;"'; }
	if (mz7) { var shiftUP = ' style="position:relative; top:0px;"'; }
	
	//var trigger = onmouseover="this.visibility='show'";
	
	//closing mechanism for Opera 5
	if (op5 || ns6 || mz7) document.onclick = clearMenus; 
	
//}
//**old browser excluded



