//variables:
sp = "<img src='http://www.sunlife-usa.com/images/sp.gif'>";
spHide = "<img src='http://www.sunlife-usa.com/images/sp.gif' border=0 width=100 height=100>";
MacIE = false;
if (navigator.userAgent.indexOf("Mac") > -1 && navigator.appName == "Microsoft Internet Explorer"){
	MacIE = true;
}
totalMainMenus = 0;
coloredSpace = "<td bgcolor='03346F'>" + sp + "</td>";
coloredSpaceRow = "<tr><td bgcolor='03346F' colspan=3>" + sp + "</td></tr>";
NS4menuWidth = 150;
thisLayer = "";
initSubObject = true;
curtop = 0;
ns = (document.layers)? true:false
ie = (document.all)? true:false
ns6 = (navigator.appName == "Netscape" && document.getElementById)? true:false

//functions:
function hide(id){
	if(ns){
		document.layers[id].visibility = "hide";
	}else if (ns6){
		var obj = eval("document.getElementById('" + id + "')");
		obj.style.visibility = "hidden";
	}else if(ie){
		document.all[id].style.visibility = "hidden";
	}
}
function show(id){
	if (ns) document.layers[id].visibility = "show"
	if (ns6){
		var obj = eval("document.getElementById('" + id + "')")
		obj.style.visibility = "visible"
	}
	else if (ie) document.all[id].style.visibility = "visible"
}
function navBar(ele,state,doNothing,bgcolor){
	if(doNothing == 0){
		if(state == 1){
			ele.style.backgroundColor = '#FFCC33';
			ele.style.color = '#03346F';
		}else{
			ele.style.backgroundColor = bgcolor;
			ele.style.color = '#03346F';
		}
	}
}
function focusSub(L){
	for( i = 1; i <= totalMainMenus; i ++ ){
		if( i == L ){
			show("subMenu" + i);
		}else{
			hide("subMenu" + i);
		}
	}
	show("bigHide");
}
function hideItAll(){
	for(i = 1; i <= totalMainMenus; i++){
		hide("subMenu" + i);
	}
	hide("bigHide");
}
function makeObject(displayText,Lid,golink){
	totalMainMenus ++;
	if(Lid == FOCUS_MAIN){
		theClass = "Focus";
		sendFocus = ",1";
		bgcolor = "FFCC33";
	}else{
		theClass = "";
		sendFocus = ",0";
		bgcolor = "ffffff";
	}
	if(ns){
		outHtml = "<td><table border=0 cellpadding=0 cellspacing=0>" + coloredSpaceRow + "<tr>" + coloredSpace + "<td><ilayer id='mainMenu" + Lid + "'><layer class='navNS' bgcolor='" + bgcolor + "' onMouseOver=\"this.bgColor = '#FFCC33'; focusSub(" + Lid + ");\" onMouseOut=\"this.bgColor = '" + bgcolor + "';\"><a href=\"" + golink + "\" ><font size=1 color='03346F'>" + displayText + "</font></a></layer></ilayer></td>" + coloredSpace + "</tr>" + coloredSpaceRow + "</table></td><td>&nbsp;</td></td>";
	}else{
		outHtml = "<td class=\"nav" + theClass + "\" id='mainMenu" + Lid + "' onMouseOver=\"navBar(this,1" + sendFocus + ");focusSub(" + Lid + ");\" onMouseOut=\"navBar(this,0" + sendFocus + ",'ffffff');\" nowrap><a href=\"" + golink + "\">" + displayText + "</a></td>";
	}
	document.write(outHtml);
}
function findPosX(obj){
	var curleft = 0;
	while (obj.offsetParent){
		curleft += obj.offsetLeft
		obj = obj.offsetParent;
	}
	return curleft;
}
function makeSubObject(){
	if(ns){
		for(n = 1; n <= totalMainMenus; n ++){
			thisSub = eval("sub" + n);
			if(thisSub.length == 0 && n > 1){
				thisLayer += "<div id='subMenu" + n + "' style=\"position:absolute; left:0px; top:0px; visibility:hidden;\"></div>";
			}else{
				topButton = document.layers["mainMenu" + n];
				if(n == 1){
					thisLayer += "<div id='mud' style=\"position:absolute; left:0px; top:0px; visibility:hidden;\"></div>";
				}else{
					thisLayer += "<div id='subMenu" + n + "' style=\"position:absolute; left:" + topButton.pageX + "px; top:" + (topButton.pageY + 20) + "px; visibility:hidden; z-index:10;\">";
					thisLayer += "<table cellpadding=0 cellspacing=0 border=0>" + coloredSpaceRow;
					for(i = 0; i < thisSub.length; i ++){
						if(n == FOCUS_MAIN && i == FOCUS_SUB){
							bgcolor = "FFCC33";
						}else{
							bgcolor = "ffffef";
						}
						thisLayer += coloredSpace;
						thisLayer +=  "<td><ilayer><layer class='navNSsub' width=" + NS4menuWidth + "  bgcolor='" + bgcolor + "' onMouseOver=\"this.bgColor = '#FFCC33';\" onMouseOut=\"this.bgColor = '" + bgcolor + "';\"><a href=\"" + thisSub[i].goLink + "\" ><font size=1 color='000000'>" + thisSub[i].displayText + "</font></a></layer></ilayer></td>";
						thisLayer += coloredSpace + coloredSpaceRow;
					}
					thisLayer += "</table></div>";
				}
			}
		}
		if(sub1.length == 0){
			thisLayer += "<div id='subMenu1' style=\"position:absolute; left:0px; top:0px; visibility:hidden;\"></div>";
		}else{
			topButton = document.layers["mainMenu1"];
			thisLayer += "<div id='subMenu1' style=\"position:absolute; left:" + topButton.pageX + "px; top:" + (topButton.pageY + 20) + "px; visibility:hidden; z-index:10;\">";
			thisLayer += "<table cellpadding=0 cellspacing=0 border=0>" + coloredSpaceRow;
			for(i = 0; i < sub1.length; i ++){
				if(1 == FOCUS_MAIN && i == FOCUS_SUB){
					bgcolor = "FFCC33";
				}else{
					bgcolor = "ffffef";
				}
				thisLayer += coloredSpace;
				thisLayer +=  "<td><ilayer><layer class='navNSsub' width=" + NS4menuWidth + "  bgcolor='" + bgcolor + "' onMouseOver=\"this.bgColor = '#FFCC33';\" onMouseOut=\"this.bgColor = '" + bgcolor + "';\"><a href=\"" + sub1[i].goLink + "\" ><font size=1 color='000000'>" + sub1[i].displayText + "</font></a></layer></ilayer></td>";
				thisLayer += coloredSpace + coloredSpaceRow;
			}
			thisLayer += "</table></div>";
		}
		thisLayer += "<div id='bigHide' style='position:absolute;top:" + (topButton.pageY + 20) + "px;left:0px;visibility:hidden;z-index:1'><table cellpadding=0 cellspacing=0 border=0 width='100%'><tr><td><a href='#' onMouseOver='hideItAll();'><img src='http://www.sunlife-usa.com/images/sp.gif' border=0 width=766 height=360 border=0></a></td></tr></table></div>"
	}else{
		for(n = 1; n <= totalMainMenus; n ++){
			thisSub = eval("sub" + n);
			if(thisSub.length == 0){
				thisLayer += "<div id='subMenu" + n + "'></div>";
			}else{
				if (ie)
					ele = document.all("mainMenu" + n);
				else if(ns6){
					ele = document.getElementById("mainMenu" + n);
				}
				if(initSubObject){
					while (ele.offsetParent){
						curtop += ele.offsetTop;
						ele = ele.offsetParent;
					}
					curtop += 20;
					if(MacIE){
						curtop += 12;
					}
					initSubObject = false;
				}
				if (ie)
					currentEle = document.all("mainMenu" + n);
				else if(ns6){
					currentEle = document.getElementById("mainMenu" + n);
				}
				leftPos = findPosX(currentEle);
				if(MacIE){
					leftPos += 10;
				}
				thisLayer += "<div id='subMenu" + n + "' style=\"position:absolute; left:" + leftPos + "px; top:" + curtop + "px; visibility:hidden;z-index:2\">";
				thisLayer += "<table cellpadding=0 cellspacing=0 border=0><tr><td bgcolor='#999999'>" + sp + "</td></tr>";
				for(i = 0; i < thisSub.length; i ++){
					if(n == FOCUS_MAIN && i == FOCUS_SUB){
						theClass = "Focus";
						sendFocus = ",1";
					}else{
						theClass = "";
						sendFocus = ",0";
					}
					thisLayer += "<tr class='subNavRow'><td class='navSub" + theClass + "' onMouseOver=\"navBar(this,1" + sendFocus + ");\" onMouseOut=\"navBar(this,0" + sendFocus + ",'ffffef');\"><a href='" + thisSub[i].goLink + "'><font color='000000'>" + thisSub[i].displayText + "</font></a></td></tr>";
				}
				thisLayer += "</table></div>";
			}
		}
		thisLayer += "<div id='bigHide' style='position:absolute;top:" + curtop + "px;left:0px;visibility:hidden;z-index:1'><table cellpadding=0 cellspacing=0 border=0 width='100%'><tr><td onMouseOver=\"hideItAll();\"><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br></td></tr></table></div>"
	}
	document.write(thisLayer);
}
function subMenuItem(displayText,goLink){
	this.displayText = displayText;
	this.goLink = goLink;
}