<!--
	function submitForm(url) 
	{
		document.forms[0].action=url;
		document.forms[0].submit();
	}

	function pad(str, padWith, num) 
	{
		for (var i = 0; i < num; i++) 
		{
			str = str + padWith;
		}
	 return (str);
 	}

function FormatNumber(num, decimalNum, bolLeadingZero, bolParens)
/* IN - num:            the number to be formatted
				 decimalNum:     the number of decimals after the digit
				 bolLeadingZero: true / false to use leading zero
				 bolParens:      true / false to use parenthesis for - num

		RETVAL - formatted number
*/
{
	var tmpNum = num;

	// Return the right number of decimal places
	tmpNum *= Math.pow(10,decimalNum);
	tmpNum = Math.floor(tmpNum);
	tmpNum /= Math.pow(10,decimalNum);

	var tmpStr = new String(tmpNum);

	// See if we need to hack off a leading zero or not
	if (!bolLeadingZero && num < 1 && num > -1 && num !=0)
	{
		if (num > 0)
		{
			tmpStr = tmpStr.substring(1,tmpStr.length);
		}
		else
		{
			// Take out the minus sign out (start at 2)
			tmpStr = "-" + tmpStr.substring(2,tmpStr.length);                        
		}
	}

	// See if we need to put parenthesis around the number
	if (bolParens && num < 0)
	{
		tmpStr = "(" + tmpStr.substring(1,tmpStr.length) + ")";
	}

	var decString = tmpStr.substring(tmpStr.indexOf(".")+1);
	if (decString.length < decimalNum) 
	{
		tmpStr = pad(tmpStr, '0', decimalNum - decString.length);
	}

	return tmpStr;
}

function setPrefillValue(fieldName, value)
{
	if (typeof document.forms[0].elements[fieldName] != "undefined")
	{
		if (document.forms[0].elements[fieldName].type == "select-one")
		{
			setSelected(document.forms[0].elements[fieldName], value);
		}
		else if (document.forms[0].elements[fieldName].type == "checkbox")
		{
			if (value == "true")
			{
				document.forms[0].elements[fieldName].checked = true;
			}
		}
		else
		{
			document.forms[0].elements[fieldName].value = value;
		}
	}
}

function setSelected(control, value)
{
	for (var i = 0; i < control.options.length; i++) 
	{
		if (control.options[i].value == value) 
		{
			control.selectedIndex = i;
			return;
		}
	}
}

function toggleBillingOptions(radioGroup1, radioGroup2, toggleValue) {
	var currentSelection = "";
	
	for (i=0; i < radioGroup1.length; i++){
		if(radioGroup1[i].checked){ currentSelection = radioGroup1[i].value; }
	}
	
	if (currentSelection == toggleValue){
		enableBillingOptions(radioGroup2);
	} else {
		disableBillingOptions(radioGroup2);
  }
}
    
function disableBillingOptions(radioGroup) {
  disableRadioButtons(radioGroup);
}
    
function enableBillingOptions(radioGroup) {
  enableRadioButtons(radioGroup);
}
    
function disableRadioButtons(radioGroup) {
  for (i=0; i < radioGroup.length; i++){
  	radioGroup[i].disabled = true;
  	radioGroup[i].checked = false;
  }
}
    
function enableRadioButtons(radioGroup) {
  for (i=0; i < radioGroup.length; i++){
  	radioGroup[i].disabled = false;
  }
}
function countCharacters(field,maxlength,label)
{
 	if(field.value.length>=maxlength)
 	{
 		field.value = field.value.substring(0, maxlength);
 	}
}

