/* ***************************************************************************
Add event function
***************************************************************************** */
function addEvent(elm, evType, fn, useCapture) {
  // cross-browser event handling for IE5+, NS6 and Mozilla
  // By Scott Andrew
  if (elm.addEventListener) {
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent) {
    var r = elm.attachEvent('on' + evType, fn);
    //EventCache.add(elm, evType, fn);
    return r;
  } else {
    elm['on' + evType] = fn;
  }
}

function formRules() {
	var aPrint = document.getElementById('aPrintMe');
	addEvent(aPrint, 'click', function(){window.print()}, false);
}

function fontSizes() {
	var aFplus = document.getElementById('aToolF3');
	var aFminus = document.getElementById('aToolF1');
	var aFreg = document.getElementById('aToolF2');
	//if((!aFplus)||(!aFminus)||(!aFreg)) return;
	if((!aFplus)||(!aFreg)) return;
	addEvent(aFplus, 'click', increaseFont, false);
	//addEvent(aFminus, 'click', decreaseFont, false);
	addEvent(aFreg, 'click', fontNormal, false);
}

function decreaseFont(e) {
	var allDivs = document.getElementsByTagName('div');
		for(d=0; d<allDivs.length; d++) {
			if (allDivs[d].className =="divFont") {
			var theDivF = allDivs[d];
			}
		}
		if(!theDivF) return;
	
    if(theDivF.style.fontSize && theDivF.style.fontSize=="11pt") {
    theDivF.style.fontSize = 9+"pt";
	} 
	// stop the links from working
	if (window.event) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else if (e) {
		e.stopPropagation();
		e.preventDefault();
	}  
}	

function increaseFont(e) {
	var allDivs = document.getElementsByTagName('div');
		for(d=0; d<allDivs.length; d++) {
			if (allDivs[d].className =="divFont") {
			var theDivF = allDivs[d];
			}
		}
		if(!theDivF) return;
		
      if(theDivF.style.fontSize) {
         var s = parseInt(theDivF.style.fontSize.replace("em",""));
		 s = 11
      } else {
         s = 11;
      }
      theDivF.style.fontSize = s+"pt";
	// stop the links from working
	if (window.event) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else if (e) {
		e.stopPropagation();
		e.preventDefault();
	}  
}

function fontNormal(e) {
	var allDivs = document.getElementsByTagName('div');
		for(d=0; d<allDivs.length; d++) {
			if (allDivs[d].className =="divFont") {
			var theDivF = allDivs[d];
			}
		}
		if(!theDivF) return;
		      
      theDivF.style.fontSize = 9+"pt";
	// stop the links from working
	if (window.event) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else if (e) {
		e.stopPropagation();
		e.preventDefault();
	}  
}	

function clickNdrop() {
	var aLoginB = document.getElementById('aLogin');
	if (!aLoginB) return;
	addEvent(aLoginB, 'click', openClose2, false);
	var drpUL = document.getElementById('ulDrops');
	if (!drpUL) return;
	var drpLIs = drpUL.getElementsByTagName('li');
	if (!drpLIs) return;
		for (var l = 0; l < drpLIs.length; l++) {
			var LInodes = drpLIs[l].childNodes;
				for (var m = 0; m < LInodes.length; m++) {
					if (LInodes[m].nodeName.toLowerCase() == 'a') {
						addEvent(LInodes[m], 'click', openClose, false);
					}
				}
		}
}

function openClose(e) {
	if (e && e.target) {
		theA = e.target;
	}
	if (window.event && window.event.srcElement) {
		theA = window.event.srcElement;
	}
	if (!theA) return;
	var theA = ascendDOM(theA, 'a'); //make sure it's the A
	theA.className = (theA.className == "aClosed") ? "aOpen" : "aClosed";
		var theLI = ascendDOM(theA, 'li'); //make sure it's the parent LI
		var theLiNodes = theLI.childNodes;
			for (var m = 0; m < theLiNodes.length; m++) {
				if (theLiNodes[m].nodeName.toLowerCase() == 'p') {
					var theP = theLiNodes[m];
					theP.style.display = (theP.style.display == "block") ? "none" : "block";
				}
			}
	// removed the dotted lines from the link
	theA.blur();
	// stop the links from working
	if (window.event) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else if (e) {
		e.stopPropagation();
		e.preventDefault();
	}
}

function openClose2(e) {
	if (e && e.target) {
		theA = e.target;
	}
	if (window.event && window.event.srcElement) {
		theA = window.event.srcElement;
	}
	if (!theA) return;
	var theA = ascendDOM(theA, 'a'); //make sure it's the A
	
	if (theA.id=="aLogin") {
		var aRel = theA.rel;
		var showDiv = document.getElementById(aRel);
		showDiv.style.display = (showDiv.style.display == "block") ? "none" : "block";
		
		if (showDiv.style.display == "block") {
			theA.style.background = "url(./images/aLogIn_on.jpg)";
		} else if (showDiv.style.display == "none") {
			theA.style.background = "url(./images/aLogIn.jpg)";
		}
	}
	// removed the dotted lines from the link
	theA.blur();
	// stop the links from working
	if (window.event) {
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	} else if (e) {
		e.stopPropagation();
		e.preventDefault();
	}
}

function noValue(e) {
	if (e && e.target) {
		fmElement = e.target;
	}
	if (window.event && window.event.srcElement) {
		fmElement = window.event.srcElement;
	}
	if (!fmElement) return;
	if( fmElement.value)  fmElement.value = "";
}

