//  Menu.js - version 3.0
//   v3.0 (Feb 12/02) - Added Netscape 6/Mozilla compatibility
//   v2.0 (Mar 28/01) - a) Fixed fly-out alignment to fit inside the page,
//                      b) Added capability to accept non-url main menu items (not hilited)
//   v1.0   (Feb 18/01) - original implementation

// Netscape 6/Mozilla compatiblity code segment for 
// insertAdjacentHTML(), insertAdjacentText() and insertAdjacentElement()

if (document.childNodes&&!document.childNodes[0].insertAdjacentHTML){

HTMLElement.prototype.insertAdjacentElement = function(where,parsedNode){

	switch (where){
	case 'beforeBegin':
		this.parentNode.insertBefore(parsedNode,this)
		break;
	case 'afterBegin':
		this.insertBefore(parsedNode,this.firstChild);
		break;
	case 'beforeEnd':
		this.appendChild(parsedNode);
		break;
	case 'afterEnd':
		if (this.nextSibling){
			this.parentNode.insertBefore(parsedNode,this.nextSibling);
		} else {
			this.parentNode.appendChild(parsedNode)
		}
		break;
	}
}

HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr){

	var r = this.ownerDocument.createRange();
	r.setStartBefore(this);
	var parsedHTML = r.createContextualFragment(htmlStr);
	this.insertAdjacentElement(where,parsedHTML)
}


HTMLElement.prototype.insertAdjacentText = function(where,txtStr){

	var parsedText = document.createTextNode(txtStr)
	this.insertAdjacentElement(where,parsedText)
}
}



var mainBGColor              = "#003366";
var subBGColor               = "#ffcc33";

var overColor                = "#ffcc00";
var highlightColor           = "#ffcc33";
var highlightCode            = 0;

var overMainSubColor         = "#faeebb";
var highlightMainSubColor    = "#faeecc";
var highlightMainSubCode     = 0;

var overSubColor             = "#ffb200";
var highlightSubColor        = "#ffb200";
var highlightSubCode         = 0;

var delay             = 100;
var MaxMainMenuItems = 100;  
var mainMenus      = new Array(eval(MaxMainMenuItems));
var popUpMenus     = new Array(eval(MaxMainMenuItems));
var rollDownMenus  = new Array(eval(MaxMainMenuItems));
var rollDownClose  = new Array(eval(MaxMainMenuItems));
var cellHeight     = 12;
var closeLayerName = "";

function initVariable()
{
	ns=window.navigator.appName == "Netscape";
	ie=window.navigator.appName == "Microsoft Internet Explorer";
	ns6=false;
	if (!document.all && document.getElementById) 
	{
		ns6=true;
		ns=false;
	}

	if (!window.imagePath)   imagePath = "";
	if (!window.MenuTop)     MenuTop = 75;
	if (!window.menuPadding) menuPadding = 2;
	if (!window.cellSpacing) cellSpacing = 2;

	if (!window.mRollNo && !window.mRollItem)
	{
	
		mRollNo   = 0;
		mRollItem = 0;
		mystr     = document.location.search;
	//	mystr="http://corp.utest.sunlife.com/corp/genpage/0,2034,30,.html?rolldown=3&rollitem=2''&languageId=1";
		if (mystr.indexOf("&") > 0)
		{
			mystr     = mystr.substr(1);
			myvar     = mystr.split("&");
			myvar1    = myvar[0].split("=");
			myvar2    = myvar[1].split("=");
			mRollNo   = parseInt(myvar1[1]);
			mRollItem = parseInt(myvar2[1]);
			if (isNaN(mRollNo)) mRollNo = 0;
		}
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {
  	if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    		document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onResize=MM_reloadPage; 
	}
  }
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}

function myParseURL()
{
	loadMenu_ns();
}

function loadMenu_ie()
{
	initVariable();
	if (ns) return;
	if (ns6)
		renderMenu_ns6();
	else
		renderMenu_ie();
}

function loadMenu_ns()
{
	initVariable();
	if (!ns) return;
	renderMenu_ns();
	MM_reloadPage(true);
}