function toggleHsaOptions(cwMedPlan) {
	var cwMedName = cwMedPlan.name;
  var hsaDivObj = document.getElementById("hsaDivId");
	if(cwMedName.indexOf(".medicalPlan") < 0 || hsaDivObj == undefined)
	{
	  return;
	}
	var selectedIdx = cwMedPlan.selectedIndex;
	var peopleType = cwMedName.substring(cwMedName.lastIndexOf("-") + 1, cwMedName.indexOf(".medicalPlan"));
  var divObj = document.getElementById("divId" + peopleType);
	if(selectedIdx >= 0 && (peopleType == "0" || peopleType == "1"))
	{
	  var selectedTxt = cwMedPlan.options[selectedIdx].text;
	  var hsaRadioGroup = document.getElementsByName('hsaForm.' + peopleType + '.lumenoshsaaccount');
	  var hsaSsn = document.getElementsByName('hsaForm.' + peopleType + '.ssn');
	  if(selectedTxt.indexOf("Lumenos HSA") >= 0 || selectedTxt.indexOf("Solaura HSA") >=0 || selectedTxt.indexOf("Solaura Health Savings Account")>=0 )
	  {
	    enableBillingOptions(hsaRadioGroup);
	    hsaSsn[0].disabled = false; 
	    divObj.style.display = 'block';
	    hsaDivObj.style.display = 'block';
	  }
	  else
	  {
	    disableBillingOptions(hsaRadioGroup);
	    hsaSsn[0].disabled = true;
	    divObj.style.display = 'none';
	    var anotherOneType = (peopleType == "0" ? "1" : "0");
	    var anotherDivObj = document.getElementById("divId" + anotherOneType);
	    if(anotherDivObj != undefined)
	    {
	      hsaDivObj.style.display = anotherDivObj.style.display;
	    }
	    else
	    {
	      hsaDivObj.style.display = 'none';
	    }
	  }
	}
}

