
// ---------------------------------------------------------
//    Menu Variables
// ---------------------
//    Adjust the variables in this section to make the menu
// ---------------------------------------------------------
var mArray = new Array('LinkID','LinkTxt','HREF','SubMenu') // do not edit
mArray[0]  = new Array(
'a1',//Home
'a2','a2b1','a2b2','a2b3','a2b4','a2b5','a2b6',//About Us
'a3','a3b1','a3b2','a3b3', 'a3b4',//Individual
'a4','a4b1','a4b2','a4b3','a4b4','a4b5','a4b6','a4b7',//Employers
'a4b8','a4b8c1','a4b8c2','a4b8c3','a4b8c4',//N.Y. Employers within Employers
'a5','a5b1','a5b2',//Customer Service
//'a5b3','a5b3c1','a5b3c2','a5b3c3','a5b3c4','a5b4','a5b5','a5b6',//Forms within Customer Service, plus RMD and IRA with in Customer Service
'a5b3','a5b3c1','a5b3c2','a5b3c3','a5b3c4','a5b4',//Forms within Customer Service, plus RMD and IRA with in Customer Service
'a6','a6b1','a6b2','a6b3','a6b4','a6b5','a6b6','a6b7','a6b8',//Tools
'a7','a7b1','a7b2','a7b3','a7b4','a7b5',//Careers
'a8')//Investor Info
//'Private Placement' option removed in below Array for PS#26272 on 08th April 2009 by Gajender Yadav(YD19)
mArray[1]  = new Array('Home','Company Profile','Ratings','Sales Offices','U.S. Companies','Sun Life Reinsurance','Press Office','Community<br><img src=/images/sp.gif width=14 height=7 border=0>Relations','Products for<br><img src=/images/sp.gif width=14 height=7 border=0>Individuals and<br><img src=/images/sp.gif width=14 height=7 border=0>Families','Life Insurance','Annuities','Mutual Funds','Products for<br><img src=/images/sp.gif width=14 height=7 border=0>Employers','Group Life','Group Disability','Medical Stop-Loss','Dental','Business Planning<br><img src=/images/sp.gif width=14 height=7 border=0>Products','COLI','COLI for Small Businesses','For New York<br><img src=/images/sp.gif width=14 height=7 border=0>Employers','Group Life','Group Disability','Medical Stop-Loss','Small Business<IND>Solutions','Customer Service<br><img src=/images/sp.gif width=14 height=7 border=0>and Forms','How Do I...','Contact Us','Forms','Group Insurance<IND>Forms','Group Insurance<IND>(NY) Forms','Individual Insurance<IND>Forms','Annuity Contract<IND>Forms','Required Minimum<br><img src=/images/sp.gif width=14 height=7 border=0>Distribution','Tools','Life Insurance<br><img src=/images/sp.gif width=14 height=7 border=0>Needs Calculator','Estate Tax<br><img src=/images/sp.gif width=14 height=7 border=0>Calculator','Mortgage Calculator','College Cost<br><img src=/images/sp.gif width=14 height=7 border=0>Calculator','Cost of Raising a<br><img src=/images/sp.gif width=14 height=7 border=0>Child Calculator','Rule of 38<br><img src=/images/sp.gif width=14 height=7 border=0>Calculator','Investment<br><img src=/images/sp.gif width=14 height=7 border=0>Temperament<br><img src=/images/sp.gif width=14 height=7 border=0>Questionnaire','Net Return<br><img src=/images/sp.gif width=14 height=7 border=0>Calculator','Careers','Search for Jobs','Life at<br><img src=/images/sp.gif width=14 height=7 border=0>Sun Life Financial','Benefits','College Students &<br><img src=/images/sp.gif width=14 height=7 border=0>Recent Grads','Directions','Investor<br><img src=/images/sp.gif width=14 height=7 border=0>Information')