function renderMenu_ns()
{
	MenuTopTick = MenuTop+48;       // Menu Start plus Height of Ticker Symbol
	loc = 1;

	var menuItemPos = 0;
	var menuCount   = 0;
	if (mRollNo > 0)
	{
		for (menuItemPos = 0; menuItemPos < MaxMainMenuItems; menuItemPos++)
		{
			if (mainMenus[menuItemPos][3].length > 0) menuCount++;
			if (menuCount == mRollNo) break;
		}
	}

	window.status = "Loading menus ...";
	document.write("<layer id=\"mainMenu\" top=\"" + eval(MenuTopTick) + "px\" left=\"0px\" WIDTH=\"146px\" HEIGHT=\"440\" Z-INDEX=1 VISIBILITY=hide BACKGROUND=\"" + imagePath + "sitenav.gif\">");
	for (var i = 0; i < MaxMainMenuItems && mainMenus[i][0] != "end"; i++)
	{
		window.status = "Loading menus ...";
		MenuTopTick += cellHeight;
		layerName = "mainMenu" + i;
		lstr = "";
		if (i == menuItemPos)
			lstr += "<layer id=\"" + layerName + "\" left=\"0px\" width=\"146px\" onMouseOver=\"hiLite(" + i + ", this, true);\">";
		else
		{
			if (mainMenus[i][3].length > 0)
				lstr += "<layer id=\"" + layerName + "\" left=\"0px\" width=\"146px\" onMouseOver=\"hiLite(" + i + ", this, true);\" onMouseOut=\"hiLite(" + i + ", this, false);\">";
			else
				lstr += "<layer id=\"" + layerName + "\" left=\"0px\" width=\"146px\">";
		}
		lstr += "<table height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
		lstr += "<tr>";
		lstr += "<td width=\"14\">";
		if (hasChildren(i))
		{
			if (i == menuItemPos)
			{
				lstr += "&nbsp<img id=\"Img1\" src=\"" + imagePath + "arrowrtwht2(roll).gif\" border=\"0\" width=\"8\" height=\"8\" align=\"absmiddle\">";
			}
			else
			{
				lstr += "&nbsp<img id=\"Img1\" src=\"" + imagePath + "arrowrtwht2.gif\" border=\"0\" width=\"8\" height=\"8\" align=\"absmiddle\">";
			}

		}
		else
		{
			lstr += "&nbsp;";
		}
		lstr += "</td>";
		lstr += "<td width=\"110\" align=left>";
		if (mainMenus[i][3].length > 0)
		{
			lstr += "<a class=aorange href=\"" + mainMenus[i][3] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
			lstr += mainMenus[i][0];
			lstr += "</a>";
		}
		else
		{
			lstr += mainMenus[i][0];
		}
		lstr += "</tr>";
		lstr += "</table>";
		lstr += "</layer>\n";

		document.write(lstr);
		if (i == menuItemPos)
		{
			if (hasChildren(i))
			{
				for (var menuPos = 0; menuPos < MaxMainMenuItems && rollDownMenus[loc][menuPos][0] != "end"; menuPos++)
				{
					subLayerName = "mainSubMenu" + i + "_" + menuPos;
					lstr = "";
					if (mRollItem - 1 == menuPos)
						lstr += "<layer id=\"" + subLayerName + "\" left=\"0px\" width=\"146px\" onMouseOver=\"hiLite(-3, this, true);\">";
					else
					{
						if (rollDownMenus[loc][menuPos][1].length > 0)
							lstr += "<layer id=\"" + subLayerName + "\" left=\"0px\" width=\"146px\" onMouseOver=\"hiLite(-3, this, true);\" onMouseOut=\"hiLite(-3, this, false);\">";
						else
							lstr += "<layer id=\"" + subLayerName + "\" left=\"0px\" width=\"146px\">";
					}
					lstr += "<table height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
					lstr += "<tr>";
					lstr += "<td width=\"17\">";
					lstr += "&nbsp;";
					lstr += "</td>";
					lstr += "<td width=\"110\" align=left>";
					if (rollDownMenus[loc][menuPos][1].length > 0)
					{
						lstr += "<a class=apopup href=\"" + rollDownMenus[loc][menuPos][1] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
						lstr += rollDownMenus[loc][menuPos][0];
						lstr += "</a>";
					}
					else
					{
						lstr += rollDownMenus[loc][menuPos][0];
					}
					lstr += "</tr>";
					lstr += "</table>";
					lstr += "</layer>\n";
					document.write(lstr);

					if (mRollItem - 1 == menuPos)
					{
						document.layers["mainMenu"].layers[subLayerName].bgColor = overMainSubColor;
						highlightMainSubCode = document.layers["mainMenu"].layers[subLayerName].bgColor;
					}
				}
			}
			document.layers["mainMenu"].layers[layerName].bgColor = overColor;
			highlightCode = document.layers["mainMenu"].layers[layerName].bgColor;
		}
		if (hasChildren(i)) loc += 1;
	}
	document.write("</layer>");


	var heightOffset = 0;
	for (var i = 0; i < document.layers["mainMenu"].layers.length; i++)
	{
		document.layers["mainMenu"].layers[i].top += heightOffset + menuPadding;
		heightOffset += document.layers["mainMenu"].layers[i].clip.height + menuPadding;
	}
	document.layers["mainMenu"].clip.height = heightOffset;

	renderSubMenus_ns();
	document.layers["mainMenu"].visibility = "show";

	if (mRollNo > 0 && hasChildren(menuItemPos))
		disablePopup(menuItemPos);
	window.status = "Done";

}