function hideEmptyHsa()
{
  var divObj0 = document.getElementById("divId0");
  var divObj1 = document.getElementById("divId1");
  var hsaDivObj = document.getElementById("hsaDivId");
  var hsaForceDisplay0 = "false";
  var selectedRadio0 = '';
  var hsaForceDisplay1 = "false";
  var selectedRadio1 = '';
  if(divObj0 != null && divObj0 != undefined)
  {
  	if(document.getElementsByName('hsaForm.0.hsaForceDisplay') != null && document.getElementsByName('hsaForm.0.hsaForceDisplay') != undefined)
  	{
		hsaForceDisplay0 = document.getElementsByName('hsaForm.0.hsaForceDisplay')[0].value;
  	}
  	var hsaRadio0 = document.getElementsByName('hsaForm.0.lumenoshsaaccount'); 
  	if(hsaRadio0 != null && hsaRadio0 != undefined)
  	{
  		selectedRadio0 = getCheckedValue(hsaRadio0);
  	}
  
	if(selectedRadio0 != '' || hsaForceDisplay0 == "true")
	{
	  if(hsaRadio0 != null && hsaRadio0 != undefined)
  	  {
        enableBillingOptions(hsaRadio0);
      }
	  divObj0.style.display = 'block';
	}
	else
	{
	  if(hsaRadio0 != null && hsaRadio0 != undefined)
  	  {
	    disableBillingOptions(hsaRadio0);
	  }
	  divObj0.style.display = 'none';
	}
  }
	if(divObj1 != null && divObj1 != undefined)
	{
	  if(document.getElementsByName('hsaForm.1.hsaForceDisplay') != null && document.getElementsByName('hsaForm.1.hsaForceDisplay') != undefined)
      {
    	hsaForceDisplay1 = document.getElementsByName('hsaForm.1.hsaForceDisplay')[0].value;
      }
	  var hsaRadio1 = document.getElementsByName('hsaForm.1.lumenoshsaaccount');
      if(hsaRadio1 != null && hsaRadio1 != undefined)
      {
        selectedRadio1 = getCheckedValue(hsaRadio1);
      }
      if(selectedRadio1 != '' || hsaForceDisplay1 == "true")
      {
      	if(hsaRadio1 != null && hsaRadio1 != undefined)
      	{
        	enableBillingOptions(hsaRadio1);
        }
        divObj1.style.display = 'block';
      }
      else
      {
      	if(hsaRadio1 != null && hsaRadio1 != undefined)
      	{
          disableBillingOptions(hsaRadio1);
        }
        divObj1.style.display = 'none';
      }
	}
	if(hsaDivObj != null && hsaDivObj != undefined)
	{
	  if(selectedRadio0 != '' || hsaForceDisplay0 == "true" || (divObj1 != undefined && (selectedRadio1 != ''|| hsaForceDisplay1 == "true")))
	  {
	    hsaDivObj.style.display = 'block';
	  }
	  else
	  {
	    hsaDivObj.style.display = 'none';
	  }
    }
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

//re-format readonly/disabled field by adding a box
function setSpanStyleClass(spanId, elementName, styleClass)
{
  var element = document.forms[0].elements[elementName];
  if(element.readOnly || (element.type != null && element.type == 'hidden') )
  {
    var span1 = document.getElementById(spanId);
    span1.className = styleClass;
  }
}


//date mask by automatically add '/'
//The only acceptable date format is: MM/dd/yyyy
//author: jliao, 2-12-2008

function maskDate(objEvent, isAllowNA)
{
  var validDateChars = '1234567890\/nNaA';
    var reValidChars = /\d/;
    var iKeyCode = objEvent.which ? objEvent.which : objEvent.keyCode;
    var objInput = objEvent.target ? objEvent.target : objEvent.srcElement;

    var strKey = String.fromCharCode(iKeyCode);
    
	if(iKeyCode == 8 || iKeyCode == 46 || iKeyCode == 37 || iKeyCode == 39 || iKeyCode == 9)
	{
		return true;
	}

    if (validDateChars.indexOf(strKey) == -1) 
    {
    	return false;
    }
    var curValue = objInput.value;
    if( strKey == 'n' || strKey == 'N' || strKey == 'a' || strKey == 'A' || 
        (strKey =='\/' && (curValue.indexOf('a') >= 0 || curValue.indexOf('A') >= 0
                            || curValue.indexOf('n') >= 0 || curValue.indexOf('N') >= 0)))
    {
      return isAllowNA == 'true';
    }

          var caretPosition = getCaretPosition(objInput);
          var selectedLength = getSelectedLength(objInput);
          var curValueLen = curValue.length;
         if((curValueLen - selectedLength) >= 10)
         {
           return false;
         }
         
         switch (caretPosition)
         {
           case 0:
           case 1:
           case 3:
           case 4:
           case 6:
           case 7:
           case 8:
           case 9:
               if(reValidChars.test(strKey))
               {
                 if((curValueLen - selectedLength) > caretPosition)
                 {
                   objInput.value = curValue.substring(0, caretPosition) + strKey + curValue.substring((caretPosition + selectedLength));
                   setCaretPosition(objInput, caretPosition + 1);
                   return false;
                 }
                 else
                 {
//                     reValidChars.test(strKey);
                     objInput.value = curValue.substring(0, caretPosition) + strKey;
                     return false;
                 }
               }
               return false;
             break;
           case 2:
             if('\/'.indexOf(strKey) != -1)
             {
               if(curValue.indexOf('\/') != 2)
               {
                 return true;
               }
               return false;
             }
             else if(curValue.indexOf('\/') != 2)
             {
               if((curValueLen - selectedLength) == 2)
               {
                 objInput.value = curValue.substring(0, 2) + '\/' + strKey;
               }
               else if((curValueLen - selectedLength) == 9)
               {
                 objInput.value = curValue.substring(0, 2) + '\/' + curValue.substring(2 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 1);
               }
               else
               {
                 objInput.value = curValue.substring(0, 2) + '\/' + strKey + curValue.substring(2 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 2);
               }
               return false;
             }
             return false;
             break;
           case 5:
             if('\/'.indexOf(strKey) != -1)
             {
               if(curValue.lastIndexOf('\/') != 5)
               {
                 return true;
               }
               return false;
             }
             else if(curValue.lastIndexOf('\/') != 5)
             {
               if((curValueLen - selectedLength) == 5)
               {
                 objInput.value = curValue.substring(0, 5) + '\/' + strKey;
               }
               else if((curValueLen - selectedLength) == 9)
               {
                 objInput.value = curValue.substring(0, 5) + '\/' + curValue.substring(5 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 1);
               }
               else
               {
                 objInput.value = curValue.substring(0, 5) + '\/' + strKey + curValue.substring(5 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 2);
               }
               return false;
             }
             return false;
             break;
           }  //end switch

  return false;
}

function maskDate2(objEvent, isAllowNA)
{
  return maskDate(objEvent, isAllowNA)
}

//phone number mask by automatically add '(', ') ' or ' ' for area code  and '-' for number
//The only acceptable phone format is: (123) 456-7890

function maskPhone2(objEvent)
{
  return maskPhone(objEvent);
}

function maskPhone(objEvent)
{
  var validPhoneChars = '1234567890()- ';
    var reValidChars = /\d/;
    var iKeyCode = objEvent.which ? objEvent.which : objEvent.keyCode;
    var objInput = objEvent.target ? objEvent.target : objEvent.srcElement;

    var strKey = String.fromCharCode(iKeyCode);
	
	if(iKeyCode == 8 || iKeyCode == 9 || iKeyCode == 46 || iKeyCode == 37 || iKeyCode == 39)
	{
		return true;
	}
	
    if(validPhoneChars.indexOf(strKey) == -1) 
    {
      return false;
    }

         var curValue = objInput.value;
          var caretPosition = getCaretPosition(objInput);
          var selectedLength = getSelectedLength(objInput);
          var curValueLen = curValue.length;
         if((curValueLen - selectedLength) >= 14)
         {
           return false;
         }
         
         switch (caretPosition)
         {
           case 1:
           case 2:
           case 3:
           case 6:
           case 7:
           case 8:
           case 10:
           case 11:
           case 12:
           case 13:
               if(reValidChars.test(strKey))
               {
                 if((curValueLen - selectedLength) > caretPosition)
                 {
                   objInput.value = curValue.substring(0, caretPosition) + strKey + curValue.substring((caretPosition + selectedLength));
                   setCaretPosition(objInput, caretPosition + 1);
                   return false;
                 }
                 else
                 {
//                     reValidChars.test(strKey);
                     objInput.value = curValue.substring(0, caretPosition) + strKey;
                     return false;
                 }
               }
               return false;
             break;
             
          case 0:
             if('('.indexOf(strKey) != -1)
             {
               if(curValue.indexOf('(') != 0)
               {
                 return true;
               }
               return false;
             }
             if(curValue.indexOf('(') == 0)
             {
               return false;
             }
             if(reValidChars.test(strKey))
             {
               if((curValueLen - selectedLength) < 13)
               {
                 objInput.value = '(' + strKey + curValue.substring(selectedLength);
                 setCaretPosition(objInput, caretPosition + 2);
               }
               else if((curValueLen - selectedLength) == 13)
               {
                 objInput.value = '(' + curValue.substring(selectedLength);
                 setCaretPosition(objInput, caretPosition + 1);
               }
               return false;
             }
             else 
             {
               return false;
             }
             break;
          

           case 4:
             if(')'.indexOf(strKey) != -1)
             {
               if(curValue.indexOf(')') != 4)
               {
                   return true;
               }
               return false;
             }
             if(curValue.indexOf(')') == 4)
             {
                return false;
             }
             if(reValidChars.test(strKey))
             {
               if((curValueLen - selectedLength) == 4)
               {
                 objInput.value = curValue.substring(0, 4) + ') ' + strKey;
               }
               else if((curValueLen - selectedLength) == 13)
               {
                 objInput.value = curValue.substring(0, 4) + ')' +  curValue.substring(4 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 1);
               }
               else if((curValueLen - selectedLength) < 12)
               {
                 if(curValue.indexOf(' ') == caretPosition + 1)
                 {
                   objInput.value = curValue.substring(0, 4) + ')' + ' ' + strKey + curValue.substring(5 + selectedLength);
                 }
                 else
                 {
                   objInput.value = curValue.substring(0, 4) + ') ' + strKey + curValue.substring(4 + selectedLength);
                 }
                 setCaretPosition(objInput, caretPosition + 3);
               }
               else
               {
                 if(curValue.indexOf(' ') == caretPosition + 1)
                 {
                   objInput.value = curValue.substring(0, 4) + ')' + ' ' + strKey + curValue.substring(5 + selectedLength);
                   setCaretPosition(objInput, caretPosition + 3);
                 }
                 else
                 {
                   objInput.value = curValue.substring(0, 4) + ') ' + curValue.substring(4 + selectedLength);
                   setCaretPosition(objInput, caretPosition + 3);
                 }
               }
               return false;
             }
             else 
             {
               return false;
             }
             break;


           case 5:
             if(' '.indexOf(strKey) != -1)
             {
               if(curValue.indexOf(' ') != 5)
               {
                   return true;
               }
               return false;
             }
             if(curValue.indexOf(' ') == 5)
             {
                return false;
             }
             if(reValidChars.test(strKey))
             {
               if((curValueLen - selectedLength) == 5)
               {
                 objInput.value = curValue.substring(0, 5) + ' ' + strKey;
               }
               else if((curValueLen - selectedLength) == 13)
               {
                 objInput.value = curValue.substring(0, 5) + ' ' +  curValue.substring(5 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 1);
               }
               else
               {
                 objInput.value = curValue.substring(0, 5) + ' ' + strKey + curValue.substring(5 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 2);
               }
               return false;
             }
             else 
             {
               return false;
             }
             break;

         

           case 9:
             if('-'.indexOf(strKey) != -1)
             {
               if(curValue.indexOf('-') != 9)
               {
                   return true;
               }
               return false;
             }
             if(curValue.indexOf('-') == 9)
             {
                return false;
             }
             if(reValidChars.test(strKey))
             {
               if((curValueLen - selectedLength) == 9)
               {
                 objInput.value = curValue.substring(0, 9) + '-' + strKey;
               }
               else if((curValueLen - selectedLength) == 13)
               {
                 objInput.value = curValue.substring(0, 9) + '-' +  curValue.substring(9 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 1);
               }
               else
               {
                 objInput.value = curValue.substring(0, 9) + '-' + strKey + curValue.substring(9 + selectedLength);
                 setCaretPosition(objInput, caretPosition + 2);
               }
               return false;
             }
             else 
             {
               return false;
             }
             break;
           }
}

function getCaretPosition(elm)
{
  if (typeof elm.selectionStart != "undefined")
  {
    return elm.selectionStart;
  }
  else if (document.selection)
  {
    return Math.abs(document.selection.createRange().moveStart("character",-1000000));
  }
}


function getSelectedLength(elm)
{
  if (typeof elm.selectionStart != "undefined")
  {
    return elm.selectionEnd - elm.selectionStart;
  }
  else if (document.selection)
  {
    var range = document.selection.createRange();
    var length = range.text.length;
    range.collapse(true);
    range.select();
    return length;
  }
}

function visibleControl(elementId, display)
{
	var element = document.getElementById(elementId);
	if (element == null) {
		return;
	}
	if (display == "hide" || display == "false") {
		element.style.display = "none";
	} else {
		element.style.display = "block";
	}
}

function clearButtons(buttonGroup)
{ 
  for (i=0; i < buttonGroup.length; i++) 
  { 
    if (buttonGroup[i].checked == true) 
    { 
      buttonGroup[i].checked = false 
    }
  } 
}

function setCheckedRadioButton(buttonGroup, value)
{ 
  for (i=0; i < buttonGroup.length; i++) 
  { 
    if (buttonGroup[i].value == value) 
    { 
      buttonGroup[i].checked = true; 
    }
    else
    {
      buttonGroup[i].checked = false; 
    }
  } 
}


function setCaretPosition(ctrl, pos)
{	
  if(ctrl.setSelectionRange)	
  {		
    ctrl.focus();
    ctrl.setSelectionRange(pos,pos);
  }	
  else if (ctrl.createTextRange) 
  {
  		var range = ctrl.createTextRange();	
  		range.collapse(true);
  		range.moveEnd('character', pos);
  		range.moveStart('character', pos);		
  		range.select();	
  }
}


function maskDateMMYYYY(objEvent, isAllowNA)
{
  	var validDateChars = '1234567890\/nNaA';
    var reValidChars = /\d/;
    var iKeyCode = objEvent.which ? objEvent.which : objEvent.keyCode;
    var objInput = objEvent.target ? objEvent.target : objEvent.srcElement;
    var strKey = String.fromCharCode(iKeyCode);

	if(iKeyCode == 9 || iKeyCode == 8 || iKeyCode == 46 || iKeyCode == 37 || iKeyCode == 39)
	{
		return true;
	}
	
    if (validDateChars.indexOf(strKey) == -1) 
    {
    	return false;
    }

    var curValue = objInput.value;
    var caretPosition = getCaretPosition(objInput);
    
    if(isAllowNA && (curValue.indexOf('n') == 0 || curValue.indexOf('N') == 0))
    {
    	if(! /[/aA]/.test(strKey))
    	{
    		return false;
    	}
    	if(caretPosition == 2 && ! /[aA]/.test(strKey))
    	{
    		return false;
   		}
    }
    
    if( (strKey == 'n' || strKey == 'N') && caretPosition == 0 || (strKey == 'a' || strKey == 'A') && caretPosition == 2 || strKey =='/' && caretPosition == 1 && (curValue.indexOf('n') == 0 || curValue.indexOf('N') == 0))
    {
      return isAllowNA == 'true';
    }
    
    if(!reValidChars.test(strKey) && caretPosition != 2)
   	{
    	return false;
    }
    
	if(curValue.length == 2 && reValidChars.test(strKey))
	{
   		objInput.value = curValue + '\/';
   		return true;
	}
	/*
	if(curValue.length >= 2 && curValue.indexOf('\/') < 0 && reValidChars.test(strKey))
	{
		switch (getCaretPosition(objInput))
        {
          case 0:
          case 1:
          	objInput.value = curValue.substring(0, 2) + '\/' + curValue.substring(2);
        }
	}
	*/
  	return true;
}
function maskDateMMYYYY2(objEvent)
{
    var objInput = objEvent.target ? objEvent.target : objEvent.srcElement;
    var curValue = objInput.value;
   
	if(curValue.length >= 3 && curValue.indexOf('\/'))
	{
        objInput.value = curValue.substring(0, 2) + '\/' + curValue.substring(2);
	}
}

// please do not delete this empty function so that it will not cause problem 
// in case of a form has field applicantInfoForm.info.homeZip but not implement this function
function zipChangeAjaxRiskTier()
{
}


function GetXmlHttpObject()
{
	var xmlHttp;
	try
	{
		// Firefox, Opera 8.0+, Safari, IE7
		xmlHttp = new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{	
			xmlHttp = new ActiveXObject('Msxml2.XMLHTTP');
		}
		catch (e)
		{
			// Internet Explorer
			xmlHttp = new ActiveXObject('Microsoft.XMLHTTP');
		}
	}
	return xmlHttp;
}

//provides trim() function for string
  String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); };

  