//Relative link for 'Private Placement' option removed in below Array for PS#26272 on 08th April 2009 by Gajender Yadav(YD19)
mArray[2]  = new Array('/','/sun/','/sun/sl_8.cfm','/sun/sl_4.cfm','/sun/sl_5.cfm','/sun/sl_02.cfm','/sun/sl_12.cfm','/sun/sl_11.cfm','/indiv/','/indiv/ind_20.cfm','/indiv/ind_21.cfm','/indiv/ind_23.cfm', '/group/','/group/grp_2.cfm','/group/grp_11.cfm','/group/grp_20.cfm','/group/grp_26_dental.cfm','/group/grp_36.cfm','/group/grp_39.cfm','/group/grp_42.cfm','/group/newyork/index.cfm','/group/newyork/grp_NY_1.cfm','/group/newyork/grp_NY_2.cfm','/group/newyork/grp_NY_3.cfm','/group/newyork/grp_NY_4.cfm','/univ/un_6.cfm','/univ/un_4.cfm','/sun/sl_3.cfm','/univ/un_5.cfm','/univ/un_8.cfm','/univ/un_9.cfm','/univ/un_10.cfm','/univ/un_11.cfm','/go/rmd','/tool/','/tool/tl_9.cfm','/tool/tl_2.cfm','/tool/tl_3.cfm','/tool/tl_4.cfm','/tool/tl_5.cfm','/tool/tl_15.cfm','/tool/tl_11.cfm','/tool/tl_12.cfm','/careers/index.cfm','Javascript:applynow()','/careers/lifeAtSun.cfm','/careers/benefits.cfm','/careers/college.cfm','/careers/directions.cfm','Javascript:investorinfo()')

mArray[3]  = new Array(
0, //Home
1,0,0,0,0,0,0, //About Us
1,0,0,0, //Individual
1,0,0,0,0,0,0,0,//Employers
1,0,0,0,0, //N.Y. Employers within Employers
1,0,0,//Customer Service
//1,0,0,0,0,0,0,0, //Forms within Customer Service, plus RMD and IRA with in Customer Service
1,0,0,0,0,0, //Forms within Customer Service, plus RMD and IRA with in Customer Service
1,0,0,0,0,0,0,0,0, //Tools
1,0,0,0,0,0, //Careers
0) //Investor Info

var maxSub = 3 //this is the maximum submenu depth (count from 0) this could become a calculation


// ---------------------------------------------------------
//    Immediate Scripts
// ---------------------------------------------------------

// set up the hilight Array
var hilightArray = new Array()
for (var i=0; i<=maxSub; i++) {
	hilightArray[i] = null
}
// openItem is initially set to '' - to set the open Item,
// set this variable equal to the item ID in the HTML file,
// after this script file is called
var openItem = ''


// ---------------------------------------------------------
//    Menu Equivalency Statements
// ---------------------------------------------------------

// writeMenu globals
mStyle      = (NS4) ? 'CLASS="nsDx"' : '';
subImg      = '/images/arrowrtwht2.gif'
subImgOn    = '/images/arrowrtwht2_on.gif'
spImg       = '/images/sp.gif'
nsFirst     = ' CLASS="nsFirst"'
nsSecond    = ' CLASS="nsOrange"'
isOpenStart = (NS4) ? '<TR><TD>' : '';
isOpenEnd   = (NS4) ? '</TD></TR>' : '';

// doHilight image Path
subBkgd   = (NS4) ? '/images/bg_yellow.gif' : 'url("/images/bg_yellow.gif")'


// ---------------------------------------------------------
//    Menu Functions
// ---------------------------------------------------------