function renderSubMenus_ns()
{
	loc = 1;
	for (var i = 0; i < MaxMainMenuItems && mainMenus[i][0] != "end"; i++)
	{
		if (mainMenus[i][1] == true)
		{
			menuTopTick = document.layers["mainMenu"].top + document.layers["mainMenu"].layers["mainMenu" + i].top;
			layerName = "subMenu" + i;
			document.write("<layer id=\"" + layerName + "\" top=\"" + menuTopTick + "px\" left=\"150px\" WIDTH=\"146px\" HEIGHT=\"10\" Z-INDEX=1; VISIBILITY=hide; background-color: #ffcc33; layer-background-color: #ffcc33; bgColor=\"#ffcc33\" onMouseOut=\"hiLiteSubMenus(" + i + ", false)\">");
			for (var menuPos = 0; menuPos < MaxMainMenuItems && rollDownMenus[loc][menuPos][0] != "end"; menuPos++)
			{
				lstr = "";
				lstr += "<layer id=\"subMenu" + i + "_" + menuPos + "\" left=\"0px\" width=\"146px\" onMouseOver=\"hiLite(" + i + ", this, true);\" onMouseOut=\"hiLite(" + i + ", this, false);\">";
				lstr += "<table height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
				lstr += "<tr>";
				lstr += "<td width=5%></td>";
				lstr += "<td width=95% align=left>";
				if (rollDownMenus[loc][menuPos][1].length > 0)
				{
					lstr += "<a class=apopup href=\"" + rollDownMenus[loc][menuPos][1] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
					lstr += rollDownMenus[loc][menuPos][0];
					lstr += "</a>";
				}
				else
				{
					lstr += rollDownMenus[loc][menuPos][0];
				}
				lstr += "</tr>";
				lstr += "</table>";
				lstr += "</layer>\n";
				document.write(lstr);
			}
			document.write("</layer>");

			var heightOffset = 0;
			for (var menuPos = 0; menuPos < MaxMainMenuItems && rollDownMenus[loc][menuPos][0] != "end"; menuPos++)
			{
				document.layers[layerName].layers[menuPos].top += heightOffset;
				heightOffset += document.layers[layerName].layers[menuPos].clip.height;
			}
			loc += 1;
			document.layers[layerName].clip.height = heightOffset;
			document.layers[layerName].visibility = "hide";
		}
	}
}

