// ---------------------------------------------------------
//    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','a2','a2b1','a2b2','a2b3','a2b4','a2b5','a2b6','a2b7','a3','a4','a4b1','a4b2','a4b3','a4b4','a4b5','a4b6','a5','a5b1','a5b2','a5b3','a5b4','a5b5','a6','a6b1','a6b2')
if (NS4) {
  mArray[1]  = new Array('Home','About Us','Philippines Profile','Corporate Information','Mission Vision Values','Company History','Service Networks','Social Responsibility','Worldwide Operations','Investor Information','Products','Individual Insurance','Variable Life Insurance','Group Insurance','Mutual Funds','Pre-Need Plans','Co-Branded Products','FAQS','Individual Insurance','Variable Life Insurance','Group Insurance','Mutual Funds','Pre-Need Plans','Career<br><img src=http://www.jobstreet.com.ph/pic/impact/sunlife/sp.gif width=21 height=7 border=0>Opportunities','Current Openings','Apply OnLine')
}
if (IE4) {
  mArray[1]  = new Array('Home','About Us','Philippines Profile','Corporate Information','Mission Vision Values','Company History','Service Networks','Social Responsibility','Worldwide Operations','Investor Information','Products','Individual Insurance','Variable Life Insurance','Group Insurance','Mutual Funds','Pre-Need Plans','Co-Branded Products','FAQS','Individual Insurance','Variable Life Insurance','Group Insurance','Mutual Funds','Pre-Need Plans','Career<br><img src=http://www.jobstreet.com.ph/pic/impact/sunlife/sp.gif width=21 height=7 border=0>Opportunities','Current Openings','Apply OnLine')
}
mArray[2]  = new Array('http://www.sunlife.com.ph/','http://www.sunlife.com.ph/aboutus/profile.asp','http://www.sunlife.com.ph/aboutus/profile.asp','Javascript:corporateinfo()','http://www.sunlife.com.ph/aboutus/core.asp','http://www.sunlife.com.ph/aboutus/history.asp','http://www.sunlife.com.ph/aboutus/servicenet.asp','http://www.sunlife.com.ph/aboutus/social.asp','Javascript:worldwide()','Javascript:investorinfo()','http://www.sunlife.com.ph/insurance/individual.asp','http://www.sunlife.com.ph/insurance/individual.asp','http://www.sunlife.com.ph/vul/default.asp','http://www.sunlife.com.ph/insurance/group.asp','http://www.sunlife.com.ph/mutualfunds/default.asp','http://www.sunlife.com.ph/preneed/default.asp','http://www.sunlife.com.ph/products/credit.asp','http://www.sunlife.com.ph/faqs/faqs-default.asp','http://www.sunlife.com.ph/faqs/faqs.asp','http://www.sunlife.com.ph/faqs/faqs-vul.asp','http://www.sunlife.com.ph/faqs/faqs-group.asp','http://www.sunlife.com.ph/faqs/faqs-slamc.asp','http://www.sunlife.com.ph/faqs/faqs-slfpi.asp','http://impactdemo.jobstreet.com/Templates/SunlifePH/sunlife.htm','http://impact-ph.jobstreet.com/jobs/jobs.asp?eid=1482962','http://impactdemo.jobstreet.com/Forms/apply.asp?aid=1404&jid=10606&did=0&its=1&src=8&apply=Deposit+Resume')
mArray[3]  = new Array(0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0)

var maxSub = 1 //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      = 'http://www.jobstreet.com.ph/pic/impact/sunlife/arrowrtwht2.gif'
subImgOn    = 'http://www.jobstreet.com.ph/pic/impact/sunlife/arrowrtwht2_on.gif'
spImg       = 'http://www.jobstreet.com.ph/pic/impact/sunlife/sp.gif'
nsFirst     = ' CLASS="nsFirst"'
nsSecond    = ' CLASS="nsOrange"'
isOpenStart = (NS4) ? '<TR><TD>' : '';
isOpenEnd   = (NS4) ? '</TD></TR>' : '';