function ascendDOM(e, target) {
	while (e.nodeName.toLowerCase() != target && e.nodeName.toLowerCase() != 'html') {
		e = e.parentNode;
	}
	return (e.nodeName.toLowerCase() == 'html')? null : e;
}

/* *****************************************************************************
Simon Willison's addLoadEvent function allows you to stack up 'window.onload' events 
without them stepping on each other's toes. 
It's explained here - http://www.sitepoint.com/blog-post-view.php?id=171578
***************************************************************************** */
function addLoadEvent(func)
{
	var oldonload = window.onload;
	if(typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function()
		{
			oldonload();
			func();
		}
	}
}

/* *****************************************************************************
// Initialize list of onload functions
/* ************************************************************************** */
addLoadEvent(function() { 
	var  foreseeURL = window.location.href;
	
	formRules();
	clickNdrop();
	fontSizes();
	initNav();
	getURL();
	
	if ((foreseeURL).indexOf('/csso/') != -1){
		//csso is in the path -- do not include the foresee survey
	} else {
		//Poll();
	}
	
	load();
});
/* ************************************************************************** */

/* ----- mmcom.js */

/* ***************************************************************************
	massmutual.com js functions
***************************************************************************** */
var thisbrowser = "";

function whatbrowser() {
	if (document.layers){
		// Netscape 4
    	thisbrowser="NN4";
	}
	if (document.all){
		// Internet Explorer
    	thisbrowser="IE";
	}
	if (!document.all && document.getElementById){
		// Netscape 6
    	thisbrowser="NN6";
	}
	
}

function load() { 
	// the real load function is within the locate an office jsp - for google map
	// need this function here so no javascript error
}

function GUnload() {
	// the real GUnload function is within the locate an office jsp - for google map
	// need this function here so no javascript error
}

function doDropDown(bxid,selectbox){
	var otherSelBox = document.getElementById(selectbox);
	var selObjx = document.getElementById(bxid);
	var selObjValue = selObjx.options[selObjx.selectedIndex].value;		
	var selArray =  eval(selObjValue);
	otherSelBox.length=1;
	otherSelBox[0].selected=true;
	selObjx.options[selObjx.selectedIndex].text.toLowerCase().indexOf("select");
	if(selObjx.options[selObjx.selectedIndex].text.toLowerCase().indexOf("select") <=-1){
		for(x = 0;x<selArray.length;x++){
				otherSelBox[x+1] = new Option(selArray[x], "we set the value to the loop iterator x which is " +x);
		}
	}
}

/* ***changeURL function -  select boxes */
function changeURL(link) { 
	if (link != '') window.location = link;
}
	
/* used for forms of different names that only have 1 dropdown in them */
function dropdownGo(i){
	var frm=document.forms[i];
	var sValue;
	for(a=0;a<frm.elements.length;a++){
   		if(frm.elements[a].type == 'select-one'){
     		sValue = frm.elements[a].options[frm.elements[a].options.selectedIndex].value.split("~");
  			break;
   		}
 	}
 	if(sValue[1].toLowerCase() == 'new'){
  		window.open(sValue[0])
 	}else if(sValue[1].toLowerCase() == 'overlay'){
  		location.href=sValue[0];
 	}
 	return false;
}

/* Collect life stages checkbox values and pass them as query string */
function passLifeStages() {

	var checkbox_choices = 0;
 		
	// Loop from zero to the one minus the number of checkbox button selections
	for (counter = 0; counter < document.frmLifeStages.chkLifeStages.length; counter++) {
		// If a checkbox has been selected it will return true
		// (If not it will return false)
		if (document.frmLifeStages.chkLifeStages[counter].checked) { 
			checkbox_choices = checkbox_choices + 1; 
		}
	}
	
	if (checkbox_choices > 3 ) {
		// If there were more than three selections made display an alert box
		msg="You're limited to only three selections.\n";
		msg=msg + "You have made " + checkbox_choices + " selections.\n";
		msg=msg + "Please remove " + (checkbox_choices-3) + " selection(s).";
		alert(msg);
		return (false);
	}
	
	var param="";
	//alert (document.frmLifeStages.hidStages.value);
	var stages = document.frmLifeStages.hidStages.value.split("|");
	for (i=0; i<document.frmLifeStages.chkLifeStages.length;i++) {
		if (document.frmLifeStages.chkLifeStages[i].checked) {
			if (param=="") {
				param = param + stages[i];
			} else {
				param=param+","+stages[i];
			}
		}
	}	
	//alert(param);
		location.href="/productssolutions/individualsfamilies/multiplelifestages/results?mmcom_stages="+param;
	return false;
}

function switchYear (selYear, count) {
	for (i=0; i<count;i++) {
		if (selYear == i) {
			if (thisbrowser == "IE") {
				document.all["divYear"+i].style.display = "inline";
				if (null != document.all["divYearTitle"+i]) {
					document.all["divYearTitle"+i].style.display = "inline";
				}
			} else {
				document.getElementById("divYear"+i).style.display="inline";
				if (null != document.getElementById("divYearTitle"+i)) {
					document.getElementById("divYearTitle"+i).style.display="inline";
				}
			}
		} else {
			if (thisbrowser == "IE") {
				document.all["divYear"+i].style.display = "none";
				if (null != document.all["divYearTitle"+i]) {
					document.all["divYearTitle"+i].style.display = "none";
				}
			} else {
				document.getElementById("divYear"+i).style.display="none";
				if (null != document.getElementById("divYearTitle"+i)) {
					document.getElementById("divYearTitle"+i).style.display="none";
				}
			}
		}
	}
}