function renderMenu_ns6()
{
	MenuTopTick = MenuTop+48;       // Menu Start plus Height of Ticker Symbol
	loc = 1;
	masterLayer = "<div id=\"mainMenu\" style=\"position:absolute; width:146px; height:440px; visibility:visible; background-image:url(" + imagePath + "sitenav.gif); left:0px; top:" + eval(MenuTopTick) + "px\"></div>";
	document.body.insertAdjacentHTML("beforeEnd", masterLayer);

	var menuItemPos = 0;
	var menuCount   = 0;
	if (mRollNo > 0)
	{
		for (menuItemPos = 0; menuItemPos < MaxMainMenuItems; menuItemPos++)
		{
			if (mainMenus[menuItemPos][3].length > 0) menuCount++;
			if (menuCount == mRollNo) break;
		}
	}

	for (var i = 0; i < MaxMainMenuItems && mainMenus[i][0] != "end"; i++)
	{
		MenuTopTick += cellHeight;
		layerName  = "mainMenu" + i;
		tabName    = "mainTable" + i;
		if (mainMenus[i][3].length > 0)
		{
			if (i == menuItemPos)
				layerStr  = "<div id=\"" + layerName + "\" style=\"position:relative; z-index:99; left:0px; width:146px;\" onMouseOver=\"hiLite(" + i + ", this, true);\">";
			else
				layerStr  = "<div id=\"" + layerName + "\" style=\"position:relative; z-index:99; left:0px; width:146px;\" onMouseOver=\"hiLite(" + i + ", this, true);\" onMouseOut=\"hiLite(" + i + ", this, false);\">";
		}
		else
		{
			layerStr  = "<div id=\"" + layerName + "\" style=\"position:relative; z-index:99; left:0px; width:146px;\">";
		}
		layerStr += "<table id=\"" + tabName + "\" height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
		layerStr += "<tr valign=\"middle\">";
		layerStr += "<td width=\"14\" valign=\"middle\">";
		if (hasChildren(i))
		{
			if (i == menuItemPos)
			{
				layerStr += "&nbsp<img id=\"Img1\" src=\"" + imagePath + "arrowrtwht2(roll).gif\" border=\"0\" width=\"8\" height=\"8\" align=\"middle\">";
			}
			else
			{
				layerStr += "&nbsp<img id=\"Img1\" src=\"" + imagePath + "arrowrtwht2.gif\" border=\"0\" width=\"8\" height=\"8\" align=\"middle\">";
			}

		}
		else
		{
			layerStr += "&nbsp;";
		}
		layerStr += "</td>";
		layerStr += "<td width=\"125\" align=left valign=\"middle\">";
		if (mainMenus[i][3].length > 0)
		{
		    layerStr += "<a class=aorange href=\"" + mainMenus[i][3] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
		    layerStr += mainMenus[i][0];
		    layerStr += "</a>";
		}
		else
		{
			layerStr += mainMenus[i][0];
		}
		layerStr += "</td>";
		layerStr += "</tr>";
		layerStr += "</table>";
		layerStr += "</div>";
		layerStr += "<div id=\"dummy\" style=\"position:relative; left:0px; width:146px; height:1px;\"><img id=\"Img1\" src=\"" + imagePath + "sitenav.gif\" border=\"0\" width=\"146\" height=\"" + menuPadding + "\"></div>";
		document.getElementById("mainMenu").innerHTML += layerStr;

		if (i == menuItemPos)
		{
			if (hasChildren(i))
			{
				for (var menuPos = 0; menuPos < MaxMainMenuItems && rollDownMenus[loc][menuPos][0] != "end"; menuPos++)
				{
					subLayerName = "mainSubMenu" + i + "_" + menuPos;
					if (rollDownMenus[loc][menuPos][1].length > 0)
					{
						if (mRollItem - 1 == menuPos)
							layerStr  = "<div id=\"" + subLayerName + "\" style=\"position=relative; left:0px; width:146px;\" onMouseOver=\"hiLite(-3, this, true);\">";
						else
							layerStr  = "<div id=\"" + subLayerName + "\" style=\"position=relative; left:0px; width:146px;\" onMouseOver=\"hiLite(-3, this, true);\" onMouseOut=\"hiLite(-3, this, false);\">";
					}
					else
						layerStr  = "<div id=\"" + subLayerName + "\" style=\"position:relative; left:0px; width:146px;\">";
					layerStr += "<table height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
					layerStr += "<tr>";
					layerStr += "<td width=\"17\">";
					layerStr += "&nbsp;";
					layerStr += "</td>";
					layerStr += "<td width=\"125\" align=left>";
					if (rollDownMenus[loc][menuPos][1].length > 0)
					{
						layerStr += "<a class=apopup href=\"" + rollDownMenus[loc][menuPos][1] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
						layerStr += rollDownMenus[loc][menuPos][0];
						layerStr += "</a>";
					}
					else
					{
						layerStr += rollDownMenus[loc][menuPos][0];
					}
					layerStr += "</td>";
					layerStr += "</tr>";
					layerStr += "</table>";
					layerStr += "</div>";
					layerStr += "<div id=\"dummy\" style=\"position:relative; left:0px; width:146px; height:1px;\"><img id=\"Img1\" src=\"" + imagePath + "sitenav.gif\" border=\"0\" width=\"146\" height=\"" + menuPadding + "\"></div>";
					document.getElementById("mainMenu").innerHTML += layerStr;
					if (mRollItem - 1 == menuPos)
					{
						document.getElementById(subLayerName).style.backgroundColor = overMainSubColor;
						highlightMainSubCode = document.getElementById(subLayerName).style.backgroundColor;
					}
				}
			}
			document.getElementById(layerName).style.backgroundColor = overColor;
			highlightCode = document.getElementById(layerName).style.backgroundColor;
		}
		if (hasChildren(i)) loc += 1;
	}

	var heightOffset = 0;

	renderSubMenus_ns6();

	if (menuItemPos > 0 && hasChildren(menuItemPos))
		disablePopup(menuItemPos);

}

function renderSubMenus_ns6()
{
	loc = 1;
	for (var i = 0; i < MaxMainMenuItems && mainMenus[i][0] != "end"; i++)
	{
		if (mainMenus[i][1] == true)
		{
			menuTopTick = parseInt(document.getElementById("mainMenu").offsetTop) + parseInt(document.getElementById("mainMenu" + i).offsetTop);
			layerName = "subMenu" + i;
			layerStr  = "<div id=\"" + layerName + "\" style=\"position:absolute; top:" + eval(menuTopTick) + "px; left:150px; width:146px; visibility:visible; background-color:#ffcc33;\" onMouseOver=\"hiLiteSubMenus(" + i + ", true)\" onMouseOut=\"hiLiteSubMenus(" + i + ", false)\"></div>";
			document.body.insertAdjacentHTML("beforeEnd", layerStr);
			for (var menuPos = 0; menuPos < MaxMainMenuItems && rollDownMenus[loc][menuPos][0] != "end"; menuPos++)
			{
				layerStr  = "<div id=\"subMenu" + i + "_" + menuPos + "\"style=\"position:relative; left:0px; width:146px; background-color:" + subBGColor + ";\" onMouseOver=\"hiLite(-2, this, true);\" onMouseOut=\"hiLite(-2, this, false);\">";
				layerStr += "<table height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
				layerStr += "<tr>";
				layerStr += "<td width=5% align=left></td>";
				layerStr += "<td width=95% align=left>";
				if (rollDownMenus[loc][menuPos][1].length > 0)
				{
					layerStr += "<a class=apopup href=\"" + rollDownMenus[loc][menuPos][1] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
					layerStr += rollDownMenus[loc][menuPos][0];
					layerStr += "</a>";
				}
				else
				{
					layerStr += rollDownMenus[loc][menuPos][0];
				}
				layerStr += "</td>";
				layerStr += "</tr>";
				layerStr += "</table>";
				layerStr += "</div>";
				document.getElementById(layerName).innerHTML += layerStr;
			}
			document.getElementById(layerName).style.visibility = "hidden";
			loc += 1;
		}
	}
}