// shows menu
function showMenu (mID) {
	clearTimeout(timeID)
	mL = mID.length
	isOpenItem = (openItem.substr(0,mL)==mID)
	isOpenTree = (mL>2) ? (openItem.substr(0,mL-2)==mID.substr(0,mL-2)) : isOpenItem ;
	mLevel = ((openItem!=null)&&(!isOpenTree))||(mL<=2) ? (mL/2) - 1 : 0 //(mL/2) - 2
	//objID is the item that is rolled over
	objID = (NS4) ? 'level' + mLevel + '.document.' : ''
	theObjRef = gDivRef + objID + mID
	theObj = eval(theObjRef)

	
	curObjRef = hilightArray[mLevel]
	// the following will force the submenu to turn off if on the base level
	isSubOnMain = 0
	if ((openItem == mID) && (mL>2)) { isSubOnMain = 1 }
	
	// turn off the current highlight
	if (curObjRef != null) {
		curObj = eval(curObjRef)
		doHilight (curObj, 0, mLevel)
		closeLevels(mLevel)
	}
	// set the new item in the array
	if (!isOpenItem || isSubOnMain) { 
		hilightArray[mLevel] = theObj
		doHilight (theObj, 1, mLevel, isOpenTree)
	}
		
if (!isOpenItem) {
	// Detect if there is a subMenu
	for (x in mArray[0]) {
		if (mArray[0][x] == mID && mArray[3][x] == 1) { // there is a sub-menu
			theDocRef = gDivRef + 'level' + (mLevel+1) // these are at the doc root
			theDocObj = eval(theDocRef)
			
			if (NS4) {
				theDocObj.document.open('text/html');
				txt = writeMenu(mID)
				theDocObj.document.write(txt);
				theDocObj.document.close();
				theDocObj.bgColor="#FFCC00"
				
				// page coordinates
				y = theObj.pageY
				x = theObj.pageX 
				w = theObj.clip.width
						
			} else {
          
				theDocObj.innerHTML = '';
				theDocObj.innerHTML = writeMenu(mID)

				// coordinates local to previous level div
				y = eval(theObjRef + '.offsetTop') - 4// original placement
				if ((mLevel > 0)) {
					y += eval(theObjRef + '.offsetParent.offsetTop')   
				}
				x = theObj.offsetParent.offsetLeft
				w = theObj.offsetWidth
			}
			
			// Position the Popup
			rPos = (NS4) ? x + w + 4 : x + w + 4 // add 8 for NS table padding
			eval(theDocRef + gStyle + '.left = ' + rPos);
			eval(theDocRef + gStyle + '.top = ' + y);
			eval(theDocRef + gStyle + '.visibility="' + gVisible + '"');
			
			break
		}
	}
}
}

// ---------------------------------------------------------
// hides menu

function hideMenu() {
	timeID = setTimeout('closeLevels(0)', 1000)
}


function doHilight (theObj, state, mLevel, isOpenTree) {
	if (isOpenTree) { // sub menu on base level
		// always level 0
		hil = state ? '#FAEEBB' : trsp	
		if (NS4) {
			theObj.bgColor = hil
		} else {
			theObj.style.backgroundColor = hil
		}

	} else if (mLevel == 0) { // base menu
		hil = state ? '#FFCC00' : trsp
		if (NS4) {
			theObj.bgColor = hil
		} else {
			theObj.style.backgroundColor = hil
		}
	} else { // submenu
		if (NS4) {
			hil = state ? subBkgd : null
			theObj.background.src = hil
		} else {
			hil = state ? subBkgd : 'none'
			theObj.style.backgroundImage = hil
		}
	}
}