function popUp(url, name) { 
	popUpWindow = window.open(url, name, 'width=630,height=400,right=0,left=0,top=0,scrollbars,resizable');
}

function newWindow(theURL,winName,w,h,scroll){
	// creates a centered popup window
	// pass in 'URL','name'[for scripting purposes],
	// 'width'[integer],'height'[integer],'1'[1 if you want scrollbars, you can omit this OR send a '0' if you don't])
	// e.g. <a href="javascript:newWindow('http://www.wired.com','whatever','500','600','1');">Wired.com</a>
	winName = winName.replace(/\s+/g,'');
	var xcoord = (screen.width-w)/2;
	var ycoord = (screen.height-h)/2;
	var settings ='height='+h+',';
	settings +='width='+w+',';
	settings +='top='+ycoord+',';
	settings +='left='+xcoord+',';
	settings +='scrollbars='+scroll+',';
	settings +='menubar=no,';
	settings +='location=no,';
	settings +='toolbar=no,';
	settings +='resizable=yes';
	var win=window.open(theURL,winName,settings);
} 


/*************** Email Us  ***************************/

function selectionChange(theControl) {
	setHelpDiv(theControl.value);
}

function setHelpDiv(theSelection) {
	var helpFragment1 = "If you would prefer to manage your account online and already have a username and password, please <a href=\"/mmfg/secure/login/index.html\">login</a> now.";
	var helpFragment2 = "If you would like to sign up for access to manage your account online, please use our <a href=\"/mmfgsvc/secure/registration/entry.html\">registration</a> process.";
	var helpSeperator = "<br><br>";	
	
	var helpText1 = helpFragment1 + helpSeperator + helpFragment2 + helpSeperator + "If you would prefer to speak with a service representative, please call our Retirement Income Service Center at 1 (800) 272-2216, between 8 a.m. and 8 p.m. EST.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201006-107043</span>";
	
	var helpText2 = helpFragment1 + helpSeperator + helpFragment2 + helpSeperator + "If you would prefer to speak with a service representative, you may contact Policyholder Customer Service at 1 (800) 272-2216, between 8 a.m. and 8 p.m. EST.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201009-107723</span>";
	
	var helpText3 = helpFragment1 + helpSeperator + helpFragment2 + helpSeperator + "If you would prefer to speak with a service representative, you may contact Policyholder Customer Service at 1 (800) 548-0073, between 8 a.m. and 5 p.m. EST.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201006-106987</span>";

	var helpText4 = helpFragment1 + helpSeperator + helpFragment2 + helpSeperator + "If you would prefer to speak with a service representative, you may contact Policyholder Customer Service at 1 (800) 272-2216, between 8 a.m. and 8 p.m. EST.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201009-107723</span>";
	
	var helpText5 = "If you would prefer to speak with a customer service representative, you may contact Policyholder Customer Service at 1 (888) 505-8952, option \"2\", between 7 a.m. and 5 p.m. PST.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201006-106989</span>";
	
	var helpText6 = "If you would prefer to manage your account online and already have a User ID and PIN, please <a href=\" javascript:popUp('https://www.mystreetscape.com/my/mmira')\">login</a> now." + helpSeperator + "If you do not have a user ID and PIN, or if you would prefer to speak with a customer service representative, you may contact the IRA Service Center at 1 (866) 306-6472, between 8 a.m. and 5 p.m. EST.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201006-106991</span>";
	
	var helpText7 = "For additional information, please contact your financial professional.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201006-107054</span>";
	
	var helpText8 = "If you would prefer to manage your account online and already have a User ID and PIN, please <a href=\"https://wwwrs.massmutual.com/journey/Login.aspx\">log in to The Journey<sup>SM</sup></a> now." + helpSeperator + "If you do not have a User ID and PIN, or if you would prefer to speak with a customer service representative, you may contact the Participant Information Center at 1 (800) 743-5274, between 8 a.m. and 8 p.m. EST.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201006-107056</span>";

	var helpText9 = "If you need assistance regarding the servicing of your MassMutual Retirement Management Account (RMA), please contact your advisor.<br><br><span style=\"font-size:.8em;font-family:Arial;color:#666666;\">CRN201006-107047</span>";
	
	var newtext = "";
	
	if (theSelection == "1") { newtext = helpText1; }
	if (theSelection == "2") { newtext = helpText2; }
	if (theSelection == "3") { newtext = helpText3; }
	if (theSelection == "4") { newtext = helpText4; }
	if (theSelection == "5") { newtext = helpText5; }
	if (theSelection == "6") { newtext = helpText6; }
	if (theSelection == "7") { newtext = helpText7; }
	if (theSelection == "8") { newtext = helpText8; }
	if (theSelection == "9") { newtext = helpText9; }
	
	document.getElementById("divHelpText").innerHTML = newtext;
}

function showWhyDialog() {
  var win = window.open("", "whyDobWindow", "width=300,height=150,menubar=false,toolbar=false,scrollbars=false");
  win.document.write("<p align=\"right\"><a href=\"javascript:window.close();\"><img src=\"/mmfg/images/btn_close.gif\" border=\"0\"></a></p><span style='font:normal normal normal 9pt/1.2em Arial,Helvetica,sans-serif;color:#333;'>By providing your date of birth, our representatives will be able to more easily identify your accounts and assist you with your questions.</span>");
}


/**************** Find a Form - three level dynamic dropdowns  *************/