function renderMenu_ie()
{
	
	MenuTopTick = MenuTop+48;       // Menu Start plus Height of Ticker Symbol
	loc = 1;
	masterLayer = "<div id=\"mainMenu\" style=\"position:absolute; width:146px; height:440px; visibility: visible; background-image:url(" + imagePath + "sitenav.gif); left=0px; top=" + eval(MenuTopTick) + "px\"></div>";
	document.body.insertAdjacentHTML("beforeEnd", masterLayer);

	var menuItemPos = 0;
	var menuCount   = 0;
	if (mRollNo > 0)
	{
		for (menuItemPos = 0; menuItemPos < MaxMainMenuItems; menuItemPos++)
		{
			if (mainMenus[menuItemPos][3].length > 0) menuCount++;
			if (menuCount == mRollNo) break;
		}
	}

	for (var i = 0; i < MaxMainMenuItems && mainMenus[i][0] != "end"; i++)
	{
		MenuTopTick += cellHeight;
		layerName  = "mainMenu" + i;
		tabName    = "mainTable" + i;
		if (mainMenus[i][3].length > 0)
		{
			if (i == menuItemPos)
				layerStr  = "<div id=\"" + layerName + "\" style=\"position=relative; z-index:99; left:0px; width:146px;\" onMouseOver=\"hiLite(" + i + ", this, true);\">";
			else
				layerStr  = "<div id=\"" + layerName + "\" style=\"position=relative; z-index:99; left:0px; width:146px;\" onMouseOver=\"hiLite(" + i + ", this, true);\" onMouseOut=\"hiLite(" + i + ", this, false);\">";
		}
		else
		{
			layerStr  = "<div id=\"" + layerName + "\" style=\"position=relative; z-index:99; left:0px; width:146px;\">";
		}
		layerStr += "<table id=\"" + tabName + "\" height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
		layerStr += "<tr valign=\"middle\">";
		layerStr += "<td width=\"14\" valign=\"middle\">";
		if (hasChildren(i))
		{
			if (i == menuItemPos)
			{
				layerStr += "&nbsp<img id=\"Img1\" src=\"" + imagePath + "arrowrtwht2(roll).gif\" border=\"0\" width=\"8\" height=\"8\" align=\"middle\">";
			}
			else
			{
				layerStr += "&nbsp<img id=\"Img1\" src=\"" + imagePath + "arrowrtwht2.gif\" border=\"0\" width=\"8\" height=\"8\" align=\"middle\">";
			}

		}
		else
		{
			layerStr += "&nbsp;";
		}
		layerStr += "</td>";
		layerStr += "<td width=\"125\" align=left valign=\"middle\">";
		if (mainMenus[i][3].length > 0)
		{
		    layerStr += "<a class=aorange href=\"" + mainMenus[i][3] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
		    layerStr += mainMenus[i][0];
		    layerStr += "</a>";
		}
		else
		{
			layerStr += mainMenus[i][0];
		}
		layerStr += "</td>";
		layerStr += "</tr>";
		layerStr += "</table>";
		layerStr += "</div>";
		layerStr += "<div id=\"dummy\" style=\"position=relative; left:0px; width:146px;\"><img id=\"Img1\" src=\"" + imagePath + "sitenav.gif\" border=\"0\" width=\"146\" height=\"" + menuPadding + "\"></div>";
		document.all["mainMenu"].insertAdjacentHTML("beforeEnd", layerStr);

		if (i == menuItemPos)
		{
			if (hasChildren(i))
			{
				for (var menuPos = 0; menuPos < MaxMainMenuItems && rollDownMenus[loc][menuPos][0] != "end"; menuPos++)
				{
					subLayerName = "mainSubMenu" + i + "_" + menuPos;
					if (rollDownMenus[loc][menuPos][1].length > 0)
					{
						if (mRollItem - 1 == menuPos)
							layerStr  = "<div id=\"" + subLayerName + "\" style=\"position=relative; left:0px; width:146px;\" onMouseOver=\"hiLite(-3, this, true);\">";
						else
							layerStr  = "<div id=\"" + subLayerName + "\" style=\"position=relative; left:0px; width:146px;\" onMouseOver=\"hiLite(-3, this, true);\" onMouseOut=\"hiLite(-3, this, false);\">";
					}
					else
						layerStr  = "<div id=\"" + subLayerName + "\" style=\"position=relative; left:0px; width:146px;\">";
					layerStr += "<table height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
					layerStr += "<tr>";
					layerStr += "<td width=\"17\">";
					layerStr += "&nbsp;";
					layerStr += "</td>";
					layerStr += "<td width=\"125\" align=left>";
					if (rollDownMenus[loc][menuPos][1].length > 0)
					{
						layerStr += "<a class=apopup href=\"" + rollDownMenus[loc][menuPos][1] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
						layerStr += rollDownMenus[loc][menuPos][0];
						layerStr += "</a>";
					}
					else
					{
						layerStr += rollDownMenus[loc][menuPos][0];
					}
					layerStr += "</td>";
					layerStr += "</tr>";
					layerStr += "</table>";
					layerStr += "</div>";
					layerStr += "<div id=\"dummy\" style=\"position=relative; left:0px; width:146px;\"><img id=\"Img1\" src=\"" + imagePath + "sitenav.gif\" border=\"0\" width=\"146\" height=\"" + menuPadding + "\"></div>";
					document.all["mainMenu"].insertAdjacentHTML("beforeEnd", layerStr);
					if (mRollItem - 1 == menuPos)
					{
						document.all(subLayerName).style.backgroundColor = overMainSubColor;
						highlightMainSubCode = document.all(subLayerName).style.backgroundColor;
					}
				}
			}
			document.all(layerName).style.backgroundColor = overColor;
			highlightCode = document.all(layerName).style.backgroundColor;
		}
		if (hasChildren(i)) loc += 1;
	}

	var heightOffset = 0;

	renderSubMenus_ie();

	if (menuItemPos > 0 && hasChildren(menuItemPos))
		disablePopup(menuItemPos);

}