// doHilight image Path
subBkgd   = (NS4) ? 'http://www.jobstreet.com.ph/pic/impact/sunlife/bg_yellow.gif' : 'url("http://www.jobstreet.com.ph/pic/impact/sunlife/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 : (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]) {


var obj = document.getElementById("PopupDiv");
if (obj) {


		if 		(mID=='a2'||mID=='a2b1'||mID=='a2b2'||mID=='a2b3'||mID=='a2b4'||mID=='a2b5'||mID=='a2b6'||mID=='a2b7'||
		mID=='a4'||mID=='a4b1'||mID=='a4b2'||mID=='a4b3'||mID=='a4b4'||mID=='a4b5'||mID=='a4b6'||
		mID=='a5'||mID=='a5b1'||mID=='a5b2')
		{

				DivSetVisible(true);}

}



		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 MID is in the group of a2, a4, a5, then display div layer to hide jump menu
			//if (mID.charAt(0)=='a'&&(mID.charAt(1)=='2'||mID.charAt(1)=='4'||mID.charAt(1)=='5')){
			//	alert("true");

			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') // 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)', 100);
	//divTime = setTimeout('DivSetVisible(false)',1500);

   var obj = document.getElementById("PopupDiv");
   if (obj) {
	DivSetVisible(false);
   }
}


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 writeMenu(cID) {
	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))
			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 = '<IMG SRC="' + cImg + '" ALIGN="baseline" VSPACE="0" BORDER="0" WIDTH="14" HEIGHT="7">'
			var mLinkText = mImg + mArray[1][x]

			if (NS4) {
				txtStyle = (mLevel > 0) ? nsSecond : nsFirst
				// NETSCAPE : DIV + LINK + JS + SPACER
				txt += '<TR><TD>' + mDiv + '>' + mLink + mJS + txtStyle + '>'
				txt += '<IMG SRC="http://www.jobstreet.com.ph/pic/impact/sunlife/sp.gif" BORDER="0" WIDTH="7" HEIGHT="1">' + mLinkText
				txt += '<\/A>'
				txt += '<BR><IMG SRC="http://www.jobstreet.com.ph/pic/impact/sunlife/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]) + 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 + '"')
}



function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
	
function investorinfo()
{
MM_openBrWindow('http:/' + '/' + 'www.sunlife.com/slcorp/genericpage/0,3324,bGFuZy1lbmdsaXNoX3NpdGUtc2xjb3JwX2Vudi1saXZlX3B6bi1nZW5lcmljX3NlYy0xOF9zdGF0LV9lZC1fbmF2LTMzMzU0,00.html','investor','')
}

function corporateinfo()
{
MM_openBrWindow('http:/' + '/' + 'www.sunlife.com/slcorp/genericpage/0,3324,bGFuZy1lbmdsaXNoX3NpdGUtc2xjb3JwX2Vudi1saXZlX3B6bi1nZW5lcmljX3NlYy0xOF9zdGF0LV9lZC1fbmF2LTMzMzE5,00.html','corporate','')
}

function worldwide()
{
MM_openBrWindow('http:/' + '/' + 'www.sunlife.com/slcorp/genericpage/0,3324,bGFuZy1lbmdsaXNoX3NpdGUtc2xjb3JwX2Vudi1saXZlX3B6bi1nZW5lcmljX3NlYy0xOF9zdGF0LV9lZC1fbmF2LTMzMzgy,00.html','worldwide','')
}

function sunlink()
{
MM_openBrWindow('/services/sharedsunlink/sunlinkredirect.asp','sunlink','width=798,height=480,top=25,left=0,scrollbars=yes,status=yes,resizable=yes,toolbar=no,location=no')
}

function groupPortal()
{
MM_openBrWindow('/group/gripredirect.asp','b2b','')
}

