// Generate all navigation menu objects
for (var i = 0; i < glnav_menuNames.length; i++) {
	//debugln(' ' + glnav_menuNames[i]);
	var menuName = glnav_menuNames[i];
	glnav_menuObjs[menuName] = new Menu(menuName,glnav_menuText[menuName],glnav_menuURLs[menuName], glnav_menuWidth, glnav_menuRowHeight, glnav_menuElmHeight, glnav_menuPadHeight, glnav_menuPadWidth, glnav_menuTextClass);
}



// YOU CANNOT GET RID OF THESE NEXT TWO LINES
menuName = 'US';
glnav_menuObjs['US'] = new Menu(menuName,gCouNav_menuText[menuName],gCouNav_menuURLs[menuName], gCouNav_menuWidth, gCouNav_menuRowHeight, gCouNav_menuElmHeight, gCouNav_menuPadHeight, gCouNav_menuPadWidth,glnav_couMenuTextClass );




// Constructor for menu objects
// Last modified: 06.05.01 
// Original author: rPm | Sapient
function Menu(name,menuText,menuURLs, menuWidth, menuRowHeight, menuElmHeight, menuPadHeight, menuPadWidth, MenuTextClass) {
    //debugln('Menu Constructor: Name:' + name);
	this.name = name;
	this.containerDivRef = this.name + 'Container';
	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 = glnav_menuWidth;
	this.rowHeight = menuRowHeight;
	this.menuElmHeight = menuElmHeight;
	this.padHeight = menuPadHeight;
	this.padWidth = menuPadWidth;
	this.menuClass = MenuTextClass;
	this.menuEdgeColor = glnav_menuEdgeColor;
	this.highlightColor = glnav_menuHighlightColor;
	eval(this.obj+"=this");
	// Build the menu items
	this.build();	
}

function MenuOpen() {
	
	if(this.containerDivName=="USContainerDiv")
		{
		eval(this.containerDivRef + ".setRight()");
		eval(this.containerDivRef + ".setBottom(true)");
		}
	eval(this.containerDivRef + ".show()");
}

function MenuClose() {
	eval(this.containerDivRef + ".hide()");
}

function HighlightElm(name) {
	obj=getDomObjRef(name);

	if (is.ie4) {
		obj.background = glnav_ie4HighlightImage;
	} else {
		obj.bgColor = this.highlightColor;
	}
}

function RevertElm(name) {
	obj=getDomObjRef(name);
		
	if (is.ie4) {
		obj.background = '';
	} else {
		obj.bgColor = '';
	}
}

// Function to dynamically build the DIVs used to house the content menu

// THIS POPS UP THE MENU THAT SPRINGS OFF OF THE BUTTONS IN THE TOPBAR ("About us", "What we do", "Find out more")
function MenuBuild() {
   if (this.containerDivName == 'USContainerDiv')
   	{
   	var cellWidth = gCouNav_menuWidth - 2;
	var dataWidth = cellWidth - 2*this.padWidth;
   	}
   else
   	{
   	var cellWidth = this.menuWidth - 2;
	var dataWidth = cellWidth - 2*this.padWidth;   
   	}
   var tableWidth = cellWidth + 2;
   
   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 colspan="3" height="1" bgcolor="' + this.menuEdgeColor + '"><spacer type="block" height="1" width="1"></td>\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 height="' + this.rowHeight + '"><td width="1" bgcolor="' +this.menuEdgeColor + '"><spacer type="block" height="1" width="1"></td>\n';
		if (this.menuText[i] != '') {
			this.div += '       <td width="' + cellWidth + '" id="' + elmName + '" width="' + cellWidth + '" onmouseover="' + this.obj + '.highlightElm(\'' + elmName + '\');" onmouseout="' + this.obj + '.revertElm(\'' + elmName + '\');">\n';
			this.div += '	<table height="' + this.rowHeight + '" width="' + cellWidth+ '" cellpadding="0" cellspacing="0" border="0">\n';
			this.div += '	  <tr height="' + this.padHeight + '"><td colspan="3"><spacer type="block" height="1" width="1"></td></tr>\n';
			this.div += '	  <tr height="' + this.menuElmHeight + '"><td width="' + this.padWidth + '"><spacer type="block" height="1" width="1"></td>\n';
			
			this.div += '<td width="' + dataWidth +'"><a class="'+ this.menuClass + '" href="' + this.menuURLs[i] 
			+ '" >' + this.menuText[i] + '</a></td>\n';
			this.div += '	    <td width="' + this.padWidth + '"><spacer type="block" height="1" width="1"></td></tr>\n';
			this.div += '	  <tr height="' + this.padHeight + '"><td colspan="3"><spacer type="block" height="1" width="1"></td></tr>\n';
			this.div += '	</table></td>\n';
		} else {
			// Empty cell within menu
			this.div += '       <td width="' + cellWidth + '">&nbsp;</td>\n';
		}
		this.div += ' <td width="0" bgcolor="' + this.menuEdgeColor + '"><spacer type="block" height="1" width="1"></td></tr>\n';
	        this.div += ' <tr><td colspan= height="" bgcolor="' + this.menuEdgeColor + '"><spacer type="block" height="1" width="1"></td><td height="1" ><spacer type="block" height="1" width="1"></td><td height="1" bgcolor="' + this.menuEdgeColor + '"><spacer type="block" height="1" width="1"></td>\n';
	        this.div += ' <tr><td  height="1" bgcolor="' + this.menuEdgeColor + '"><spacer type="block" height="1" width="1"><td  height="1"><spacer type="block" height="1" width="1"></td><td height="1" bgcolor="' + this.menuEdgeColor + '"><spacer type="block" height="1" width="1"></td></tr>\n';
      }
   this.div += '    <tr><td colspan="3" height="" bgcolor="' + this.menuEdgeColor + '"><spacer type="block" height="1" width="1"></td>\n';
   this.div += '   </table>\n</div>\n';
 }
