

// Generate all navigation menu objects
for (var i = 0; i < nav_menuNames.length; i++) {
	var menuName = nav_menuNames[i];
	nav_menuObjs[menuName] = new Menu(menuName,nav_menuText[menuName],nav_menuURLs[menuName], nav_menuWidth,nav_navButtonWidth[i], nav_menuRowHeight, nav_menuTextInset, nav_menuTextClass);
}

// Constructor for menu objects
function Menu(name,menuText,menuURLs, menuWidth,buttonWidth, menuRowHeight, menuTextInset, MenuTextClass) {
	this.name = name;
	this.containerDivRef = this.name + 'Menu';
	this.containerDivName = this.containerDivRef + 'Div';
	this.menuText = menuText;
	this.menuURLs = menuURLs;
	this.obj = this.name + 'Obj';
	this.openMenu = MenuOpen;
	this.closeMenu = MenuClose;
	this.build = MenuBuild;
	this.highlightElm = HighlightElm;
	this.revertElm = RevertElm;
	
	// Various style attributes for menu elements
	this.menuWidth = nav_menuWidth;
	this.buttonWidth = nav_navButtonWidth[i];
	//this.rowHeight = menuRowHeight;
	this.menuRowHeight = nav_menuRowHeight;
	this.menuTextInset = nav_menuTextInset;
	//this.padHeight = menuPadHeight;
	//this.padWidth = menuPadWidth;
	this.menuClass = MenuTextClass;
	//this.menuEdgeColor = nav_menuEdgeColor;
	//this.menuOutlineColor = nav_menuOutlineColor;
	this.highlightColor = nav_menuHighlightColor;
	eval(this.obj+"=this");
	// Build the menu items
	this.build();
}

function MenuOpen() {
	eval(this.containerDivRef + ".show()");
}

function MenuClose() {
	eval(this.containerDivRef + ".hide()");
}

function HighlightElm(name) {
	obj=getDomObjRef(name);

	if (is.ie4) {
		obj.background = nav_ie4HighlightImage;
	} else {
		obj.bgColor = this.highlightColor;
	}
}

function RevertElm(name) {
	obj=getDomObjRef(name);
		
	if (is.ie4) {
		obj.background = nav_nsMenuBgColor;
	} else {
		obj.bgColor = nav_nsMenuBgColor;
	}
}
	

// Function to dynamically build the DIVs used to house the content menu
function MenuBuild() {
	var cellWidth = this.menuWidth;
	var dataWidth = cellWidth - 4;
	var tableWidth = this.menuWidth;
	var spaceWidth = this.menuWidth - this.buttonWidth - 1;

	this.div = '<div id="' + this.containerDivName + '" width="' + tableWidth + '">\n';
	this.div += '<table width="' + tableWidth + '" summary="Menu for ' + this.name + '" border="0" cellpadding="0" cellspacing="0">\n';
	this.div += '<tr><td bgcolor="#ffcc66"><img src="/images-common/Pixel-Transparent.gif" alt="" width="' + this.buttonWidth + '" height="1" border="0" /></td>\n';
	this.div += '<td><img src="/images-common/Pixel-Transparent.gif" alt="" width="' + spaceWidth + '" height=1 border="0" /></td>\n';
	this.div += '<td><img src="/images-common/Pixel-Transparent.gif" alt="" width=1 height=1 border="0" /></td></tr>\n';
	this.div += '<tr><td bgcolor="#ffcc66" colspan=2><img src="/images-common/Pixel-Transparent.gif" alt="" width="156" height="1" border="0" /></td>\n';
	this.div += '<td><img src="/images-common/Pixel-Transparent.gif" alt="" width=1 height="1" border="0" /></td></tr>\n';
	this.div += '<tr><td bgcolor="#ffcc66" colspan=3><img src="/images-common/Pixel-Transparent.gif" alt="" width="156" height="2" border="0" /></td>\n</tr>\n';

	// Generate code for all URLs
	var elmName;
	for (var i = 0; i < this.menuText.length; i++) {
		elmName = this.name + 'Elm' + i;
		this.div += '<tr><td bgcolor="#515050" colspan=3 width="' + tableWidth + '" id="' + elmName + '" onmouseover="' + this.obj + '.highlightElm(\'' + elmName + '\');" onmouseout="' + this.obj + '.revertElm(\'' + elmName + '\');">\n';
		if (this.menuText[i] != '') {
			this.div += '<table border="0" cellspacing="0" cellpadding="0">\n<tr>\n';
			this.div += '<td><img src="images/menu-LeftEdge.gif" width="4" height="21" border="0" /></td>\n';
			this.div += '<td width=4><spacer type=block width=4 height=1 /></td>\n';
			this.div += '<td width="' + dataWidth +'"><div class="menuMargin"><a href="/'+ this.name +'/' + this.menuURLs[i] + '" class="'+ this.menuClass + '">' + this.menuText[i] + '</a></div></td>\n';
			this.div += '<td><img src="images/menu-RightEdge.gif"width="4" height="21" border="0" /></td>\n';
			this.div += '</tr>\n</table>\n';
		} else {
			// Empty cell within menu
			this.div += '';
		}
		this.div += '</td>\n</tr>\n';
		if (i != this.menuText.length - 1) {
			this.div += '<tr><td colspan=3 width=157 height=3 bgcolor="#ffcc66"><spacer type=block width=157 height=3 /></td></tr>';
		} else { continue; }
	}
	this.div += '<tr><td colspan=3><img src="images/menu-Bottom.gif" alt="" width="157" height="3" border="0" /></td></tr>\n</table>\n</div>\n';
}