function doProductName(thisId){
	var thisSelBox = document.getElementById(thisId);
	var nextSelBox = document.getElementById("selProductName");
	var thirdSelBox = document.getElementById("selTask");
	var thisSelBoxValue = thisSelBox.options[thisSelBox.selectedIndex].value;		
	
	if (thisSelBoxValue == "all") {
		// "I don't know" is selected, no need to set up any array
	} else {
		var selArray =  eval("prodname_" + thisSelBoxValue);
		nextSelBox.length=1;
		nextSelBox[0].selected=true;
		thisSelBox.options[thisSelBox.selectedIndex].text.toLowerCase().indexOf("select");
		//if(thisSelBox.options[thisSelBox.selectedIndex].text.toLowerCase().indexOf("select") <=-1){
			for(x = 0;x<selArray.length;x++){
				nextSelBox[x+1] = new Option(selArray[x], x);
			}
		//}
		thirdSelBox.length=1;
		thirdSelBox[0].selected=true;
		thirdSelBox.options[thirdSelBox.selectedIndex].text.toLowerCase().indexOf("select");
	}
}

function doTask(thisId){
	var prevSelBox = document.getElementById("selProductType");
	var thisSelBox = document.getElementById(thisId);
	var nextSelBox = document.getElementById("selTask");
	var prevSelBoxValue = prevSelBox.options[prevSelBox.selectedIndex].value;
	var thisSelBoxValue = thisSelBox.options[thisSelBox.selectedIndex].value;		
	var selArray =  eval("task_" + prevSelBoxValue + "_" + thisSelBoxValue);
	nextSelBox.length=1;
	nextSelBox[0].selected=true;
	thisSelBox.options[thisSelBox.selectedIndex].text.toLowerCase().indexOf("select");
	//if(thisSelBox.options[thisSelBox.selectedIndex].text.toLowerCase().indexOf("select") <=-1){
		for(x = 0;x<selArray.length;x++){
			nextSelBox[x+1] = new Option(selArray[x], x);
		}
	//}
}

/* Forms - multiple pdfs printing  */
function countPrintPDFsChecked() {
    var numChecked = 0;
  
    //look for checkboxes with a specific name and determine if they have been checked
    for (i=0; i<document.PdfForm.elements.length; i++)
      {
      if (document.PdfForm.elements[i].type == 'checkbox' &&
          document.PdfForm.elements[i].checked == true)
        {
        numChecked++;
        } 
      }
     
    return numChecked;
  }

function submitPdfPrintForm()
  { 
    //count number of PDF's checked off for printing
    var iCnt = countPrintPDFsChecked();

    if (iCnt == 0)
      {
      alert("No PDF's were selected for printing.");
      }
    else
    if (iCnt > 5)
      {
      alert("The maximum number of PDF's that you can print at one time is 5.");
      }
    else
      {
      window.open("","pdf_window","resizable=yes,status=no,toolbar=no,menubar=no,location=yes,scrollbars=yes,width=800,height=600","");
      document.PdfForm.target = "pdf_window";
      //document.PdfForm.method = "POST"; 
      //document.PdfForm.action = "/forms/pdfprint"; 
      document.PdfForm.submit(); 
      }
  } 


/**********************************************************************/
/* ----- styleswitcher.js */
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

/* ----- subnav.js */
function initNav() {
	if (!document.getElementsByTagName || !document.getElementById) return;
	var navUL = document.getElementById('navmenu');
	if (!navUL) return;
	var allNavLInks = navUL.getElementsByTagName('a');
		for (var a = 0; a < allNavLInks.length; a++) {
		addEvent(allNavLInks[a], 'click', findLink, false);
		}
	addEvent(document, 'click', allOff, false)
}

function allOff() {
	if (!document.getElementsByTagName || !document.getElementById) return;
	
	var mainNavUL = document.getElementById('navmenu');
	var divArray =  mainNavUL.getElementsByTagName('div');
		for(d=0; d<divArray.length; d++) {
			divArray[d].style.display = "none";
		}

	var ulArray = mainNavUL.getElementsByTagName('ul');
		for(u=0; u<ulArray.length; u++) {
		ulArray[u].style.display = "none";
		}
	
	var liArray = document.getElementsByTagName('li');
		for(l=0; l<liArray.length; l++) {
			if (liArray[l].className == "liTopNav"){
				var mainNavA = liArray[l].childNodes[0];
					if ((mainNavA.id).indexOf('Over') != -1){
						var txtId = mainNavA.id;
						txtId = txtId.replace("Over", "");
						mainNavA.id = txtId;
					}
			}
		}
	var logDrop = document.getElementById('divChoose');
	var aDrop = document.getElementById('aLogin');
		if (logDrop.style.display == "block") {
			logDrop.style.display = "none";
			aDrop.style.background = "url(./images/aLogIn.jpg)";
		}
}

function findLink(e) {
	if (e && e.target) {
		theA = e.target;
	}
	if (window.event && window.event.srcElement) {
		theA = window.event.srcElement;
	}
	if (!theA) return;
	
	if (theA.nodeName.toLowerCase() == 'a') {
	theA = theA;
	} else {
	var theA = ascendDOM(theA, 'a'); //make sure it's the A
	}
	//now we have the anchor that was clicked on
	// if it's the top level A then do this
	if(theA.className == "topNav") {
		var theTopLi = ascendDOM(theA, 'li'); //make sure it's the top level LI
		if (theTopLi.className == "liTopNav") {
			turnOnUL(theTopLi);
			// stop the links from working
			if (window.event) {
				window.event.cancelBubble = true;
				window.event.returnValue = false;
			} else if (e) {
				e.stopPropagation();
				e.preventDefault();
			}
		}
	}
	// if it's the A in the nav with a flyout
	if (theA.className == "parent") {
		var theInnerLi = ascendDOM(theA, 'li'); //make sure it's the inner level LI
		turnOnDiv(theInnerLi);
		// stop the links from working
		if (window.event) {
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		} else if (e) {
			e.stopPropagation();
			e.preventDefault();
		}
	}
	// removed the dotted lines from the link
	theA.blur();
}