function renderSubMenus_ie()
{
	loc = 1;
	for (var i = 0; i < MaxMainMenuItems && mainMenus[i][0] != "end"; i++)
	{
		if (mainMenus[i][1] == true)
		{
			menuTopTick = document.all("mainMenu").offsetTop + document.all("mainMenu" + i).offsetTop;
			layerName = "subMenu" + i;
			layerStr  = "<div id=\"" + layerName + "\" style=\"position=absolute; top:" + menuTopTick + "; left:150px; width:146px; visibility: visible; background-color:#ffcc33;\" onMouseOver=\"hiLiteSubMenus(" + i + ", true)\" onMouseOut=\"hiLiteSubMenus(" + i + ", false)\"></div>";
			document.body.insertAdjacentHTML("beforeEnd", layerStr);
			for (var menuPos = 0; menuPos < MaxMainMenuItems && rollDownMenus[loc][menuPos][0] != "end"; menuPos++)
			{
				layerStr  = "<div id=\"subMenu" + i + "_" + menuPos + "\"style=\"position=relative; left:0px; width:146px;\" onMouseOver=\"hiLite(-2, this, true);\" onMouseOut=\"hiLite(-2, this, false);\">";
				layerStr += "<table height=20 width=100% border=0 cellpadding=0 cellspacing=" + cellSpacing + ">";
				layerStr += "<tr>";
				layerStr += "<td width=5% align=left></td>";
				layerStr += "<td width=95% align=left>";
				if (rollDownMenus[loc][menuPos][1].length > 0)
				{
					layerStr += "<a class=apopup href=\"" + rollDownMenus[loc][menuPos][1] + "\"" + " style=\"color=#003366;fontWeight=600;fontSize=8pt;fontFamily=Arial, Helvetica, sans-serif;textDecoration=none;verticalAlign=middle;\"" + ">";
					layerStr += rollDownMenus[loc][menuPos][0];
					layerStr += "</a>";
				}
				else
				{
					layerStr += rollDownMenus[loc][menuPos][0];
				}
				layerStr += "</td>";
				layerStr += "</tr>";
				layerStr += "</table>";
				layerStr += "</div>";
				document.all[layerName].insertAdjacentHTML("beforeEnd", layerStr);
			}
			document.all[layerName].style.visibility = "hidden";
			loc += 1;
		}
	}
}

function disablePopup(pos)
{
	mainMenus[pos][4] = false;
}

function hasChildren(pos)
{
	return mainMenus[pos][1];
}

function hiLite(pos, theCell, Over)
{
	if (pos >= 0 && mainMenus[pos][4] == true)
	{
		hiLiteSubMenus(pos, Over);
	}
	hiLiteItem(pos, theCell, Over);
}