//-->

function checkSSN(url)
{
	try
	{
	var showMessage = false;
	var formName = document.forms[0].name;
	if(/.*SaveApplicantInfo.*/.test(formName) && /.*&flow=forward&.*/.test(url))
	{
		var ssnField;
		var spouseSsnField;
		var spouseCoverage;
		var maritalStatus;
		
		var elements = document.forms[0].elements;
		for(var i = 0; i < elements.length; i++)
		{
			var element = elements[i];
			if(element && element.name && /.*\.ssn$/i.test(element.name))
			{
				ssnField = element;
			}
			else if(element && element.name && /.*\.spousessn$/i.test(element.name))
			{
				spouseSsnField = element;
			}
			else if(element && element.name && /.*\.spouseCoverage$/i.test(element.name))
			{
				spouseCoverage = element;
			}
			else if(element && element.name && /.*\.maritalStatus$/i.test(element.name))
			{
				maritalStatus = element;
			}
		}
		if(ssnField && ssnField.value.trim().length == 0)
		{
			showMessage = true;
		}
		if(spouseSsnField && spouseSsnField.value.trim().length == 0 && !showMessage)
		{
			if(spouseCoverage)
			{
				if(spouseCoverage.value == "Yes")
				{
					showMessage = true;
				}
			}
			else if(maritalStatus && (maritalStatus.value == "M" || maritalStatus.value == "Married"))
			{
				showMessage = true;
			}
		}
	}
	else if(/.*SaveDependentInfo.*/.test(formName) && /.*&flow=forward&.*/.test(url))
	{
			var spouseOrPartner = /.*(spouse|partner|husband|wife)$/i;
		var elements = document.forms[0].elements;
			for(var i = 0; i < elements.length && !showMessage; i++)
		{
			var element = elements[i];
				if(element && element.name && /.*\.ssn$/i.test(element.name))
			{
				if(element.value.trim().length == 0)
				{
						var nameParts = element.name.split(".ssn");
						var relationElmtName = nameParts[0] + ".relation";
						var relationElmt = document.getElementsByName(relationElmtName);
						if(!relationElmt || !relationElmt[0])
						{
							relationElmtName = nameParts[0] + ".relationship";
							relationElmt = document.getElementsByName(relationElmtName);
						}
						
						if(relationElmt && relationElmt[0] && relationElmt[0].tagName == "SELECT")
						{
							var options = relationElmt[0].options;
							if(options)
							{
								for(var j = 0; j < options.length; j++)
								{
									var option = options[j];
									if(option && option.selected && spouseOrPartner.test(option.text))
									{
										//alert(option.text);
					showMessage = true;
					break;
				}
			}
		}
	}
						else if(relationElmt && relationElmt[0] && relationElmt[0].tagName == "INPUT" && (spouseOrPartner.test(relationElmt[0].value) || relationElmt[0].value =="1"))
						{
							//alert(relationElmt[0].value);
							showMessage = true;
						}
					}
				}
			}
		}
	
	if(showMessage)
	{
	  var msg = 'Please consider entering your valid Social Security Number to help us more quickly process your application. ' +
	            'Your Social Security Number will be kept confidential and will only be used to help us process your application. ' +
	            'Providing your Social Security Number is not mandatory.\n\n' +
                '            Click "OK" to go back and enter your SSN or "Cancel" to continue to the next page.';
    /*            
	 	var msg = 'Please consider entering your social security number to help us more quickly process your application. ' +
	 			  'Providing your social security number is not mandatory. ' +
	 			  'If you choose to provide it, we will keep it confidential and use it only to help us process your application.' +
	 			  '\n\nClick "OK" to enter your social security number or "Cancel" to continue to the next page.';
	*/ 			  
	 	/*
	 	var msg = 'Please consider entering your social security number to help us more quickly process your application. ' +
	 			  'Providing your social security number is not mandatory. ' +
 			  	  'If you choose to provide it, we will keep it confidential and use it only to help us process your application.' +
	 			  '\n\n                   Click "OK" to go back and enter your SSN or "Cancel" to continue to the next page.';
	 	*/
		if(confirm(msg))
   		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	return true;
}
	catch(e)
	{
		//alert("oops" + e);
		return true;
	}
}


//do nothing except send a request to server to extend server session 
//whenever mosuse clicked or key pressed 
// (at most send 1 request in a minute, no matter how many keypress or mouse clicked in the minute)
function ajaxExtendServerSession()
{
    var currentDate = new Date();
    //same request string (in the same 5 minutes) will not cause "get" request send to server
    var currentAdjustedMin = Math.floor(currentDate.getMinutes() / 5);
    var currentDateStr = currentDate.getFullYear() + "-" + currentDate.getUTCMonth() + "-"  + currentDate.getDate() 
       + "-" + currentDate.getHours() + "-" + currentAdjustedMin;
	var xmlHttp = GetXmlHttpObject();
	
	xmlHttp.onreadystatechange = function()
		{
			if (xmlHttp.readyState == 4)
			{ 
				if(xmlHttp.status  == 200) 
		        {
		          var responseTxt = xmlHttp.responseText;
		          if("Session Alive" != responseTxt)
		          {
		            submitForm(loginUrl);
		          }
		       	}
			}
		}
	
	xmlHttp.open('GET', '/roi/servlets/express?displayAction=ExtendSessionService&currentDate=' + currentDateStr, true);
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send('');
	//no need 5 minutes warning per Brian
//	if(adjustedMin != currentAdjustedMin) //reset the timer if within a different 5-minute period
//	{
//	  adjustedMin = currentAdjustedMin;
//      clearTimeout(timerId);
//      timerId = self.setTimeout("remind5MinutesLeft()", 1500000);//5 minutes left warning
//	}
} 

//function remind5MinutesLeft()
//{
//  timer5TimeoutId = self.setTimeout("timeoutMsg()", 10000);//70 secs warning (5 secs before time out)
//  alert("Your session will timeout in 5 minutes if there is no activity.");
//  ajaxExtendServerSession();
//}

//ajax to detect if session really timed out, no need javascript alert
//function timeoutMsg()
//{
//  alert("Your session has timed out for security reasons.  Please click \"OK\" to login again to complete your application.");  
//  window.location.reload( true );
//}


function toggleDynamicDiv(yesNoChoiceName, divId)
{
	var yesNoChoice = document.getElementsByName(yesNoChoiceName);
	var div = document.getElementById(divId);
	if(!yesNoChoice || !div)
	{
		return;
	}
	
	var diplayOption = "none";
	for(var i = 0; i < yesNoChoice.length; i++)
	{
		if(yesNoChoice[i].checked && (yesNoChoice[i].value == "Y" || yesNoChoice[i].value == "yes"))
		{
			diplayOption = "block";
			break;
		}
	}
	
	div.style.display = diplayOption;
}

function hideDynamicDivForYes(yesNoChoiceName, divId)
{
	var yesNoChoice = document.getElementsByName(yesNoChoiceName);
	var div = document.getElementById(divId);
	if(!yesNoChoice || !div)
	{
		return;
	}
	
	var diplayOption = "block";
	for(var i = 0; i < yesNoChoice.length; i++)
	{
		if(yesNoChoice[i].checked && yesNoChoice[i].value == "Y")
		{
			diplayOption = "none";
			break;
		}
	}
	
	div.style.display = diplayOption;
}

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() 
{
	return window.innerWidth != null? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
} 

function pageHeight() 
{
	return  window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
} 

function posLeft() 
{
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset :document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
} 

function posTop() 
{
	return typeof window.pageYOffset != 'undefined' ?  window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
} 

function posRight() 
{
	return posLeft()+pageWidth();
} 

function posBottom() 
{
	return posTop()+pageHeight();
}

function clearTextWidgetValue(widgetName)
{
  var textWidget = document.getElementsByName(widgetName);
  //textWidget exist & has value property (in case someone pass in an widget which does not have value property)
  if(textWidget && textWidget.length > 0 && textWidget[0].value) 
  {
    textWidget[0].value = "";
  }
}


function clearDropdownWidgetValue(widgetName)
{
  var dropdownWidget = document.getElementsByName(widgetName);
  //dropdownWidget exist & has selectedIndex property (in case someone pass in an widget which does not have selectedIndex property)
  if(dropdownWidget && dropdownWidget.length > 0 && dropdownWidget[0].selectedIndex) 
  {
     dropdownWidget[0].selectedIndex = -1;
  }
}


function acceptNumberOnly(objEvent)
{
    var reValidChars = /\d/;
    var iKeyCode = objEvent.which ? objEvent.which : objEvent.keyCode;
    var objInput = objEvent.target ? objEvent.target : objEvent.srcElement;
    var strKey = String.fromCharCode(iKeyCode);

	if(iKeyCode == 9 || iKeyCode == 8 || iKeyCode == 37 || iKeyCode == 39)
	{
		return true;
	}
    return reValidChars.test(strKey);
}
