
// this renders all the data from myMenu array into Menu tables

for (var x = 0; x <= myMenu.length-1; x++){
	
	currLoc = "'" + myMenu[x][1] +  "'";
	
	if(mySubmenu[x][0][0]!=""){menuLaunch = "showdiv(" + x + ")";menuExit = "hidediv(" + x + ")";} else {menuLaunch = "";menuExit = "";}
	
	if(currpage==x){
		currBackground = 'background="images/1i_whtarrow_bk.gif"';
		currClass = "menulinksel";
		//ie_handler = '';
		ie_handler = 'onClick="javascript:window.location.assign(' + currLoc + ');"';
		nn_handler = '';
	}else{
		currBackground = '';
		currClass = "menulink";
		ie_handler = 'onMouseOver="hideall();this.style.backgroundColor=menuOnColor;' + menuLaunch + ';linkCol(' + x + ',1)" onMouseOut="this.style.backgroundColor=menuOffColor;' + menuExit + ';linkCol(' + x + ',0)" onClick="javascript:window.location.assign(' + currLoc + ');"';
		nn_handler = 'onMouseOver="hideall();this.bgColor=menuOnColor;' + menuLaunch + '" onMouseOut="this.bgColor=menuOffColor;' + menuExit + '" onClick="javascript:window.location.assign(' + currLoc + ');"';
	}
	
	document.write('<tr><td><table width="152" height="20" border="0" cellspacing="0" cellpadding="0" bgcolor="#336699"><tr><td ' + currBackground + 'valign="top"' + ie_handler + 'id="menubox' + x + '" class="menubox"><ilayer id="menuboxIL' + x + '"><layer id="menuboxL' + x + '" ' + currBackground + 'width="152" height="20" ' + nn_handler + '><img src="images/spacer.gif" width=5 height=13 alt="" border=0 name="posImg' + x + '" hspace=0 vspace=0 align="bottom"><a href="' + myMenu[x][1] + '" class="' + currClass + '" id="link' + x + '">' + myMenu[x][0] + '</a></layer></ilayer></td></tr></table></td></tr>');
	
	// render relavent submenu for current page under page link
	if((currpage==x)&&(mySubmenu[x][0][0]!="")){
		document.write('<tr><td>');
		for (var z = 0; z <= mySubmenu[x][0].length-1; z++){
		
			var currSubLoc = "'" + mySubmenu[x][1][z] +  "'";
			
			if(currsubpage==z){
				currBackgroundCol = submenuOnColor;
				//ie_handler_sub = '';
				ie_handler_sub = 'onClick="javascript:window.location.assign(' + currSubLoc + ');"';
				nn_handler_sub = '';
			}else{
				currBackgroundCol = subMenuMnColor;
				ie_handler_sub = 'onMouseOver="this.style.backgroundColor=submenuOnColor;" onMouseOut="this.style.backgroundColor=submenuOffColor;" onClick="javascript:window.location.assign(' + currSubLoc + ');"';
				nn_handler_sub = 'onMouseover="this.bgColor=submenuOnColor;" onMouseout="this.bgColor=submenuOffColor;"';
			}
			
			var anchorTag = "<a href='" + mySubmenu[x][1][z] + "' target='" + mySubmenu[x][2][z] + "' class='submenulink'>" + mySubmenu[x][0][z] + "</a>";
			document.write('<table width="152" border="0" cellspacing="0" cellpadding="0"><tr><td width="11" background="images/i_submenuarrow_bk.gif" valign="top"><img src="images/i_submenuarrow.gif" width="11" height="14" alt="" border="0"></td><td width="141" bgcolor="' + currBackgroundCol + '" ' + ie_handler_sub + ' class="submenucell"><ilayer><layer width="100%" ' + nn_handler_sub + '>&nbsp;' + anchorTag + '&nbsp;<br><img src="images/spacer.gif" width="1" height="2" alt="" border="0"></layer></ilayer></td></tr>');
			if(z < (mySubmenu[x][0].length-1)){document.write('<tr><td colspan="2" background="images/i_submenudotln.gif"><img src="images/spacer.gif" width="1" height="1" alt="" border="0"></td></tr>')}
			document.write('</table>');	
		}
		document.write('</td></tr>');
	
	//alert(x);
	
	}
}