function hiLiteItem(pos, theCell, Over)
{
	var isSubMenu     = false;
	var isMainSubMenu = false;
	if (pos == -2) isSubMenu     = true;
	if (pos == -3) isMainSubMenu = true;
	if (ns && theCell.name.substr(0,3) == "sub")     isSubMenu = true;
	if (ns && theCell.name.substr(0,7) == "mainSub") isMainSubMenu = true;

	var oColor = overColor;
	var shouldHighLight = false;
	if (!isSubMenu && !isMainSubMenu)
	{
		if (mainMenus[pos][3].length > 0)
		{
			shouldHighLight = true;
		}
	}
	if (isSubMenu)
	{
		if (ns)
			id = theCell.name.substr(7);
		else
			id = theCell.id.substr(7);
		menuPos  = id.split("_");
		layerName = "mainMenu" + menuPos[0];
		if (ns)
			mainCell = document.layers["mainMenu"].document.layers[layerName];
		else if (ie)
			mainCell = document.all(layerName);
		else
			mainCell = document.getElementById(layerName);		
		hiLiteItem(menuPos[0], mainCell, Over);
		oColor = overSubColor;
		for (position = 0, i = 1; i <= menuPos[0]; i++)
		{
			if (mainMenus[i][1]) position++;
		}
		if (rollDownMenus[position][menuPos[1]][1].length > 0) shouldHighLight = true;
	}
	if (isMainSubMenu)
	{
		oColor = overMainSubColor;
		if (ns)
			id = theCell.name.substr(11);
		else
			id = theCell.id.substr(11);
		menuPos  = id.split("_");
		for (position = 0, i = 1; i <= menuPos[0]; i++)
		{
			if (mainMenus[i][1]) position++;
		}
		if (rollDownMenus[position][menuPos[1]][1].length > 0) shouldHighLight = true;
	}

		
	if (Over)
	{
		if (shouldHighLight)
		{
			if (ns)
			{
				if (theCell.bgColor == null) 
					theCell.bgColor = oColor;
			}
			else
			{
				if (theCell.style.backgroundColor != highlightColor && theCell.style.backgroundColor != highlightMainSubColor)
					theCell.style.backgroundColor = oColor;
			}
		}
	}
	else
	{
		if (ns)
		{
			theCell.bgColor = null;
		}
		else if (ie)
		{
			theCell.style.backgroundColor = "";
		}
		else if (pos == -2)
			theCell.style.backgroundColor = subBGColor;
		else
			theCell.style.backgroundColor = "transparent";
	}
}

function hiLiteSubMenus(pos, Over)
{
	layerName = "subMenu" + pos;
	if (Over)
	{
		if (ns)
		{
			adjustSubMenuStart(layerName, pos);
			document.layers[layerName].visibility = "show";
		}
		else if (ie)
		{
			adjustSubMenuStart(layerName, pos);
			document.all(layerName).style.visibility = "visible";
			rollDownClose[pos] = "";
		}
		else
		{
			adjustSubMenuStart(layerName, pos);
			document.getElementById(layerName).style.visibility = "visible";
			rollDownClose[pos] = "";
		}
	}
	else
	{
		if (ns)
		{
			document.layers[layerName].visibility = "hide";
		}
		else if (ie)
		{
			rollDownClose[pos] = "close";

			runStr = "hideSubMenus_ie(" + pos + ")";
			setTimeout(runStr, delay);
		}
		else
		{
			rollDownClose[pos] = "close";

			runStr = "hideSubMenus_ns6(" + pos + ")";
			setTimeout(runStr, delay);
		}
	}

}

function hiLiteSubMenus_force(pos, Over)
{
return;
	layerName = "subMenu" + pos;
	if (Over)
	{
		if (ns)
			document.layers[layerName].visibility = "show";
		else if (ie)
		{
			document.all(layerName).style.visibility = "visible";
		}
		else
		{
			document.getElementById(layerName).style.visibility = "visible";
		}
	}
	else
	{
		if (ns)
		{
			document.layers[layerName].visibility = "hide";
		}
		else if (ie)
		{
			document.all(layerName).style.visibility = "hidden";
		}
		else
		{
			document.getElementById(layerName).style.visibility = "hidden";
		}
	}

}

function showSubMenus_ie(pos)
{
	layerName = "subMenu" + i;
	document.all(layerName).style.visibility = "visible";
}

function showDelaySubMenus_ie(layerName)
{
	runStr = "showSubMenus_ie(\"" + layerName + "\")";
	setTimeout(runStr, delay);
}

function hideSubMenus_ns6(pos)
{
	if (rollDownClose[pos] != "")
	{
		rollDownClose[pos] = "";
		layerName = "subMenu" + pos;
		document.getElementById(layerName).style.visibility = "hidden";
	}
}