// top nav turning on and off
function turnOnUL(theTopLi) {
	turnOffAllSubs(theTopLi);
	
	for (l=0; l<theTopLi.childNodes.length; l++) {
		if(theTopLi.childNodes[l].nodeName.toLowerCase()=="ul") {
			var childUL = theTopLi.childNodes[l];
		}
	}
	childUL.style.display = (childUL.style.display == "block") ? "none" : "block";
	
	// on state for bg image
	var aBgOn = theTopLi.childNodes[0];
		if ((aBgOn.id).indexOf('Over') == -1){
			if ((aBgOn.id).indexOf('Up') == -1){	
			aBgOn.id = aBgOn.id + ("Over");
			}
		} else {
			var txtId = aBgOn.id;
			txtId = txtId.replace("Over", "");
			aBgOn.id = txtId;
		}
}

function turnOffAllSubs(theTopLi) {
	for (l=0; l<theTopLi.childNodes.length; l++) {
		if(theTopLi.childNodes[l].nodeName.toLowerCase()=="ul") {
			var leaveUL = theTopLi.childNodes[l];
		}
	}
	
	if (!document.getElementsByTagName || !document.getElementById) return;
	var mainNavUL = document.getElementById('navmenu');
	
	//turn off any flyouts that may be active
	var divArray =  mainNavUL.getElementsByTagName('div');
		for(d=0; d<divArray.length; d++) {
			divArray[d].style.display = "none";
		}	
	var ulArray = mainNavUL.getElementsByTagName('ul');
		for(u=0; u<ulArray.length; u++) {
			if (ulArray[u] != leaveUL){
			ulArray[u].style.display = "none";
			}
		}
	
	// turn all bg images to off state
	var topUL = ascendDOM(theTopLi, 'ul'); //make sure it's the ul containing this li
	var allLis = topUL.getElementsByTagName('li');
		for (b=0; b<allLis.length; b++) {
			if (allLis[b].className == "liTopNav") {
				var mainNavA = allLis[b].childNodes[0];
					if ((mainNavA.id).indexOf('Over') != -1){
						if (mainNavA != theTopLi.childNodes[0]){
							var txtId = mainNavA.id;
							txtId = txtId.replace("Over", "");
							mainNavA.id = txtId;
						}
					}
			}
			if (allLis[b].childNodes[0].id == "sNavOn") {
				allLis[b].childNodes[0].id = "";
			}
		}	
		// turn off login box if it's on
		var logDrop = document.getElementById('divChoose');
		var aDrop = document.getElementById('aLogin');
			if (logDrop.style.display == "block") {
				logDrop.style.display = "none";
				aDrop.style.background = "url(./images/aLogIn.jpg)";
			}
}

function turnOnDiv(theInnerLi) {
	turnOffAllDivs(theInnerLi);

	for (s=0; s<theInnerLi.childNodes.length; s++) {
		if(theInnerLi.childNodes[s].nodeName.toLowerCase()=="div") {
			var flyDiv = theInnerLi.childNodes[s];
		}
	}
	flyDiv.style.display = (flyDiv.style.display == "block") ? "none" : "block";
	
	var flyULs = flyDiv.getElementsByTagName('ul');
		for (d=0; d<flyULs.length; d++) {
			flyULs[d].style.display = "block";
		}
	// keep the background state on
	theInnerLi.childNodes[0].id = (theInnerLi.childNodes[0].id == "sNavOn") ? "" : "sNavOn";
	//alert(theInnerLi.childNodes[0].id);
}

function turnOffAllDivs(theInnerLi){
	for (l=0; l<theInnerLi.childNodes.length; l++){
		if (theInnerLi.childNodes[l].nodeName.toLowerCase()=="div") {
			var leaveDiv = theInnerLi.childNodes[l];
		}
	}
	var ulMenu = ascendDOM(theInnerLi, 'ul'); //make sure it's the ul containing this li
	var divsToHide = ulMenu.getElementsByTagName('div');
		for(h=0; h<divsToHide.length; h++) {
			if (divsToHide[h] != leaveDiv) { 
			divsToHide[h].style.display = "none";
			}
		}
	//turn other bg colors off in snav
	var aThatWasClicked = theInnerLi.childNodes[0];
	var upToUL = ascendDOM(theInnerLi, 'ul');
	var asToOff = upToUL.getElementsByTagName('a');
		for(a=0; a<asToOff.length; a++) {
			if (asToOff[a] != aThatWasClicked){
				asToOff[a].id = "";
			}	
		}
}

/* *******************climbs the DOM to find the event src in the params************* */
function ascendDOM(e, target) {
	while (e.nodeName.toLowerCase() != target && e.nodeName.toLowerCase() != 'html') {
		e = e.parentNode;
	}
	return (e.nodeName.toLowerCase() == 'html')? null : e;
}
/* *******************Get the URL************* */
function getURL() {
	var  theURL = window.location.href;
	
	if ((theURL).indexOf('/productssolutions') != -1){
	var aNavS = document.getElementById('aNav1');
	aNavS.id = aNavS.id + ("Up");
	} else if ((theURL).indexOf('/planningtools') != -1){
	var aNavS = document.getElementById('aNav2');
	aNavS.id = aNavS.id + ("Up");
	} else if ((theURL).indexOf('/aboutmassmutual') != -1){
	var aNavS = document.getElementById('aNav3');
	aNavS.id = aNavS.id + ("Up");
	} else if ((theURL).indexOf('/careers') != -1){
	var aNavS = document.getElementById('a2Nav1');
	aNavS.id = aNavS.id + ("On");
	} else if ((theURL).indexOf('/forms') != -1){
	var aNavS = document.getElementById('a2Nav2');
	aNavS.id = aNavS.id + ("On");
	} else if ((theURL).indexOf('/contactus') != -1){
	var aNavS = document.getElementById('a2Nav3');
	aNavS.id = aNavS.id + ("On");
	}
}