function closeLevels (startLevel) {
	// turn off the current highlight
	curObjRef = hilightArray[startLevel]
	if (curObjRef != null) {
		curObj = eval(curObjRef)
		doHilight (curObj, 0, startLevel)
		hilightArray[startLevel] = null
		//closeLevels(startLevel)
		for (var i = startLevel+1; i<= maxSub; i++) {
			theDocRef = gDivRef + 'level' + i // these are at the doc root
			eval(theDocRef + gStyle + '.visibility="' + gHidden + '"');
			hilightArray[i] = null
		}
	}
}
function BC_rplc(inTxt, mLevel, isRecurse) {
	if (inTxt.indexOf('<IND>') != -1) {
		wd = (isRecurse==null) ? 2 : mLevel + 1
		outTxt  = inTxt.substring(0,inTxt.indexOf('<IND>'))
		outTxt += '<BR><IMG SRC="' + spImg + '" ALIGN="baseline" VSPACE="0" BORDER="0" WIDTH="'+(wd*7)+'" HEIGHT="7">'
		outTxt += inTxt.substring(inTxt.indexOf('<IND>'),inTxt.length)
		return outTxt
	} else {
		return inTxt
	}
}			
function writeMenu(cID,isRecurse) {
	var txt  = ""
	var mLinkNum = 0
	var mLevel = (cID.length/2)
	var m = String.fromCharCode(97+mLevel)
	for (x in mArray[0]) {
		if (doLink(cID, mArray[0][x], m)) {
			//var isOpen = (mArray[0][x]==openItem.substr(0,mLevel+2)) // v1
			var isOpen = (mArray[0][x]==openItem.substr(0,(2*mLevel)+2))
			mLinkNum++
			var mID = cID + m + mLinkNum
			var mDiv = '<DIV ID="' + mID + '" ' + mStyle
			var mLink  = '<A HREF="' + mArray[2][x] + '"'
			var mJS  = ' onMouseOver="showMenu(\'' + mID + '\')" onMouseOut="hideMenu()"'
			var cImg = (mArray[3][x]) ? ((isOpen) ? subImgOn : subImg) : spImg;
			var mImg = ""
			if ((mLevel > 1)&&isRecurse) {
				mImg += '<IMG SRC="' + spImg + '" ALIGN="baseline" VSPACE="0" BORDER="0" WIDTH="'+((mLevel-1)*7)+'" HEIGHT="7">'
			}
			mImg += '<IMG SRC="' + cImg + '" ALIGN="baseline" VSPACE="0" BORDER="0" WIDTH="14" HEIGHT="7">'
			var mLinkText = mImg + BC_rplc(mArray[1][x], mLevel, isRecurse)

			if (NS4) {
				txtStyle = (mLevel > 0) ? nsSecond : nsFirst
				// NETSCAPE : DIV + LINK + JS + SPACER
				txt += '<TR><TD>' + mDiv + '>' + mLink + mJS + txtStyle + '>'
				txt += '<IMG SRC="/images/sp.gif" BORDER="0" WIDTH="7" HEIGHT="1">' + mLinkText
				txt += '<\/A>'
				txt += '<BR><IMG SRC="/images/sp.gif" BORDER="0" WIDTH="147" HEIGHT="3">' //NS width only works with this at the end
				txt += '<\/DIV></TD></TR>'
	
			} else {
				mClass = (mLevel > 0) ? 'jorange' : 'jfirst'
				// IE : LINK + DIV + JS
				txt += mLink + '>' + mDiv + mJS + ' CLASS="' + mClass + '">' + mLinkText
				txt += '<\/DIV><\/A>'
			}
			//if link is "on", write the menu below the link.
			if (isOpen) {
				txt += isOpenStart + writeMenu(mArray[0][x],1) + isOpenEnd
			}
			
		}
	}
	if (NS4) {
		
		txt = '<TABLE BORDER="0" WIDTH="147" CELLPADDING="0" CELLSPACING="0">' + txt + '</TABLE>'
	}
	return txt
}

function doLink(cID, dbItem, m) {
	// detect if the items in the array start with the current Item
	if ((dbItem.indexOf(cID + m) != -1) && (dbItem.length-2 == cID.length)) {
		return true
	}
	return false
}

function writeDiv() {
	txt = ''
	for (var i = 1; i <= maxSub; i++) {
		txt += '<DIV ID="level' + i + '" STYLE="position:absolute; visibility:hidden;'
		if (IE4) {
			txt += ' z-index=' + (500+i) + '; background-color:#FFCC00; width:147'
		}
		txt += '"><\/DIV>\n'
	}
	return txt
}


function initMenu() {

if (NS4) {
		document.level0.top = 126 // 71(table)+9(image)+46(stock ticker)
	}
	subMenu=0//
	for (var i=2; i<=openItem.length; i++) {
		
		objID = (NS4) ? 'level0.document.' : ''
		theObjRef = gDivRef + objID + openItem.substr(0,i)
		theObj = eval(theObjRef)
		doHilight (theObj, 1, 0, subMenu)
		subMenu=1 // after the first time we are into submenus
		i++ // increment by 2 each loop
	}
	eval(gDivRef + 'level0' + gStyle + '.visibility = "' + gVisible + '"')
}