function hideSubMenus_ie(pos)
{
	if (rollDownClose[pos] != "")
	{
		rollDownClose[pos] = "";
		layerName = "subMenu" + pos;
		document.all(layerName).style.visibility = "hidden";
	}
}

function adjustSubMenuStart(layerName, pos)
{
	var pageOffset;
	var innerHeight;

	if (ie)
	{
		pageOffset  = document.body.scrollTop;
		innerHeight = document.body.clientHeight;
		mTop        = document.all("mainMenu").offsetTop + document.all("mainMenu" + pos).offsetTop;
		mHeight     = document.all(layerName).offsetHeight;
		if ((pageOffset + innerHeight) < (mTop + mHeight))
		{
			mTop = document.all("mainMenu").offsetTop + 
		       	       document.all("mainMenu" + pos).offsetTop +
		       	       document.all("mainMenu" + pos).offsetHeight -
		       	       document.all(layerName).offsetHeight;
//			if (mTop < pageOffset) mTop = pageOffset;
			if (mTop < pageOffset) 
			{
				mTop = pageOffset + innerHeight - mHeight;
			}
		}
		document.all(layerName).style.top = mTop;
	}
	else if (ns)
	{
		pageOffset  = window.pageYOffset;
		innerHeight = window.innerHeight;
		mTop        = document.layers["mainMenu"].top + 
			      document.layers["mainMenu"].layers["mainMenu" + pos].top;
		mHeight     = document.layers[layerName].clip.height;
		if ((pageOffset + innerHeight) < (mTop + mHeight))
		{
			mTop = document.layers["mainMenu"].top + 
		       	       document.layers["mainMenu"].layers["mainMenu" + pos].top + 
			       document.layers["mainMenu"].layers["mainMenu" + pos].clip.height -
			       document.layers[layerName].clip.height;
//			if (mTop < pageOffset) mTop = pageOffset;
			if (mTop < pageOffset) 
			{
				mTop = pageOffset + innerHeight - mHeight;
			}
		}
		document.layers[layerName].top = mTop;
	}
	else
	{
		pageOffset  = window.pageYOffset;
		innerHeight = window.innerHeight;
		mTop        = document.getElementById("mainMenu").offsetTop + document.getElementById("mainMenu" + pos).offsetTop;
		mHeight     = document.getElementById(layerName).offsetHeight;
		if ((pageOffset + innerHeight) < (mTop + mHeight))
		{
			mTop = document.getElementById("mainMenu").offsetTop + 
		       	       document.getElementById("mainMenu" + pos).offsetTop +
		       	       document.getElementById("mainMenu" + pos).offsetHeight -
		       	       document.getElementById(layerName).offsetHeight;
//			if (mTop < pageOffset) mTop = pageOffset;
			if (mTop < pageOffset) 
			{
				mTop = pageOffset + innerHeight - mHeight;
			}
		}
		document.getElementById(layerName).style.top = mTop + "px";
	}
}

function AddMainMenu()
{
	argv = AddMainMenu.arguments;
	argc = argv.length;

	index = 0;
	for (var i = 0; i < argc; i++) {
		mainMenus[index] = new Array();
		mainMenus[index][0] = argv[i++];
		mainMenus[index][1] = argv[i++];
		mainMenus[index][2] = argv[i++];
		mainMenus[index][3] = argv[i];
		mainMenus[index][4] = mainMenus[index][1];
		index++;
	}
	mainMenus[index] = new Array();
	mainMenus[index][0] = "end";
}

function AddPopupMenu()
{
return;
	argv = AddPopupMenu.arguments;
	argc = argv.length;

	menuPos = argv[0];
	popUpMenus[menuPos] = new Array();
	index = 0;
	for (var i = 0; i < argc; i++) {
		popUpMenus[menuPos][index] = new Array();
		popUpMenus[menuPos][index][0] = argv[i++];
		popUpMenus[menuPos][index][1] = argv[i];
		index++;
	}
	popUpMenus[menuPos][index] = new Array();
	popUpMenus[menuPos][index][0] = "end";
}

function AddRollDownMenu()
{
	argv = AddRollDownMenu.arguments;
	argc = argv.length;

	menuPos = argv[0];
	rollDownMenus[menuPos] = new Array();
	index = 0;
	for (var i = 1; i < argc; i++) {
		rollDownMenus[menuPos][index] = new Array();
		rollDownMenus[menuPos][index][0] = argv[i++];
		rollDownMenus[menuPos][index][1] = argv[i];
		index++;
	}
	rollDownMenus[menuPos][index] = new Array();
	rollDownMenus[menuPos][index][0] = "end";
}


function windowOpen(url, target, parm)
{
	window.open(url, target, parm);
}

var allLoaded = true;