/* ************************************************************************** */
/* ----- ntpagetag.js */
/* Unica Page Tagging Script v1.1
 * Copyright 2004-2006 Unica Corporation.  All rights reserved.
 * Visit http://www.unica.com for more information.
 */

var NTPT_IMGSRC = '/images/vendor/semphonic/ntpagetag.mmt';

var NTPT_FLDS = new Object();
NTPT_FLDS.lc = true; // Document location
NTPT_FLDS.rf = true; // Document referrer
NTPT_FLDS.rs = true; // User's screen resolution
NTPT_FLDS.cd = true; // User's color depth
NTPT_FLDS.ln = true; // Browser language
NTPT_FLDS.tz = true; // User's timezone
NTPT_FLDS.jv = true; // Browser's Java support

var NTPT_MAXTAGWAIT = 1.0; // Max delay (secs) on link-tags and submit-tags

// Optional variables:
var NTPT_HTTPSIMGSRC = '';
var NTPT_GLBLEXTRA = '';
var NTPT_GLBLREFTOP = false;

/*** END OF USER-CONFIGURABLE VARIABLES ***/
//called at loading and onClick when ntptEventTag is called
function O0000(O0000O,O0O0OOO){
     return(eval("\x74\x79\x70\x65\x6f\x66\x20"+O0000O+"\x20\x21\x3d\x20\x22\x75\x6e\x64\x65\x66\x69\x6e\x65\x64\x22")?eval(O0000O):O0O0OOO);
}
//called at loading and onClick when ntptEventTag is called
function O00O000(O0OOO0,O000OO){
  return(O0OOO0+(((O0OOO0=='')||((O000OO=='')||(O000OO.substring((0xf6d+32-0xf8d),(0x14d8+2215-0x1d7e))=="\x26")))?'':"\x26")+O000OO);
}

function O000O0(){
     var O0O00O=new Date();
	 return(O0O00O.getTime()+"\x2e"+Math.floor(Math.random()*(0xd43+2155-0x11c6)));
}

// this function [function 2] is called as the page loads - and on the onclick event from the function designated in 
// comments as function 1
function O0OOO(OO0000,O00OO0){
    OO0OO[OO0000]=O00OO0.toString();
}

function OO0OO0(OO0000){
      OO0OO[OO0000]='';
}
//called at loading and onClick when ntptEventTag is called
function OO0OOOO(OOOOO){
    var O0O0OO='',O00OO,O0O000;OOO0O0(O0000("\x4e\x54\x50\x54\x5f\x47\x4c\x42\x4c\x45\x58\x54\x52\x41",''));
	  if(!LnkLck)
	      OOO0O0(O0000("\x4e\x54\x50\x54\x5f\x50\x47\x45\x58\x54\x52\x41",''));
		  OOO0O0(OOOOO);
		  for(O00OO in OO0OO){
		     O0O000=OO0OO[O00OO];
			   if(O0O000&&(O0O000!=''))
			      O0O0OO=O00O000(O0O0OO,(O00OO+"\x3d"+(self.encodeURIComponent?encodeURIComponent(O0O000):escape(O0O000))));
		 }
	  return O0O0OO;
}
//called at loading
function OOO00OO(){
  var O00OO;OOOOOO.OO0OO=new Array();
     for(O00OO in OO0OO)OOOOOO.OO0OO[O00OO]=OO0OO[O00OO];
}
// called at loading and onClick when ntptEventTag is called
function O0OO00(){
   var O00OO;OO0OO=new Array();
      for(O00OO in OOOOOO.OO0OO)OO0OO[O00OO]=OOOOOO.OO0OO[O00OO];
}

function OOOO0O(O0OOOO,O0OO0O,OOOO0){
    if(OO0O0[O0OOOO]!=null){
	    var O00O0O=new Function(O0OO0O);OO0O0[O0OOOO].onload=O00O0O;OO0O0[O0OOOO].onerror=O00O0O;OO0O0[O0OOOO].onabort=O00O0O;
	}
	setTimeout(O0OO0O,(OOOO0*(0x61e+1960-0x9de)));
}
// called at loading and onClick when ntptEventTag is called
function OO0O00(O0OO0,OO0OOO){
    if(O0OO0=='')
	    return;
	OOO0O=((OOO0O+(0xd01+3643-0x1b3b))%OO0O0.length);
if(OO0O0[OOO0O]==null)OO0O0[OOO0O]=new Image((0x459+2628-0xe9c),(0x11c2+1387-0x172c));OO0O0[OOO0O].src=O0OO0+"\x3f"+OO0OOO;
}

// this function [function 2] is called as the page loads and on the onclick event from the function designated in 
// comments as function 1
function O00000(OOOOO){
  var O0OO0;var OO0OOO;
    if((OOOO00!='')&&(document.location.protocol=="\x68\x74\x74\x70\x73\x3a"))
	   O0OO0=OOOO00;
	else 
	   O0OO0=O00O00;
	   OO0OOO=OO0OOOO(OOOOO);
	   OO0O00(O0OO0,OO0OOO);
	   O0OO00();
}
// called at loading and onClick when ntptEventTag is called
function OOO0O0(OOOOO){
  var OOO00O;
  var OO0O0O;
 if(!OOOOO)
 return;
 OOOOO=OOOOO.toString();if(OOOOO=='')
 return;
 OOO00O=OOOOO.split("\x26");
 for(OO0O0O=(0x41f+1956-0xbc3);OO0O0O<OOO00O.length;OO0O0O++){
 var O00OOO=OOO00O[OO0O0O].split("\x3d");
 if(O00OOO.length==(0x1fa5+1107-0x23f6))
 O0OOO(O00OOO[(0x1836+2183-0x20bd)],(self.decodeURIComponent?decodeURIComponent(O00OOO[(0x1084+3223-0x1d1a)]):unescape(O00OOO[(0x4cb+410-0x664)])));
 }
}

// function 1 - determined by the value of referenced on the onClicke event - 
// for the sample it's ntptEventTag [see below for the value]
function OO000O(OOOOO){
  O0OOO("\x65\x74\x73",O000O0());
  O00000(OOOOO);
  return true;
}

function O0O00O0(O0O0O,OOOOO,OOOO0){
  var O00O0;if(!O0O0O||!O0O0O.href)
  return true;
  if(LnkLck)
  return false;
  LnkLck=O0O0O;
if(OOO00.lc)O0OOO("\x6c\x63",O0O0O.href);
if(OOO00.rf){
  if(!OOOOO0||!top||!top.document)
     O0OOO("\x72\x66",document.location);}OO000O(OOOOO);
	 if(OOOO0)O00O0=OOOO0;else O00O0=NTPT_MAXTAGWAIT;
	 if(O00O0>(0x7df+2430-0x115d)){
	       var OO00OO;
            if(O0O0O.click){
              O0O0O.tmpclck=O0O0O.onclick;O0O0O.onclick=null;
              OO00OO="\x69\x66\x20\x28\x20\x4c\x6e\x6b\x4c\x63\x6b\x20\x29\x20\x7b\x20\x4c\x6e\x6b\x4c\x63\x6b\x2e\x63\x6c\x69\x63\x6b\x28\x29\x3b\x20\x4c\x6e\x6b\x4c\x63\x6b\x2e\x6f\x6e\x63\x6c\x69\x63\x6b\x20\x3d\x20\x4c\x6e\x6b\x4c\x63\x6b\x2e\x74\x6d\x70\x63\x6c\x63\x6b\x3b\x20\x4c\x6e\x6b\x4c\x63\x6b\x20\x3d\x20\x6e\x75\x6c\x6c\x3b\x20\x7d";
            }else 
               OO00OO="\x69\x66\x20\x28\x20\x4c\x6e\x6b\x4c\x63\x6b\x20\x29\x20\x7b\x20\x77\x69\x6e\x64\x6f\x77\x2e\x6c\x6f\x63\x61\x74\x69\x6f\x6e\x2e\x68\x72\x65\x66\x20\x3d\x20\x22"+O0O0O.href+"\x22\x3b\x20\x4c\x6e\x6b\x4c\x63\x6b\x20\x3d\x20\x6e\x75\x6c\x6c\x3b\x20\x7d";OOOO0O(OOO0O,OO00OO,O00O0);
         return false;
     }
LnkLck=null;
return true;
}

function O0OOO0O(OO000,OOOOO,OOOO0){
   var O00O0;
   if(!OO000||!OO000.submit)
     return true;
	 if(FrmLck)
	 return false;
	   FrmLck=OO000;
	   OO000O(OOOOO);
	 if(OOOO0)
	   O00O0=OOOO0;
	 else 
	   O00O0=NTPT_MAXTAGWAIT;
	   if(O00O0>(0x9e0+6857-0x24a9)){
	     OO000.tmpsbmt=OO000.onsubmit;
		 OO000.onsubmit=null;
		 OOOO0O(OOO0O,"\x69\x66\x20\x28\x20\x46\x72\x6d\x4c\x63\x6b\x20\x29\x20\x7b\x20\x46\x72\x6d\x4c\x63\x6b\x2e\x73\x75\x62\x6d\x69\x74\x28\x29\x3b\x20\x46\x72\x6d\x4c\x63\x6b\x2e\x6f\x6e\x73\x75\x62\x6d\x69\x74\x20\x3d\x20\x46\x72\x6d\x4c\x63\x6b\x2e\x74\x6d\x70\x73\x62\x6d\x74\x3b\x20\x46\x72\x6d\x4c\x63\x6b\x20\x3d\x20\x6e\x75\x6c\x6c\x3b\x20\x7d",O00O0);
		 return false;
	    }
		 FrmLck=null;
		 return true;
}
		 var O00O00=NTPT_IMGSRC;
		 var OOO00=NTPT_FLDS;
		 var OOOO00=O0000("\x4e\x54\x50\x54\x5f\x48\x54\x54\x50\x53\x49\x4d\x47\x53\x52\x43",'');
		 var OOOOO0=O0000("\x4e\x54\x50\x54\x5f\x50\x47\x52\x45\x46\x54\x4f\x50",O0000("\x4e\x54\x50\x54\x5f\x47\x4c\x42\x4c\x52\x45\x46\x54\x4f\x50",false));
		 var OOO000=O0000("\x4e\x54\x50\x54\x5f\x4e\x4f\x49\x4e\x49\x54\x49\x41\x4c\x54\x41\x47",false);
		 var ntptAddPair=O0OOO;
		 var ntptDropPair=OO0OO0;
		 var ntptEventTag=OO000O;
		 var ntptLinkTag=O0O00O0;
		 var ntptSubmitTag=O0OOO0O;
		 var OO0OO=new Array();
		 var OOOOOO=new Object();
		 var OO0O0=Array((0xc53+5034-0x1ff3));
		 var OOO0O;for(OOO0O=(0xc69+6583-0x2620);OOO0O<OO0O0.length;OOO0O++)OO0O0[OOO0O]=null;
		 var LnkLck=null;
		 var FrmLck=null;
		 O0OOO("\x6a\x73","\x31");
		 O0OOO("\x74\x73",O000O0());
		    if(OOO00.lc)
			  O0OOO("\x6c\x63",document.location);
			if(OOO00.rf){
			   var O0O0O0;
			     if(OOOOO0&&top&&top.document)
				    O0O0O0=top.document.referrer;
				 else 
				    O0O0O0=document.referrer;
					O0OOO("\x72\x66",O0O0O0);
			}
			if(self.screen){
			   if(OOO00.rs)
			      O0OOO("\x72\x73",self.screen.width+"\x78"+self.screen.height);
			   if(OOO00.cd)
			      O0OOO("\x63\x64",self.screen.colorDepth);
			}
		   if(OOO00.ln){
		       var OO00O;
			   if(navigator.language)
			      OO00O=navigator.language;
			   else if(navigator.userLanguage)
			      OO00O=navigator.userLanguage;
			   else OO00O='';
			   if(OO00O.length>(0xd3b+6466-0x267b))
			       OO00O=OO00O.substring((0xb13+5400-0x202b),(0x8ca+5379-0x1dcb));
				   OO00O=OO00O.toLowerCase();O0OOO("\x6c\x6e",OO00O);
		    }
				   if(OOO00.tz){
				       var O0O00;
					   var O0O00O=new Date();
					   var O000O=O0O00O.getTimezoneOffset();
					   var OOO0OO;
					   O0O00="\x47\x4d\x54";
					     if(O000O!=(0x10c4+3752-0x1f6c)){
						     if(O000O>(0xc86+1771-0x1371))
							    O0O00+="\x20\x2d";
						     else 
							    O0O00+="\x20\x2b";
							  O000O=Math.abs(O000O);OOO0OO=Math.floor(O000O/(0x1840+1703-0x1eab));
							  O000O-=OOO0OO*(0x13b1+2037-0x1b6a);
							  if(OOO0OO<(0x41+6971-0x1b72))
							      O0O00+="\x30";O0O00+=OOO0OO+"\x3a";
							  if(O000O<(0x1026+3918-0x1f6a))
							      O0O00+="\x30";O0O00+=O000O;
						 }
							  O0OOO("\x74\x7a",O0O00);
					}
						  if(OOO00.jv){
						      var OO00O0;
							   if(navigator.javaEnabled())
							      OO00O0="\x31";
							   else 
							      OO00O0="\x30";
							   O0OOO("\x6a\x76",OO00O0);
						  }
						  OOO00OO();
						  if(!OOO000)
						    O00000('');

/* ----- ntpagetag_flash.js */

// Function calls created by Semphonich to be used with Flash for tracking

function doPageEvent( pageType, pageName )
{
	//alert("doPageEvent:pageName = [" + pageName + "]");
	ntptEventTag('ev=Page&'+pageType+'='+pageName+'&pv=1');
}  // doPageEvent

function doCustomEvent( eventName )
{
	//alert("doCustomEvent: eventName = [" + eventName + "]");
	ntptEventTag('ev='+eventName+'&pv=0');
}  // doCustomEvent

function doLinkEvent( linkName )
{
	//alert("doLinkEvent: linkName = [" + linkName + "]");
	ntptAddPair( "flashLink", linkName );
	ntptEventTag('ev=FlashLink&pv=0');
	//alert(linkName);
}  // doLinkEvent


/*  ----- iehover-fix-wps.js */
sfHover = function() {
	// Find all unordered lists.
	var navmenu = document.getElementById('navmenu');
	var dropdowns = navmenu.getElementsByTagName('ul');
    var divs = navmenu.getElementsByTagName('div');
	  for(i=0; i<divs.length; i++){
	  var ul = divs[i];
	  // needed to add iframe fix to entire outer child menu container
	   setHover(ul, '25em', '30em');
	   }
	   
	for(i=0; i<dropdowns.length; i++){
		var ul = dropdowns[i];
		var lis = ul.getElementsByTagName("li");
		// default width = trial and error = "fudge" factor
		var wdth='22em'
		// the height of 3.3em is just trial and error and represents the optimal for these menus
		var hgt = '3.4em';
		for(y=0;y<lis.length;y++){
		// apply "fix" to LIs only and only if it hasn't already been done
		 if(lis[y].innerHTML.toLowerCase().indexOf('iframe') < 0){
		 // trial and error = "fudge" factor - when menu is in the center of a os whizzy wig
		   wdth='17em';
	       setHover(lis[y], hgt, wdth);
		   }
		}
	}
}

function setHover(nav, h, w) {

	if (navigator.appVersion.substr(22,3)!="5.0") {
		// IE script to cover <select> elements with <iframe>s
		nav.innerHTML = '<iframe src="./images/spacer.gif" scrolling="no" frameborder="0" style="filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);z-index:-15;height:'+h+';width:'+w+';position:absolute"></iframe>'+nav.innerHTML;
	}
}

// Run this only for IE.
if (window.attachEvent) window.attachEvent('onload', sfHover);
// end