
// *******************************************************************************
// Description: Using JavaScript to validate forms for www.401ek.com. 
// This file includes all functions for special cases in some forms. 
// @ 2000 SBSB
// Author: Tam Nguyen
// *******************************************************************************

//################################################################################
//# Name: main_valid()
//# Purpose:
//#	This page contains all the functions that are validating all types of data,
//#	such as, validate numerical, alpha, email, date, empty fields, etc.
//#	Other validate functions will call this function within their functions.
//# Name of all the functions:
//#	isEmpty()	isNum()
//#	checkdate()	numericOnly()
//#	trim()		isPosInteger()
//#	isMoney()	validEmail()
//#	checkRadio()
//################################################################################
function check(field)
{
	if (field.length!=3)
	{
		alert("try again.");
		return false;
	}
return true;
}
function numFix(myData)
{
//format numbers
	var mrVar;
	if (isNaN(myData))
	{
		myData = 0;
	}
	if (myData == "")
	{
		myData = 0;
	}
	mrVar = parseFloat(myData);
	return mrVar
}

function isNum(passedVal) 
{
	//if (passedVal == "") 
	//{
		//return false
	//}
	for (i=0; i<passedVal.length; i++) 
	{
		if (passedVal.charAt(i) < "0") 
		{
			return false
		}
		if (passedVal.charAt(i) > "9") 
		{
			return false
		}
	}
	return true
}

// Removes all characters which are not digits from a string
// Except comma or comma colon
function numericOnly(sString)
{
	var sNumericOnly = "";
	var sValidChars = "1234567890,.-()/";
	for (var iCharPos = 0; iCharPos < sString.length; iCharPos++)
	{
		if (sValidChars.indexOf(sString.charAt(iCharPos)) != -1)
			sNumericOnly = sNumericOnly + sString.charAt(iCharPos);
	}
	
	return sNumericOnly;
}
function isNumMoney(sString)
{
	var sNumericOnly = "";
	var sValidChars = "1234567890,.";
	for (var iCharPos = 0; iCharPos < sString.length; iCharPos++)
	{
		if (sValidChars.indexOf(sString.charAt(iCharPos)) != -1)
			sNumericOnly = sNumericOnly + sString.charAt(iCharPos);
	}
	
	return sNumericOnly;
}

function validate(field) 
{
	var valid = "0123456789()- "
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") 
	{
		alert("Invalid entry!  Only numbers and these characters () - are accepted!");
		field.focus();
		field.select();
   }
}

function isEmpty(inputStr) 
{
	if((inputStr==null) || (inputStr=="")) 
	{
		return true;
	}
	return false;
}

// Check for a blank field
function isFieldBlank(theField)
{
	if(theField.value == "")
        return true;
else
        return false;
}

function isPosInteger(inputStr) 
{
	var inputVal;
	inputStr = inputVal.toString()
	for (var i = o; i<inputStr.length; i++) 
	{
		var oneChar = inputStr.charAt(i)
		if (oneChar < "0" || oneChar> "9") 
		{
			return false
		}
	}
	return true;
}
function isMoney(field) 
{
	var valid = "0123456789,."
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	if (ok == "no") 
	{
		alert("Please do not enter any non-numeric characters. These formats are accepted (5000 or 5,000)");
		field.focus();
		field.select();
   }
}

function isSSN1(SSN1) 
{
	if (SSN1.length=="")
	{
		return true;
	}
	if (SSN1.length !=3) 
	{
		return false;
	}
	if (isNum(SSN1)) 
	{
		return true
	}
	return false;
}	
function isSSN2(SSN2) 
{
	if (SSN2.length=="")
	{
		return true;
	}
	if (SSN2.length !=2) 
	{
		return false;
	}
	if (isNum(SSN2)) 
	{
		return true
	}
	return false;
}
function isSSN3(SSN3) 
{
	if (SSN3.length=="")
	{
		return true;
	}
	if (SSN3.length !=4) 
	{
		return false;
	}
	if (isNum(SSN3)) 
	{
		return true
	}
	return false;
}

function isThree(field) 
{
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
		if (field.length !=3)
		{
			ok1 = "no1";
		}		
	}
	if ((ok == "no") ||(ok1 == "no1"))
	{
		alert("Please enter 3 digit numbers here.");
		field.focus();
		field.select();
   }
}
function isFour(field) 
{
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
		if (field.length != 4)
		{
			ok = "no";
		}
	}
	if (ok == "no") 
	{
		alert("Please enter 4 digit numbers here.");
		field.focus();
		field.select();
   }
}

function isExt(field) 
{
	var valid = "0123456789"
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) 
	{
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") 
		{
			ok = "no";
		}
		if (field.length > 4)
		{
			ok = "no";
		}
	}
	if (ok == "no") 
	{
		alert("Invalid entry.  Please re-enter your extension numbers.");
		field.focus();
		field.select();
   }
}


function isTax1(Tax1) 
{
	if (Tax1 == "") 
	{
		return true;
	}
	if (Tax1.length !=2) 
	{
		return false;
	}
	if (isNum(Tax1)) 
	{
		return true;
	}
	return false;
}	
function isTax2(Tax2) 
{
	if (Tax2 == "") 
	{
		return true;
	}
	if (Tax2.length !=7) 
	{
		return false;
	}
	if (isNum(Tax2)) 
	{
		return true;
	}
	return false;
}
function validEmail(email) 
{
         invalidChars = " /:,;"   
         //if (email == "") 
         //{
         //   return false
         //}
         
         for (i=0; i<invalidChars.length; i++) 
         {
         	badChar = invalidChars.charAt(i)
         	if (email.indexOf(badChar,0) > -1) 
         	{
               return false
            }
         }
         atPos = email.indexOf("@",1)
         if (atPos == -1) 
         {
            	return false
         }
         if (email.indexOf("@",atPos+1) > -1) 
         {
          	return false
         }
         periodPos = email.indexOf(".",atPos)
         if (periodPos == -1) 
         {
         	return false
         }
         if (periodPos+3 > email.length)   
         {
         	return false
         }
         return true
}

function checkRadio(radioGroup)
{
  for (var i = 0; i < radioGroup.length; i++)
  {
  	if (radioGroup[i].checked == true)
		return true;
  }
  return false;
}
function isEmail(string) {
	if((string==null) || (string==""))
		return true;
    else if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}
function isFullTwo(string) {
    if (string.length != 2) {return true};
    return false;
}
function isFullThree(string) {
    if (string.length != 3) {return true};
    return false;
}
function isFullFour(string) {
    if (string.length != 4) {return true};
    return false;
}
function isFullSeven(string) {
    if (string.length != 7) {return true};
    return false;
}
function isPropLength(string) {
    if ((string.length <5) || (string.length > 10)){return true};
    return false;
}
// #################################################################################
// Name: checkAddMembers()
// Purpose:
// This function is validate AddMember.asp on the ghba website; 
//validates some validation on a lot of form objects that may or
//may not be created as arrays
// #################################################################################
function checkAddMembers(theForm)
{
	//check to see if the radio button is an array or not
	chkArray = theForm.Plan.length;
	//alert((isNaN(parseFloat(chkArray))));
	if ((isNaN(parseFloat(chkArray))))
		{
		if(theForm.Plan.checked == false)
			{
			alert("You forgot to check the Medical Plan.");
			theForm.Plan.focus();
			return false;
			}
		}	
	
	//else it's an array
	else //if ((isNaN(parseFloat(chkArray))==false))
		{
		if(checkRadio(document.theForm.Plan) == false)
			{
				alert("Please Choose one of the  Medical Plans.");
				
				return false;
			}
		}

numcoState=theForm.EFFMonth.selectedIndex
	if(isEmpty(theForm.EFFMonth.options[numcoState].value))
	{
		alert("Please select your Effective Start Month.");
		theForm.EFFMonth.focus();
		return false;
	}
	numcoState=theForm.EFFDay.selectedIndex
	if(isEmpty(theForm.EFFDay.options[numcoState].value))
	{
		alert("Please select your Effective Start Day.");
		theForm.EFFDay.focus();
		return false;
	}
	numcoState=theForm.EFFYear.selectedIndex
	if(isEmpty(theForm.EFFYear.options[numcoState].value))
	{
		alert("Please select your Effective Start Year.");
		theForm.EFFYear.focus();
		return false;
	}
	if(isEmpty(theForm.FirstName.value))
	{
		alert("Please enter your first name.");
		theForm.FirstName.focus();
		return false;
	}
	if(isEmpty(theForm.Name.value))
	{
		alert("Please enter your last name.");
		theForm.Name.focus();
		return false;
	}
	
	if(isEmpty(theForm.SSN1.value) ||(!numericOnly(theForm.SSN1.value)))
	{
		alert("Please enter your first 3 digits in your social security");
		theForm.SSN1.focus();
		return false;
	}
	if(isEmpty(theForm.SSN2.value) || (!numericOnly(theForm.SSN2.value)))
	{
		alert("Please enter your middle 2 digits in your social security.");
		theForm.SSN2.focus();
		return false;
	}
	if(isEmpty(theForm.SSN3.value) || (!numericOnly(theForm.SSN3.value)))
	{
		alert("Please enter your last 4 digits in your social security.");
		theForm.SSN3.focus();
		return false;
	}
	numcoState=theForm.DOBMonth.selectedIndex
	if(isEmpty(theForm.DOBMonth.options[numcoState].value))
	{
		alert("Please select Date of Birth Month.");
		theForm.DOBMonth.focus();
		return false;
	}
	numcoState=theForm.DOBDay.selectedIndex
	if(isEmpty(theForm.DOBDay.options[numcoState].value))
	{
		alert("Please select Date of Birth Day.");
		theForm.DOBDay.focus();
		return false;
	}
	numcoState=theForm.DOBYear.selectedIndex
	if(isEmpty(theForm.DOBYear.options[numcoState].value))
	{
		alert("Please select Date of Birth Year.");
		theForm.DOBYear.focus();
		return false;
	}
	if(isEmpty(theForm.AddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.AddressLine1.focus();
		return false;
	}
	if(isEmpty(theForm.City.value))
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return false;
	}	
	numcoState=theForm.coState.selectedIndex
	if(isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state.");
		theForm.coState.focus();
		return false;
	}	
	if(isEmpty(theForm.Zip.value) || (!numericOnly(theForm.Zip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.Zip.focus();
		return false;
	}
/*
	if(isEmpty(theForm.Password.value))
	{
		alert("Please choose a password(upto 10 characters).");
		theForm.Password.focus();
		return false;
	}
	
	if(isEmpty(theForm.Password2.value))
	{
		alert("Please re-type your password");
		theForm.Password2.focus();
		return false;
	}
	if((theForm.Password.value) !=(theForm.Password2.value))
	{
		alert("Your password is not matched. Please re-type your password.");
		theForm.Password2.focus();
		return false;
	}
*/
}

// #################################################################################
// Name: checkAddMembers()
// Purpose:
// This function is validate AddMember.asp on the ghba website; 
//validates some validation on a lot of form objects that may or
//may not be created as arrays
// #################################################################################
function checkNewMembers(theForm)
{
	//alert(theForm.advancedfunction.value);
	if(isEmpty(theForm.FirstName.value))
	{
		alert("Please enter your First Name.");
		theForm.FirstName.focus();
		return false;
	}
	numcoState=theForm.DOBMonth.selectedIndex
	if(isEmpty(theForm.DOBMonth.options[numcoState].value))
	{
		alert("Please select Date of Birth Month.");
		theForm.DOBMonth.focus();
		return false;
	}
	numcoState=theForm.DOBDay.selectedIndex
	if(isEmpty(theForm.DOBDay.options[numcoState].value))
	{
		alert("Please select your Date of Birth Day.");
		theForm.DOBDay.focus();
		return false;
	}
	numcoState=theForm.DOBYear.selectedIndex
	if(isEmpty(theForm.DOBYear.options[numcoState].value))
	{
		alert("Please select your Date of Birth Year.");
		theForm.DOBYear.focus();
		return false;
	}
	
	if(isEmpty(theForm.City.value) )
	{
		alert("Please enter your City.");
		theForm.City.focus();
		return false;
	}
	numcoState=theForm.coState.selectedIndex
	if(isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state.");
		theForm.coState.focus();
		return false;
	}
	
	if(isEmpty(theForm.Zip.value) || (!numericOnly(theForm.Zip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.Zip.focus();
		return false;
	}
	else //check to make sure it is a valid zipcode
	{
	//MA valid zips are from 01001 to 02791 but andover,MA is 05544
	//NH valid zips are 03031 to 03897 no exceptions
		if(theForm.coState.options[numcoState].value =="MA")
		{
			if ((theForm.Zip.value < "01001")||((theForm.Zip.value > "02791")&&(theForm.Zip.value != "05544")))
			{
				alert("This Zip Code is not valid for Massachusetts.\nPlease Check the Zip and try again.");
				theForm.Zip.focus();
				return false;
			}
		}
		if(theForm.coState.options[numcoState].value =="NH")
		{
			if ((theForm.Zip.value < "03031")||(theForm.Zip.value > "03897"))
			{
				alert("This Zip Code is not valid for New Hampshire.\nPlease Check the Zip and try again.");
				theForm.Zip.focus();
				return false;
			}
		}
	}
	if (theForm.dependents.value=="0")
		{
	theForm.action="FinalizeAddEmployee.asp";
		}
	else
		{
	
		}
	
}

// #################################################################################
// Name: checkAddEmployer()
// Purpose:
// This function is validate AddEmployer.asp
// #################################################################################
function checkAddEmployer(theForm)
{
	if(isEmpty(theForm.EmployerName.value))
	{
		alert("Please enter your business name.");
		theForm.EmployerName.focus();
		return false;
	}
	if ((isEmpty(theForm.TaxID1.value))||(!isNum(theForm.TaxID1.value)))
	{
		alert("Please enter the first 2 digits of your Tax ID (must be numeric).");
		theForm.TaxID1.focus();
		return false;
	}
	if (!isTax1(theForm.TaxID1.value)) {
		alert("Please enter the first 2 digits of your Tax ID (must be numeric).")
		theForm.TaxID1.focus();
		return false;
	}
	if ((isEmpty(theForm.TaxID2.value))||(!isNum(theForm.TaxID2.value)))
	{
		alert("Please enter the last 7 digits of your Tax ID (must be numeric).");
		theForm.TaxID2.focus();
		return false;
	}	
	if (!isTax2(theForm.TaxID2.value)) {
		alert("Please enter the last 7 digits of your Tax ID (must be numeric).")
		theForm.TaxID2.focus();
		return false;
	}
	if (!theForm.EstabDateMM.selectedIndex)
	{
		alert("Please select the month.");
		theForm.EstabDateMM.focus();
		return false;
	}	
	if (!theForm.EstabDateDD.selectedIndex)
	{
		alert("Please select the day.");
		theForm.EstabDateMM.focus();
		return false;
	}
	if (!theForm.EstabDateYYYY.selectedIndex)
	{
		alert("Please select the year.");
		theForm.EstabDateYYYY.focus();
		return false;
	}	
	
}

// #################################################################################
// Name: checkAddBroker()
// Purpose:
// This function is validate AddBroker.asp
// #################################################################################
function checkAddBroker(theForm)
{
	if(isEmpty(theForm.Name.value))
	{
		alert("Please enter your name.");
		theForm.Name.focus();
		return false;
	}
	
	if(isEmpty(theForm.SSN1.value) ||(!numericOnly(theForm.SSN1.value)))
	{
		alert("Please enter your 3 digits social security");
		theForm.SSN1.focus();
		return false;
	}
	if(isEmpty(theForm.SSN2.value) || (!numericOnly(theForm.SSN2.value)))
	{
		alert("Please enter your 2 digits social security.");
		theForm.SSN2.focus();
		return false;
	}
	if(isEmpty(theForm.SSN3.value) || (!numericOnly(theForm.SSN3.value)))
	{
		alert("Please enter your 3 digits social security.");
		theForm.SSN3.focus();
		return false;
	}
	if(isEmpty(theForm.AddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.AddressLine1.focus();
		return false;
	}
	if(isEmpty(theForm.City.value))
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return false;
	}	
	numcoState=theForm.coState.selectedIndex
	if(isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state.");
		theForm.coState.focus();
		return false;
	}	
	if(isEmpty(theForm.Zip.value) || (!numericOnly(theForm.Zip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.Zip.focus();
		return false;
	}
	if(isEmpty(theForm.Password.value))
	{
		alert("Please choose a password(upto 10 characters).");
		theForm.Password.focus();
		return false;
	}
	
	if(isEmpty(theForm.Password2.value))
	{
		alert("Please re-type your password");
		theForm.Password2.focus();
		return false;
	}
	if((theForm.Password.value) !=(theForm.Password2.value))
	{
		alert("Your password is not matched. Please re-type your password.");
		theForm.Password2.focus();
		return false;
	}
}
// #################################################################################
// Name: checkAgentDetail()
// Purpose:
// This function is validate checkAgentDetail.asp
// #################################################################################
function checkAgentDetail(theForm)
{
	if(isEmpty(theForm.Name.value))
	{
		alert("Please enter your name.");
		theForm.Name.focus();
		return false;
	}
	if(isEmpty(theForm.AddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.AddressLine1.focus();
		return false;
	}
	if(isEmpty(theForm.City.value))
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return false;
	}	
	numcoState=theForm.coState.selectedIndex
	if(isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state.");
		theForm.coState.focus();
		return false;
	}	
	if(isEmpty(theForm.Zip.value) || (!numericOnly(theForm.Zip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.Zip.focus();
		return false;
	}
	if (!isNum(theForm.Phone1.value))
	{
		alert("Please enter a valid numeric area code.");
		theForm.Phone1.focus();
		return false;
	}
	
	if (!isNum(theForm.Phone2.value))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.Phone2.focus();
		return false;
	}

	if (!isNum(theForm.Phone3.value))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.Phone3.focus();
		return false;
	}
	
	if (!isNum(theForm.Phone4.value))
	{
		alert("Please enter a valid numeric phone extension.");
		theForm.Phone4.focus();
		return false;
	}

	if (!isNum(theForm.Fax1.value))
	{
		alert("Please enter a valid numeric fax area code.");
		theForm.Fax1.focus();
		return false;
	}
	
	if (!isNum(theForm.Fax2.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.Fax2.focus();
		return false;
	}

	if (!isNum(theForm.Fax3.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.Fax3.focus();
		return false;
	}
	
	if ((!validEmail(theForm.Email.value))&&(!isEmpty(theForm.Email.value)))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.Email.value=""
		theForm.Email.select();
		theForm.Email.focus();
		return false;
	}		
}

// #################################################################################
// Name: checkAddTrustee()
// Purpose:
// This function is validate addTrust.asp
// #################################################################################
function checkAddTrustee(theForm)
{
	if(isEmpty(theForm.Name.value))
	{
		alert("Please enter your name.");
		theForm.Name.focus();
		return false;
	}
	
	
	if(isEmpty(theForm.TAddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.TAddressLine1.focus();
		return false;
	}
	if(isEmpty(theForm.TCity.value))
	{
		alert("Please enter your city.");
		theForm.TCity.focus();
		return false;
	}	
	numcoState=theForm.coTState.selectedIndex
	if(isEmpty(theForm.coTState.options[numcoState].value))
	{
		alert("Please select your state.");
		theForm.coTState.focus();
		return false;
	}	
	if(isEmpty(theForm.TZip.value) || (!numericOnly(theForm.TZip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.TZip.focus();
		return false;
	}
	if (!isNum(theForm.TPhone1.value))
	{
		alert("Please enter a valid numeric area code.");
		theForm.TPhone1.focus();
		return false;
	}
	
	if (!isNum(theForm.TPhone2.value))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.TPhone2.focus();
		return false;
	}

	if (!isNum(theForm.TPhone3.value))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.TPhone3.focus();
		return false;
	}
	
	if (!isNum(theForm.TPhone4.value))
	{
		alert("Please enter a valid numeric phone extension.");
		theForm.TPhone4.focus();
		return false;
	}

	if (!isNum(theForm.TFax1.value))
	{
		alert("Please enter a valid numeric fax area code.");
		theForm.TFax1.focus();
		return false;
	}
	
	if (!isNum(theForm.TFax2.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.TFax2.focus();
		return false;
	}

	if (!isNum(theForm.TFax3.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.TFax3.focus();
		return false;
	}
	if ((!validEmail(theForm.TEmail.value))&&(!isEmpty(theForm.TEmail.value)))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.TEmail.value=""
		theForm.TEmail.select();
		theForm.TEmail.focus();
		return false;
	}	
}
// #################################################################################
// Name: checkBrokerReg()
// Purpose:
// This function is validate brokerReg.asp
// #################################################################################
function checkBrokerReg(theForm)
{
	if(isEmpty(theForm.FirstName.value))
	{
		alert("Please enter your first name.");
		theForm.FirstName.focus();
		return false;
	}
	if(isEmpty(theForm.LastName.value))
	{
		alert("Please enter your last name.");
		theForm.LastName.focus();
		return false;
	}
	if(isEmpty(theForm.TaxID1.value) ||(!numericOnly(theForm.TaxID1.value)))
	{
		alert("Please enter your 2 digits Tax ID");
		theForm.TaxID1.focus();
		return false;
	}
	if(!isTax1(theForm.TaxID1.value))
	{
		alert("Invalid entry. Please re-enter the first 2 digits of your Tax ID.");
		theForm.TaxID1.focus();
		return false;
	}
	if(isEmpty(theForm.TaxID2.value) || (!numericOnly(theForm.TaxID2.value)))
	{
		alert("Please enter your 7 digits Tax ID.");
		theForm.TaxID2.focus();
		return false;
	}
	if(!isTax2(theForm.TaxID2.value))
	{
		alert("Invalid entry. Please re-enter the second 7 digits of your Tax ID.");
		theForm.TaxID2.focus();
		return false;
	}

	if(isEmpty(theForm.AddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.AddressLine1.focus();
		return false;
	}
	if(isEmpty(theForm.City.value))
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return false;
	}	
	numcoState=theForm.coState.selectedIndex
	if(isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state.");
		theForm.coState.focus();
		return false;
	}	
	if(isEmpty(theForm.Zip.value) || (!numericOnly(theForm.Zip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.Zip.focus();
		return false;
	}
	if ((!isNum(theForm.Phone1.value))||(isEmpty(theForm.Phone1.value)))
	{
		alert("Please enter a valid numeric area code.");
		theForm.Phone1.focus();
		return false;
	}
	
	if ((!isNum(theForm.Phone2.value))||(isEmpty(theForm.Phone2.value)))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.Phone2.focus();
		return false;
	}

	if ((!isNum(theForm.Phone3.value))||(isEmpty(theForm.Phone3.value)))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.Phone3.focus();
		return false;
	}
	if (isEmpty(theForm.Email.value))
	{
		alert("Please enter your email address.");
		theForm.Email.focus();
		return false;
	}

	if ((!validEmail(theForm.Email.value))&&(!isEmpty(theForm.Email.value)))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.Email.value=""
		theForm.Email.select();
		theForm.Email.focus();
		return false;
	}	
	/*if ((!validEmail(theForm.Email.value))&&(!isEmpty(theForm.Email.value)))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.Email.value=""
		theForm.Email.select();
		theForm.Email.focus();
		return false;
	}	*/
	if(isEmpty(theForm.LicState.options[theForm.LicState.selectedIndex].value))
	{
		alert("Please select your license state.");
		theForm.LicState.focus();
		return false;
	}	
	if (isEmpty(theForm.LicNumber.value))
	{
		alert("Please enter your license number.");
		theForm.LicNumber.focus();
		return false;
	}
	if (isEmpty(theForm.EffectiveDate.value))
	{
		alert("Please enter your effective date.");
		theForm.EffectiveDate.focus();
		return false;
	}
	if(isEmpty(theForm.PolicyNum.value))
	{
		alert("Please enter policy number.");
		theForm.PolicyNum.focus();
		return false;
	}
	if(isEmpty(theForm.PeriodFrom.value))
	{
		alert("Please enter period from.");
		theForm.PeriodFrom.focus();
		return false;
	}
	if(isEmpty(theForm.PeriodTo.value))
	{
		alert("Please enter period to.");
		theForm.PeriodTo.focus();
		return false;
	}
	if(isEmpty(theForm.LegalLoss.value))
	{
		alert("Please enter legal liability, each loss.");
		theForm.LegalLoss.focus();
		return false;
	}
	if(isEmpty(theForm.LegalAggregate.value))
	{
		alert("Please enter legal liability, aggregate.");
		theForm.LegalAggregate.focus();
		return false;
	}
/*
	if(isEmpty(theForm.Password2.value))
	{
		alert("Please re-type your password");
		theForm.Password2.focus();
		return false;
	}
	if((theForm.Password.value) !=(theForm.Password2.value))
	{
		alert("Your password is not matched. Please re-type your password.");
		theForm.Password2.focus();
		return false;
	}
*/

}

// #################################################################################
// Name: checkBrokerBySSN()
// Purpose:
// This function is validate BrokerBySSN.asp
// #################################################################################
function checkBrokerBySSN(theForm)
{
	if((isEmpty(theForm.SSN1.value))||(isNaN(theForm.SSN1.value)))
	{
		alert("Please enter 3 digits of your social security number.!!");
		theForm.SSN1.focus();
		return false;
	}	
	if(!isSSN1(theForm.SSN1.value))
	{
		alert("Invalid entry. Please re-enter the first 3 digits of your SSN.");
		theForm.SSN1.focus();
		return false;
	}
	if((isEmpty(theForm.SSN2.value))||(isNaN(theForm.SSN2.value)))
	{
		alert("Please enter 2 digits of your social security number.");
		theForm.SSN2.focus();
		return false;
	}	
	if(!isSSN2(theForm.SSN2.value))
	{
		alert("Invalid entry. Please re-enter the first 2 digits of your SSN.");
		theForm.SSN2.focus();
		return false;
	}
	if((isEmpty(theForm.SSN3.value))||(isNaN(theForm.SSN3.value)))
	{
		alert("Please enter 4 digits of your social security number.");
		theForm.SSN3.focus();
		return false;
	}	
	if(!isSSN3(theForm.SSN3.value))
	{
		alert("Invalid entry. Please re-enter the first 4 digits of your SSN.");
		theForm.SSN3.focus();
		return false;
	}	
}


//******************************************************************************************************************
//Special case for EmployerInfo.asp
//This function will validate EmployerInfo.asp
//Here is the list of un-required fields:
// Fax, Email, second address
//*******************************************************************************************************************
function checkEmployerInfo(theForm)
{
	//Validate Employer Information
	if (isEmpty(theForm.EmployerName.value))
	{
		alert("Please enter your employer name.");
		theForm.EmployerName.focus();
		return false;
	}
	//check to see if the radio button is an array or not
	chkArray = theForm.Plan.length;
	//alert((isNaN(parseFloat(chkArray))));
	if ((isNaN(parseFloat(chkArray))))
		{
		if(theForm.Plan.checked == false)
			{
			alert("You forgot to check the Medical Plan.");
			theForm.Plan.focus();
			return false;
			}
			else 
			{
			theForm.PlanArray.value = theForm.Plan.value;
			theForm.PlanDate.value = theForm.EFFMonth.value + "/" + theForm.EFFDay.value + "/" + theForm.EFFYear.value;
			
			}
			
		}	
	
	//else it's an array
	else //if ((isNaN(parseFloat(chkArray))==false))
		{
		//alert((isNaN(parseFloat(chkArray))));
		if(checkRadio(document.theForm.Plan) == false)
			{
				alert("Please Choose one of the  Medical Plans.");
				
				return false;
			}
			else 
			{
				for (var i = 0; i < theForm.Plan.length; i++)
				{
				if (theForm.Plan[i].checked == true) 
					{
					theForm.PlanArray[i].value = theForm.Plan[i].value;
					theForm.PlanDate[i].value = theForm.EFFMonth[i].value + "/" + theForm.EFFDay[i].value + "/" + theForm.EFFYear[i].value;
					//alert(theForm.PlanDate[i].value);
					}
					else
					{
					theForm.PlanArray[i].value = "";
					theForm.PlanDate[i].value = "";
					//alert(theForm.PlanDate[i].value);
					}
				}
				
			}
	}
	if (isEmpty(theForm.AddressLine1.value))
	{
		alert("Please enter your address1.");
		theForm.AddressLine1.focus();
		return false;
	}
	if (isEmpty(theForm.City.value))
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return false;
	}
	numcoState=theForm.coState.selectedIndex
	if (isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state");
		theForm.coState.focus();
		return false;
	}
	if ((isEmpty(theForm.Zip.value))||(!isNum(theForm.Zip.value)))
	{
		alert("Please enter a valid numeric zip code.");
		theForm.Zip.focus();
		return false;
	}
	else //check to make sure it is a valid zipcode
	{
		//MA valid zips are from 01001 to 02791 but andover,MA is 05544
		//NH valid zips are 03031 to 03897 no exceptions
		if(theForm.coState.options[numcoState].value =="MA")
		{
			if ((theForm.Zip.value < "01001")||((theForm.Zip.value > "02791")&&(theForm.Zip.value != "05544")))
			{
				alert("This Zip Code is not valid for Massachusetts.\nPlease Check the Zip and try again.");
				theForm.Zip.focus();
				return false;
			}
		}
		if(theForm.coState.options[numcoState].value =="NH")
		{
			if ((theForm.Zip.value < "03031")||(theForm.Zip.value > "03897"))
			{
				alert("This Zip Code is not valid for New Hampshire.\nPlease Check the Zip and try again.");
				theForm.Zip.focus();
				return false;
			}
		}
	}
	if (theForm.Zip.value.length < 5 )
	{
		alert("Not enough zip code digits.");
		theForm.Zip.focus();
		return false;
	}
	
//	if (!isNum(theForm.Zip.value))
	//{
	//	alert("Your zip code has to be in this format (11111 or 11111-1111).");
	//	theForm.Zip.focus();
	//	return false;
//	}

	if ((!isNum(theForm.Phone1.value))||(isEmpty(theForm.Phone1.value)))
	{
		alert("Please enter a valid numeric area code.");
		theForm.Phone1.focus();
		return false;
	}
	
	if ((!isNum(theForm.Phone2.value))||(isEmpty(theForm.Phone2.value)))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.Phone2.focus();
		return false;
	}

	if ((!isNum(theForm.Phone3.value))||(isEmpty(theForm.Phone3.value)))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.Phone3.focus();
		return false;
	}
	
	if (!isNum(theForm.Phone4.value))
	{
		alert("Please enter a valid numeric phone extension.");
		theForm.Phone4.focus();
		return false;
	}

	if (!isNum(theForm.Fax1.value))
	{
		alert("Please enter a valid numeric fax area code.");
		theForm.Fax1.focus();
		return false;
	}
	
	if (!isNum(theForm.Fax2.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.Fax2.focus();
		return false;
	}

	if (!isNum(theForm.Fax3.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.Fax3.focus();
		return false;
	}
	
	var FaxLength
	FaxLength = (theForm.Fax1.value.length) + (theForm.Fax2.value.length) + (theForm.Fax3.value.length);
	if ((FaxLength != 0)&&(FaxLength != 10))
	{
		alert("Missing Fax Numbers.");
		theForm.Fax1.focus();
		return false;
	}
	
	//if ((!isEmpty(theForm.Email.value))&&(!isEmailValid(theForm.Email))) {return false;}

	
/*	
	if ((isEmpty(theForm.TaxID1.value)) ||(!numericOnly(theForm.TaxID1.value)))
	{
		alert("Please enter the first 2 digits of your Tax ID (must be numeric).");
		theForm.TaxID1.focus();
		return false;
	}
	
	if (!isTax1(theForm.TaxID1.value)) {
		alert("Please enter the first 2 digits of your Tax ID (must be numeric).")
		theForm.TaxID1.focus();
		return false;
	}
	
	if ((isEmpty(theForm.TaxID2.value))||(!numericOnly(theForm.TaxID2.value)))
	{
		alert("Please enter the last 7 digits of your Tax ID (must be numeric).");
		theForm.TaxID2.focus();
		return false;
	}	
	if (!isTax2(theForm.TaxID2.value)) {
		alert("Please enter the last 7 digits of your Tax ID (must be numeric).")
		theForm.TaxID2.focus();
		return false;
	}
*/
}	

//******************************************************************************************************************
//Special case for employerInfo2.asp
//This functioin will validate employerInfo2.asp
//Here is the list of un-required fields:
//*******************************************************************************************************************
function checkEmployerInfo2(theForm)
{

	tmpSelectedIndex=theForm.TypeOfEntity.selectedIndex
	if (isEmpty(theForm.TypeOfEntity.options[tmpSelectedIndex].value))
	{
		alert("Please select your type of Entity.");
		return false;
	}

	if ((theForm.TypeOfEntity.value=="Other")&&(theForm.TypeOfEntityOther.value==""))
	{
		alert("What is the value for Other?");
		theForm.TypeOfEntityOther.focus();
		return false;
	}
	
	if ((theForm.TypeOfEntity.value!="Other")&&(theForm.TypeOfEntityOther.value!=""))
	{
		alert("You may only enter a value for Other when the Type of Entity selection is Other.");
		theForm.TypeOfEntityOther.focus();
		return false;
	}

	
	if (!theForm.EstabDateMM.selectedIndex)
	{
		alert("Please select the month established.");
		theForm.EstabDateMM.focus();
		return false;
	}
	if (!theForm.EstabDateDD.selectedIndex)
	{
		alert("Please select the day established.");
		theForm.EstabDateDD.focus();
		return false;
	}
	if (!theForm.EstabDateYYYY.selectedIndex)
	{
		alert("Please select the year established.");
		theForm.EstabDateYYYY.focus();
		return false;
	}		
	if (!theForm.FiscalYrEndMM.selectedIndex)
	{
		alert("Please select the fiscal year end month.");
		theForm.FiscalYrEndMM.focus();
		return false;
	}	
	if (!theForm.FiscalYrEndDD.selectedIndex)
	{
		alert("Please select the fiscal year end day.");
		theForm.FiscalYrEndDD.focus();
		return false;
	}		
	if (!theForm.FiscalYrEndYYYY.selectedIndex)
	{
		alert("Please select the fiscal year end year.");
		theForm.FiscalYrEndYYYY.focus();
		return false;
	}			

	tmpSelectedIndex=theForm.ControlGroup.selectedIndex
	if (isEmpty(theForm.ControlGroup.options[tmpSelectedIndex].value))	
	{
		alert("Please indicate whether the employer is a member of a controlled group");
		theForm.ControlGroup.focus();
		return false;
	}
	tmpSelectedIndex=theForm.ServiceGroup.selectedIndex
	if (isEmpty(theForm.ServiceGroup.options[tmpSelectedIndex].value))		
	{
		alert("Please indicate whether the employer is a member of an affiliated service group.");
		theForm.ServiceGroup.focus();
		return false;
	}
}	


//******************************************************************************************************************
//Special case for ConInfo.asp
//This function will validate ConInfo.asp
//*******************************************************************************************************************
function checkConInfo(theForm)
{
	if (theForm.IsAllocated.value == "True")
	{
		if (!theForm.Format.selectedIndex)
		{
			alert("Please select a record keeping format.");
			theForm.Format.focus();
			return false;			
		}
	}
	if (theForm.IsFromNY.value == "True")
	{
		if (!theForm.MoneySource.selectedIndex)
		{
			alert("Please select a money source.");
			theForm.MoneySource.focus();
			return false;			
		}
		if ((theForm.MoneySource.value=="Other")&&(theForm.MoneySourceother.value==""))
		{
			alert("Please enter the other money source.");
			theForm.MoneySourceother.focus();
			return false;
		}		
	}	
}

//******************************************************************************************************************
//Special case for Payroll.asp
//This function will validate Payroll.asp
//Here is the list of un-required fields:
// Fax, Email
//*******************************************************************************************************************
function checkPayroll(theForm)
{
	
	if (isEmpty(theForm.ContactName.value))
	{
		alert("Please enter a Contact Name.");
		theForm.ContactName.focus();
		return false;			
	}	
	
	if ((!isNum(theForm.APhone1.value))||(isEmpty(theForm.APhone1.value)))
	{
		alert("Please enter a valid numeric area code.");
		theForm.APhone1.focus();
		return false;
	}
	
	if ((!isNum(theForm.APhone2.value))||(isEmpty(theForm.APhone2.value)))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.APhone2.focus();
		return false;
	}

	if ((!isNum(theForm.APhone3.value))||(isEmpty(theForm.APhone3.value)))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.APhone3.focus();
		return false;
	}
	
	if (!isNum(theForm.APhone4.value))
	{
		alert("Please enter a valid numeric phone extension.");
		theForm.APhone4.focus();
		return false;
	}

	if (!isNum(theForm.AFax1.value))
	{
		alert("Please enter a valid numeric fax area code.");
		theForm.AFax1.focus();
		return false;
	}
	
	if (!isNum(theForm.AFax2.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.AFax2.focus();
		return false;
	}

	if (!isNum(theForm.AFax3.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.AFax3.focus();
		return false;
	}
	
	var FaxLength
	FaxLength = (theForm.AFax1.value.length) + (theForm.AFax2.value.length) + (theForm.AFax3.value.length);
	if ((FaxLength != 0)&&(FaxLength != 10))
	{
		alert("Missing Fax Numbers.");
		theForm.AFax1.focus();
		return false;
	}
		
	
	if ((!validEmail(theForm.AEmail.value))&&(!isEmpty(theForm.AEmail.value)))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.AEmail.value=""
		theForm.AEmail.select();
		theForm.AEmail.focus();
		return false;
	}
//}NOTE: TPAINFO.ASP WAS COMBINED WITH PAYROLL.ASP, THUS THE FOLLOWING LINES ARE COMMENTED OUT...
//******************************************************************************************************************
//Special case for TPAInfo.asp
//This functioin will validate TPAInfo.asp
//Here is the list of un-required fields:
// Fax, Email, second address
//*******************************************************************************************************************
//function checkTPAInfo(theForm)
//{
	// Validate Third Party Administrator Information
	if (isEmpty(theForm.TPAName.value))
	{
		alert("Please enter your third party admin name.");
		theForm.TPAName.focus();
		return false;
	}
	if (isEmpty(theForm.TPAContactName.value))
	{
		alert("Please enter your contact name.");
		theForm.TPAContactName.focus();
		return false;
	}
	if (isEmpty(theForm.AAddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.AAddressLine1.focus();
		return false;
	}
	if (isEmpty(theForm.ACity.value))
	{
		alert("Please enter your city.");
		theForm.ACity.focus();
		return false;
	}
	numcoAState=theForm.coAState.selectedIndex
	if (isEmpty(theForm.coAState.options[numcoAState].value))
	{
		alert("Please select your state.");
		theForm.coAState.focus();
		return false;
	}	
	if (isEmpty(theForm.AZip.value) || (!numericOnly(theForm.AZip.value)))
	{
		alert("Please enter a valid numeric zip code.");
		theForm.AZip.focus();
		return false;
	}
	if (theForm.AZip.value.length < 5 )
	{
		alert("Not enough zip code digits.");
		theForm.AZip.focus();
		return false;
	}	
	if (!isNum(theForm.TPAPhone1.value))
	{
		alert("Please enter a valid numeric area code.");
		theForm.TPAPhone1.focus();
		return false;
	}
	
	if (!isNum(theForm.TPAPhone2.value))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.TPAPhone2.focus();
		return false;
	}

	if (!isNum(theForm.TPAPhone3.value))
	{
		alert("Please enter a valid numeric phone number.");
		theForm.TPAPhone3.focus();
		return false;
	}
	
	if (!isNum(theForm.TPAPhone4.value))
	{
		alert("Please enter a valid numeric phone extension.");
		theForm.TPAPhone4.focus();
		return false;
	}
	var PhoneLength
	PhoneLength = (theForm.TPAPhone1.value.length) + (theForm.TPAPhone2.value.length) + (theForm.TPAPhone3.value.length);
	if ((PhoneLength != 0)&&(PhoneLength != 10))
	{
		alert("Missing Phone Numbers.");
		theForm.TPAPhone1.focus();
		return false;
	}
		

	if (!isNum(theForm.TPAFax1.value))
	{
		alert("Please enter a valid numeric fax area code.");
		theForm.TPAFax1.focus();
		return false;
	}
	
	if (!isNum(theForm.TPAFax2.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.TPAFax2.focus();
		return false;
	}

	if (!isNum(theForm.TPAFax3.value))
	{
		alert("Please enter a valid numeric fax number.");
		theForm.TPAFax3.focus();
		return false;
	}
	var FaxLength
	FaxLength = (theForm.TPAFax1.value.length) + (theForm.TPAFax2.value.length) + (theForm.TPAFax3.value.length);
	if ((FaxLength != 0)&&(FaxLength != 10))
	{
		alert("Missing Fax Numbers.");
		theForm.TPAFax1.focus();
		return false;
	}
		
	if ((!validEmail(theForm.TPAEmail.value))&&(!isEmpty(theForm.TPAEmail.value)))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.TPAEmail.value=""
		theForm.TPAEmail.select();
		theForm.TPAEmail.focus();
		return false;
	}
	//only need to valid email
	//if (!validEmail(theForm.AEmail.value))
	//{
		//alert("Your email is invalid.");
		//theForm.AEmail.focus();
		//return false;
	//}
}

//******************************************************************************************************************
//Special case for Commission.asp
//This function will validate Commission.asp
//*******************************************************************************************************************
function checkCommission(theForm)
{
	numMnE=theForm.MnE.selectedIndex
	if(isEmpty(theForm.MnE.options[numMnE].value))
	{
		alert("Please select your ME")
		theForm.MnE.focus();
		return false;
	}
	numCom=theForm.CommissionOpt.selectedIndex
	if(isEmpty(theForm.CommissionOpt.options[numCom].value))
	{
		alert("Please select your commission option.")
		theForm.CommissionOpt.focus();
		return false;
	}
}

//******************************************************************************************************************
//Special case for FR_Form.asp
//This functioin will validate FR_Form.asp
//*******************************************************************************************************************
function checkFR_Form(theForm)
{
	if (checkRadio(document.forms[0].DocumentsUsed) == false)
	{
		alert("Please check which document will be used.");
		return false;
	}
	if((theForm.DocumentsUsed[2].checked==true)&&(theForm.txtDocumentsUsed.value==""))
	{
		alert("What is the value for Other option?");
		theForm.txtDocumentsUsed.focus();
		return false;
	}
	if (checkRadio(document.forms[0].LoansAvail)==false)
	{
		alert("Please check which loan is available.");
		return false;
	}
	if (isEmpty(theForm.EstPremium.value))
	{
		alert("Please estimate your annual premium flow.");
		theForm.EstPremium.focus();
		return false; 
	}
}
//******************************************************************************************************************
//Special case for ExistingCo.asp
//This function will validate ExistingCo.asp
//*******************************************************************************************************************
function checkExistingCo(theForm)
{
	if (isEmpty(theForm.ExistAddress1.value))
	{
		alert("Please enter your address.");
		theForm.ExistAddress1.focus();
		return false;
	}
	if (isEmpty(theForm.ExistCity.value))
	{
		alert("Please enter your city.");
		theForm.ExistCity.focus();
		return false;
	}
	numcoState=theForm.coState.selectedIndex
	if (isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state.");
		theForm.coState.focus();
		return false;
	}	
	if (isEmpty(theForm.ExistZip.value) || (!numericOnly(theForm.ExistZip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.ExistZip.focus();
		return false;
	}

}
//******************************************************************************************************************
//Special case for FR.asp
//This functioin will validate FR.asp
//Here is the list of un-require fields:
// Fax, Email, Tax ID, second address
// Notes: For a moment, I haven't validate theirs format yet.
//Here are the name of all the fields needed to check
//
//*******************************************************************************************************************
function checkFR(theForm)
{
	//Validate Employer Information
	if (isEmpty(theForm.EmployerName.value))
	{
		alert("Please enter your employer name.");
		theForm.EmployerName.focus();
		return false;
	}
	if (isEmpty(theForm.AddressLine1.value))
	{
		alert("Please enter your address1.");
		theForm.AddressLine1.focus();
		return false;
	}
	if (isEmpty(theForm.City.value))
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return false;
	}
	numcoState=theForm.coState.selectedIndex
	if (isEmpty(theForm.coState.options[numcoState].value))
	{
		alert("Please select your state");
		theForm.coState.focus();
		return false;
	}
	if (isEmpty(theForm.Zip.value))
	{
		alert("Please enter your zip code in digit format.");
		theForm.Zip.focus();
		return false;
	}
//	if (!isNum(theForm.Zip.value))
	//{
	//	alert("Your zip code has to be in this format (11111 or 11111-1111).");
	//	theForm.Zip.focus();
	//	return false;
//	}
	if ((isEmpty(theForm.TaxID1.value)) ||(!numericOnly(theForm.TaxID1.value)))
	{
		alert("Please enter 2 digit your Tax ID");
		theForm.TaxID1.focus();
		return false;
	}
	if (!isTax1(theForm.TaxID1.value)) {
		alert("Please enter your 2 digit Tax ID.")
		theForm.TaxID1.focus();
		return false;
	}
	if ((isEmpty(theForm.TaxID2.value))||(!numericOnly(theForm.TaxID2.value)))
	{
		alert("Please enter your 7 digit Tax ID.");
		theForm.TaxID2.focus();
		return false;
	}	
	if (!isTax2(theForm.TaxID2.value)) {
		alert("Please enter your 7 digit Tax ID.")
		theForm.TaxID2.focus();
		return false;
	}
	if (checkRadio(document.forms[0].TypeOfEntity) == false)
	{
		alert("Please select your type of Entity.");
		return false;
	}
	if((theForm.TypeOfEntity[6].checked==true)&&(theForm.TypeOfEntityOther.value==""))
	{
		alert("What is the value for Other?");
		theForm.TypeOfEntityOther.focus();
		return false;
	}
	if (checkRadio(document.forms[0].ControlGroup)==false)
	{
		alert("Is the employer a member of a controlled group?");
		return false;
	}
	if (checkRadio(document.forms[0].ServiceGroup)==false)
	{
		alert("Is the employer a member of an affiliated service group?");
		return false;
	}
	// Validate Third Party Administrator Information
	if (isEmpty(theForm.TPAName.value))
	{
		alert("Please enter your third party admin name.");
		theForm.TPAName.focus();
		return false;
	}
	if (isEmpty(theForm.ContactName.value))
	{
		alert("Please enter your contact name.");
		theForm.ContactName.focus();
		return false;
	}
	if (isEmpty(theForm.AAddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.AAddressLine1.focus();
		return false;
	}
	if (isEmpty(theForm.ACity.value))
	{
		alert("Please enter your city.");
		theForm.ACity.focus();
		return false;
	}
	numcoAState=theForm.coAState.selectedIndex
	if (isEmpty(theForm.coAState.options[numcoAState].value))
	{
		alert("Please select your state.");
		theForm.coAState.focus();
		return false;
	}	
	if (isEmpty(theForm.AZip.value) || (!numericOnly(theForm.AZip.value)))
	{
		alert("Please enter your zip code in digit format.");
		theForm.AZip.focus();
		return false;
	}
	//only need to valid email
	//if (!validEmail(theForm.AEmail.value))
	//{
		//alert("Your email is invalid.");
		//theForm.AEmail.focus();
		//return false;
	//}
	//no need to validate registered radio button as button is permanently selected
	// Validate Product/Compensation Information
	// Validate Product/Compensation Information
		//if (checkRadio(document.forms[0].Registered)==false)
		//{
		//	alert("Please select your contract type.");
		//alert(document.forms[0].Registered.checked);
		
			//return false;
	//}
	
	// Validate Trustee Information
	
	// Skip this section for now because there's a bug in the checkbox button.
	// Check with Howard
	
	// Validate Plan Information
	if (isEmpty(theForm.planName.value))
	{
		alert("Please enter your plan name.");
		theForm.planName.focus();
		return false;
	}
	if (isEmpty(theForm.NoEmp.value) || (!isNum(theForm.NoEmp.value)))
	{
		alert("Please enter the number of your employees.");
		theForm.NoEmp.focus();
		return false;
	}
	numPayroll=theForm.PayrollFrequency.selectedIndex
	if (isEmpty(theForm.PayrollFrequency.options[numPayroll].value))
	{
		alert("Please select your frequency of payroll.");
		theForm.PayrollFrequency.focus();
		return false;
	}
	if (!theForm.StartDateMM.selectedIndex)
	{
		alert("Please select the month");
		theForm.StartDateMM.focus();
		return false;
	}
	if (!theForm.StartDateDD.selectedIndex)
	{
		alert("Please select the day");
		theForm.StartDateDD.focus();
		return false;
	}
	if (!theForm.StartDateYYYY.selectedIndex)
	{
		alert("Please select the year");
		theForm.StartDateYYYY.focus();
		return false;
	}		
	if (!theForm.EndDateMM.selectedIndex)
	{
		alert("Please select the month");
		theForm.EndDateMM.focus();
		return false;
	}	
	if (!theForm.EndDateDD.selectedIndex)
	{
		alert("Please select the day");
		theForm.EndDateDD.focus();
		return false;
	}		
	if (!theForm.EndDateYYYY.selectedIndex)
	{
		alert("Please select the year");
		theForm.EndDateYYYY.focus();
		return false;
	}		
	if (checkRadio(document.forms[0].DocumentsUsed) == false)
	{
		alert("Please check which document will be used.");
		return false;
	}
	if((theForm.DocumentsUsed[2].checked==true)&&(theForm.txtDocumentsUsed.value==""))
	{
		alert("What is the value for Other option?");
		theForm.txtDocumentsUsed.focus();
		return false;
	}
	if (checkRadio(document.forms[0].LoansAvail)==false)
	{
		alert("Please check which loan is available.");
		return false;
	}
	if (isEmpty(theForm.EstPremium.value))
	{
		alert("Please estimate your annual premium flow.");
		theForm.EstPremium.focus();
		return false; 
	}
	// Validate Producer of Record
	//check with Matt	
}
//*****************************************************************************************************************
//validation for FR1
//*****************************************************************************************************************

function checkFR1(theForm)
{
	//Commission Fee schedule
	numMne=theForm.MnE.selectedIndex
	if (isEmpty(theForm.MnE.options[numMne].value))
	{	
		alert("Please select your ME %");
		theForm.MnE.focus();
		return false;
	}
	numCommissionOpt=theForm.CommissionOpt.selectedIndex
	if (isEmpty(theForm.CommissionOpt.options[numCommissionOpt].value))
	{
		alert("Please select your commission option.");
		theForm.CommissionOpt.focus();
		return false;
	}
//added validation for commission split 1/23/01 TL

	if (isEmpty(theForm.CommissionPct1.value))
	{
		alert("Please enter your commission split.");
		theForm.CommissionPct1.focus();
		return false;
	}	
	if (!(document.theForm.RepID2)&&!(document.theForm.RepID3)&&!(document.theForm.RepID4)&&(theForm.CommissionPct1.value!='100'))
			{	
			alert("The commission split must be 100%");
			theForm.CommissionPct1.focus();
			return false;
		}
	if (document.theForm.RepID2){	
			
		if (!(document.theForm.RepID3)&&!(document.theForm.RepID4)&&(numFix(theForm.CommissionPct1.value)+numFix(theForm.CommissionPct2.value) !='100'))
		{
			//alert (numFix(theForm.CommissionPct1.value)+numFix(theForm.CommissionPct2.value));
			
				alert("The commision split must add up to 100%");
				theForm.CommissionPct2.focus();
				return false;
			}
		}

	if (document.theForm.RepID3){	
		if (!(document.theForm.RepID4)&&((numFix(theForm.CommissionPct1.value)+numFix(theForm.CommissionPct2.value) + numFix(theForm.CommissionPct3.value)) !='100'))
				{	
				//alert(numFix(theForm.CommissionPct1.value)+numFix(theForm.CommissionPct2.value) + numFix(theForm.CommissionPct3.value))
				alert("The commission split must add up to 100%");
				theForm.CommissionPct3.focus();
				return false;
			}
		}

	if (document.theForm.RepID4){	
		if ((numFix(theForm.CommissionPct1.value)+numFix(theForm.CommissionPct2.value) + numFix(theForm.CommissionPct3.value) + numFix(theForm.CommissionPct4.value)) !='100')
				{	
				alert("The commission split must add up to 100%");
				theForm.CommissionPct4.focus();
				return false;
			}
		}
	}


//******************************************************************************************************************
//Special case for FR2conversion.asp
//Here is the list of un-require fields:
// 
// Notes: Shall we validate "number of active participants" and 
//	"Eligible employee" fields?
//Here are the name of all the fields needed to check
//
//*******************************************************************************************************************
function checkFR2conversion(theForm)
{
	if (isEmpty(theForm.CurrentProductNo.value))
	{
		alert("Please enter your case number.");
		theForm.CurrentProductNo.focus();
		return false;
	}
	if(!isNum(theForm.CurrentProductNo.value))
	{
		alert("This is an invalid entry, please re-enter your case number.");
		theForm.CurrentProductNo.focus();
		return false;
	}
	if ((isEmpty(theForm.NoEmpActive.value))||(!isNum(theForm.NoEmpActive.value)))
	{
		alert("Please enter the number of active participants (digit format).");
		theForm.NoEmpActive.focus();
		return false;
	}
	if ((isEmpty(theForm.NoEmpElig.value))||(!isNum(theForm.NoEmpElig.value)))
	{
		alert("Please enter the number of eligible employees.");
		theForm.NoEmpElig.focus();
		return false;
	}
}

//******************************************************************************************************************
// Name: checkFRNewPlan()
// Description:
//	Validate FRnewplan.asp
//
//*******************************************************************************************************************
function checkFRNewPlan(theForm)
{
	if(checkRadio(document.forms[0].Allocated==false))
	{
		alert("Please select Allocated or Unallocated option");
		return false;
	}
	if(isEmpty(theForm.NoEmp.value))
	{
		alert("Please enter the number of your employees");
		theForm.NoEmp.focus();
		return false;
	}
	if (!isNum(theForm.NoEmp.value))
	{
		alert("Invalid entry. Please enter the number of your employees in digit format.");
		theForm.NoEmp.focus();
		return false;
	}
	if(isEmpty(theForm.NoEmpElig.value))
	{
		alert("Please enter the number of expected employees to be eligible");
		theForm.NoEmpElig.focus();
		return false;
	}
	if (!isNum(theForm.NoEmpElig.value))
	{
		alert("Invalid entry. Please enter the number of expected employees to be eligible in digit format.");
		theForm.NoEmpElig.focus();
		return false;
	}	
	if(isEmpty(theForm.EligPayroll.value))
	{
		alert("Please enter your total eligible payroll");
		theForm.EligPayroll.focus();
		return false;
	}
	//check for $ signs
	var invalid = "$"; 
	if (theForm.EligPayroll.value.indexOf(invalid) > -1)
	{
		alert("Please do not use dollar signs or any non-numerics symbols.");
		theForm.EligPayroll.focus();
		return false;
	}
	if (!isNumMoney(theForm.EligPayroll.value))
	{
		alert("Please do not use dollar signs or any non-numerics symbols.");
		theForm.EligPayroll.focus();
		return false;
	}	
	if((isEmpty(theForm.NoTermEmp.value))||(!isNum(theForm.NoTermEmp.value)))
	{
		alert("Please enter number of eligible employees who retired or terminated from last year. If none, please enter 0");
		theForm.NoTermEmp.focus();
		return false;
	}
	if((isEmpty(theForm.NoTermEmp2.value))||(!isNum(theForm.NoTermEmp2.value)))
	{
		alert("Please enter number of eligible employees who retired or terminated from 2 years ago. If none, please enter 0");
		theForm.NoTermEmp2.focus();
		return false;
	}
}

//******************************************************************************************************************
//Special case for PR_Form.asp
//This functioin will validate PR_Form.asp
//PR_Form is the name of the PR_Form's form
//Here are the name of all the fields needed to check
//ProposalNum(number), EmployerName(text),AddressLine1(text),State(dropdown), NoEmpElig(number), EstPremium(money w/ 2 digits)
//ForwardProposalTo(checkbox), FPTName(text), FPTAddress1(text), FPTAddress2(text), FPTCity(text), FPTState(dropdown)
//FPTZip(number), Standard(checkbox), IncTPASrvFee(text), MnE(%)
//Note: I think we don't need to check the fields that have the default values in, for example, state,checkbox option..
//	Also I am skipping the Forward proposal section at this moment, I'll come back this section later.
//*******************************************************************************************************************
function checkPR_Form(theForm)
{
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTName.value==""))
	{
		alert("Please enter your name.");
		theForm.FPTName.focus();
		return false;
	}
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTAddress1.value==""))
	{
		alert("Please enter your address.");
		theForm.FPTAddress1.focus();
		return false;
	}
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTCity.value==""))
	{
		alert("Please enter your city.");
		theForm.FPTCity.focus();
		return false;
	}
	numFPTState=theForm.FPTState.selectedIndex
	if((theForm.ForwardProposalTo[1].checked==true)&&(isEmpty(theForm.FPTState.options[numFPTState].value)))
	{
		alert("Please select your state.");
		theForm.FPTState.focus();
		return false;
	}
	
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTZip.value==""))
	{
		alert("Please enter your zip code.");
		theForm.FPTZip.focus();
		return false;
	}
	//skip proposal consideration for now. check back later.
}



//******************************************************************************************************************
//Special case for PR.asp
//This functioin will validate PR.asp
//PR is the name of the PR's form
//Here are the name of all the fields needed to check
//ProposalNum(number), EmployerName(text),AddressLine1(text),State(dropdown), NoEmpElig(number), EstPremium(money w/ 2 digits)
//ForwardProposalTo(checkbox), FPTName(text), FPTAddress1(text), FPTAddress2(text), FPTCity(text), FPTState(dropdown)
//FPTZip(number), Standard(checkbox), IncTPASrvFee(text), MnE(%)
//Note: I think we don't need to check the fields that have the default values in, for example, state,checkbox option..
//	Also I am skipping the Forward proposal section at this moment, I'll come back this section later.
//*******************************************************************************************************************
function checkPR(theForm)
{
	if (isEmpty(theForm.ProposalNum.value))
	{
		alert("Please enter your proposal number.");
		theForm.ProposalNum.focus();
		return false;
	}
	if (isEmpty(theForm.EmployerName.value))
	{
		alert("Please enter your employer name.");
		theForm.EmployerName.focus();
		return false;
	}
	if (isEmpty(theForm.AddressLine1.value))
	{
		alert("Please enter your address.");
		theForm.AddressLine1.focus();
		return false;
	}
	if (isEmpty(theForm.City.value))
	{
		alert("Please enter your city.");
		theForm.City.focus();
		return false;
	}	
	num=theForm.coState.selectedIndex
	if (isEmpty(theForm.coState.options[num].value))
	{
		alert("Please select your state.");
		theForm.coState.focus();
		return false;
	}
	if ((isEmpty(theForm.Zip.value))||(!numericOnly(theForm.Zip.value)))
	{
		alert("Please enter your zip code.");
		theForm.Zip.focus();
		return false;
	}
	if(isEmpty(theForm.NoEmpElig.value))
	{
		alert("Please enter the number of your eligible employees.");
		theForm.NoEmpElig.focus();
		return false;
	}
	if (!isNum(theForm.NoEmpElig.value))
	{
		alert("Invalid entry. Please enter the number of your eligible employees.");
		theForm.NoEmpElig.focus();
		return false;
	}
	if(isEmpty(theForm.EstPremium.value))
	{
		alert("Please estimate your annual premium flow.");
		theForm.EstPremium.focus();
		return false;	
	}
	
	if (!isNumMoney(theForm.EstPremium.value))
	{
		alert("Please do not use dollar signs or any non-numerics symbols.");
		theForm.EstPremium.focus();
		return false;
	}
	//check for $ signs
	var invalid = "$"; 
	if (theForm.EstPremium.value.indexOf(invalid) > -1) 
	{
		alert("Please do not use dollar signs or any non-numerics symbols.");
		theForm.EstPremium.focus();
		return false;
	}
	if (checkRadio(document.forms[0].ForwardProposalTo)==false)
	{
		alert("Where do you want to forward your proposal request to?");
		return false;
	}
	
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTName.value==""))
	{
		alert("Please enter your name.");
		theForm.FPTName.focus();
		return false;
	}
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTAddress1.value==""))
	{
		alert("Please enter your address.");
		theForm.FPTAddress1.focus();
		return false;
	}
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTCity.value==""))
	{
		alert("Please enter your city.");
		theForm.FPTCity.focus();
		return false;
	}
	numFPTState=theForm.FPTState.selectedIndex
	if((theForm.ForwardProposalTo[1].checked==true)&&(isEmpty(theForm.FPTState.options[numFPTState].value)))
	{
		alert("Please select your state.");
		theForm.FPTState.focus();
		return false;
	}
	
	if((theForm.ForwardProposalTo[1].checked==true)&&(theForm.FPTZip.value==""))
	{
		alert("Please enter your zip code.");
		theForm.FPTZip.focus();
		return false;
	}
	//skip proposal consideration for now. check back later.
}

function checkPR1(theForm)
{
	numMnE=theForm.MnE.selectedIndex
	if(isEmpty(theForm.MnE.options[numMnE].value))
	{
		alert("Please select your ME")
		theForm.MnE.focus();
		return false;
	}
	numCom=theForm.CommissionOpt.selectedIndex
	if(isEmpty(theForm.CommissionOpt.options[numCom].value))
	{
		alert("Please select your commision option.")
		theForm.CommissionOpt.focus();
		return false;
	}
	//skip proposal consideration for now. check back later.
}



//******************************************************************************************************************
// This function will validate PR2.asp
// PR2 is the name of the PR2's form
// Variable: Here are the name of all the fields needed to check
// TypeOfEntityOther (if checked, enter what type of entity)
// EstabDate(date)
// FiscalYrEnd(date) 
//*******************************************************************************************************************
function checkPR2(theForm)
{
	//business info
	if((theForm.TypeOfEntity[3].checked==true)&&(theForm.TypeOfEntityOther.value==""))
	{
		alert("What's the value for Other option?");
		theForm.TypeOfEntityOther.focus();
		return false;
	}
	if (!theForm.EstabDateMM.selectedIndex)
	{
		alert("Please select the month.");
		theForm.EstabDateMM.focus();
		return false;
	}
	if (!theForm.EstabDateDD.selectedIndex)
	{
		alert("Please select the day.");
		theForm.EstabDateDD.focus();
		return false;
	}
	if (!theForm.EstabDateYYYY.selectedIndex)
	{
		alert("Please select the year.");
		theForm.EstabDateYYYY.focus();
		return false;
	}		
	if (!theForm.FiscalYrEndMM.selectedIndex)
	{
		alert("Please select the month.");
		theForm.FiscalYrEndMM.focus();
		return false;
	}	
	if (!theForm.FiscalYrEndDD.selectedIndex)
	{
		alert("Please select the day.");
		theForm.FiscalYrEndDD.focus();
		return false;
	}	
	if (!theForm.FiscalYrEndYYYY.selectedIndex)
	{
		alert("Please select the year.");
		theForm.FiscalYrEndYYYY.focus();
		return false;
	}	
}

//******************************************************************************************************************
// Name: PR3.asp
// Description:
// 	This function will validate PR3.asp. In order to go to the next page, the users have
//	to select one or more plans.
// 
//*******************************************************************************************************************
function checkPR3(PR) 
{
	for (var i=0; i <PR.length; i++) 
	{
	        if (PR[i].checked) return true;
	}
	alert("Please select one or more plan.");
	return false;
}

//******************************************************************************************************************
// Name: PR5.asp
// Description:
//	To make sure the users have selected one out of two options. Also, if the users selected
//	the second option, then they have to enter how many employees they have.
//*******************************************************************************************************************
function checkPR5(PR)
{
    numProjInvestRet=PR.ProjInvestRet.selectedIndex
	if(!PR.ProjInvestRet.options[numProjInvestRet].value)
	{	
		alert("Please select the percentage of Projected Investment Return.");
		return false; 
	}
	
	if(isEmpty(PR.NoEmp.value))
	{	
		alert("Please select the number of your employees in numeric format.");
		return false; 
	}
	for (var i=0; i <PR.length; i++)
	{
		if (PR[i].checked) 
		return true;
	}
	alert("You have to select one out of two options.");
	return false;

	
}

//******************************************************************************************************************
// Name: PRcensus.asp
// Description:
//	This function will check for valid dates and other fields
//Note: I skipped "LastName" field
//*******************************************************************************************************************
 function checkPRCensus(theForm)
 {
 	if (isEmpty(theForm.FirstName.value))
 	{
 		alert("Please enter your first name");
 		theForm.FirstName.focus();
 		return false;
 	}
 	if (isEmpty(theForm.LastName.value))
	 {
	 	alert("Please enter your last name");
	 	theForm.LastName.focus();
	 	return false;
 	}
	numeType=theForm.eType.selectedIndex
 	if (isEmpty(theForm.eType.options[numeType].value))
 	{
 		alert("Please select your Employee Type");
 		theForm.eType.focus();
 		return false;
 	}
	if (checkRadio(document.forms[0].Sex) == false)
  	{
 		alert("Please select the Gender field");
 		return false;
 	}
	if (!theForm.DOBMM.selectedIndex)
 	{
 		alert("Please select the month.");
 		theForm.DOBMM.focus();
 		return false;
 	}
	if (!theForm.DOBDD.selectedIndex)
 	{
 		alert("Please select the day.");
 		theForm.DOBDD.focus();
 		return false;
 	}
	if (!theForm.DOBYYYY.selectedIndex)
 	{
 		alert("Please select the year.");
 		theForm.DOBYYYY.focus();
 		return false;
 	}
	if (!theForm.DateOfHireMM.selectedIndex)
 	{
 		alert("Please select the month.");
 		theForm.DateOfHireMM.focus();
 		return false;
 	}
	if (!theForm.DateOfHireDD.selectedIndex)
 	{
 		alert("Please select the day.");
 		theForm.DateOfHireDD.focus();
 		return false;
 	}
	if (!theForm.DateOfHireYYYY.selectedIndex)
 	{
 		alert("Please select the year.");
 		theForm.DateOfHireYYYY.focus();
 		return false;
 	}	
 	theForm.Salary.value = numericOnly(theForm.Salary.value);
 	if (isEmpty(theForm.Salary.value))
 	{
 		alert("You have entered an invalid number");
 		theForm.Salary.focus();
 		return false;
 	}
	numPay=theForm.PayPeriod.selectedIndex
 	if (isEmpty(theForm.PayPeriod.options[numPay].value))
 	{
 		alert("Please select your Pay Period");
 		theForm.PayPeriod.focus();
 		return false;
 	}
}
function checkPRexport(theForm)
{
	if (checkRadio(document.forms[0].email)==false)
	{
		alert("Please select your option.");
		return false;
	}
	if ((theForm.email[1].checked==true)&&(isEmpty(theForm.emailaddress.value)))
	{
		alert("Please enter your email");
		theForm.emailaddress.focus();
		return false;
	}
	if ((!validEmail(theForm.emailaddress.value))&&(theForm.email[0].checked==false))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.emailaddress.value=""
		theForm.emailaddress.select();
		theForm.emailaddress.focus();
		return false;
	}
}
//******************************************************************************************************************
// Name: check401k()
// Description:
//	This function will validate PR401k.asp
//
//*******************************************************************************************************************
function check401k(theForm)
{
/*OLD...
	if (checkRadio(document.forms[0].ElectiveDeferral)== false)
	{
		alert("Please select Elective Deferral's option.");
		return false;
	}
	if ((PR.ElectiveDeferral[6].checked==true) &&(PR.txtElectiveDeferral.value==""))
	{
		alert("Please enter the value for Elective Deferrral's Other option.");
		PR.txtElectiveDeferral.focus();
		return false;
	}
	if (isNaN(PR.txtElectiveDeferral.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		return false;
	}
*/
	var tmpSelectedIndex
	tmpSelectedIndex=theForm.ElectiveDeferral.selectedIndex
	if (isEmpty(theForm.ElectiveDeferral.options[tmpSelectedIndex].value))
	{
		alert("Please select an Elective Deferral percent.");
		return false;
	}

	if ((theForm.ElectiveDeferral.value=="0")&&(theForm.txtElectiveDeferral.value==""))
	{
		alert("Please enter the value for Elective Deferrral's Other option.");
		theForm.txtElectiveDeferral.focus();
		return false;
	}
	if (isNaN(theForm.txtElectiveDeferral.value))
	{
		alert("Invalid entry. Only numbers are allowed in the Other Elective Deferral box.");
		theForm.txtElectiveDeferral.focus();
		return false;
	}		
/*
old....
	if (checkRadio(document.forms[0].EmployerMatchPct)== false)
	{
		alert("Please select Employer Match's option.");
		return false;
	}
	if ((PR.EmployerMatchPct[4].checked==true) &&(PR.txtEmployerMatchPct.value==""))
	{
		alert("Please enter the value for Employer Match's Other option.");
		PR.txtEmployerMatchPct.focus();
		return false;
	}
	if (isNaN(PR.txtEmployerMatchPct.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.txtEmployerMatchPct.focus();
		return false;
	}
	*/
	
	tmpSelectedIndex=theForm.EmployerMatchPct.selectedIndex
	if (isEmpty(theForm.EmployerMatchPct.options[tmpSelectedIndex].value))
	{
		alert("Please select an Employer Match percent.");
		return false;
	}

	if ((theForm.EmployerMatchPct.value=="0")&&(theForm.txtEmployerMatchPct.value==""))
	{
		alert("Please enter the value for Employer Match's Other option.");
		theForm.EmployerMatchPct.focus();
		return false;
	}
	
	if (isNaN(theForm.txtEmployerMatchPct.value))
	{
		alert("Invalid entry. Only numbers are allowed in the Other Employer Match Percent box..");
		theForm.txtEmployerMatchPct.focus();
		return false;
	}	
	
	if (checkRadio(document.forms[0].EmployerMatchSalPct)== false)
	{
		alert("Please select Employer Match Limited's option.");
		return false;
	}
	if ((theForm.EmployerMatchSalPct[1].checked==true) &&(theForm.txtEmployerMatchSalPct.value==""))
	{
		alert("Please enter Percent of Salary in the Employer Match Limited to section.");
		theForm.txtEmployerMatchSalPct.focus()
		return false;
	}
	if (isNaN(theForm.txtEmployerMatchSalPct.value))
	{
		alert("Invalid entry. Only numbers are allowed in the Match Limited to Percent of Salary box..");
		theForm.txtEmployerMatchSalPct.focus();
		return false;
	}
	/* old...
	if (checkRadio(document.forms[0].EmployerProfShareOpt)==false)
	{
		alert("Please select your Employer Profit Sharing.");
		return false;
	}
	if (checkRadio(document.forms[0].EmployerProfShareOpt2)==false)
	{
		alert("Please select your Employer Profit Sharing 2.");
		return false;
	}	
*/		
	tmpSelectedIndex=theForm.EmployerProfShareOpt.selectedIndex
	if (isEmpty(theForm.EmployerProfShareOpt.options[tmpSelectedIndex].value))
	{
		alert("Please select an Employer Profit Sharing type.");
		return false;
	}
	
	
	if ((theForm.EmployerProfShareOpt2[0].checked==true) &&(theForm.EmployerProfShareAmt.value==""))
	{
		alert("Please enter the dollar amount for Employer Profit Sharing.");
		theForm.EmployerProfShareAmt.focus();
		return false;
	}

	//validation for PR.Employer.ProfShareAmt.value is done in onBlur event
	
	if((theForm.EmployerProfShareOpt2[1].checked==true)&&(theForm.EmployerProfSharePct.value==""))
	{
		alert("Please enter a percent for Employer Profit Sharing.");
		theForm.EmployerProfSharePct.focus();
		return false;
	}
	if (isNaN(theForm.EmployerProfSharePct.value))
	{
		alert("Invalid entry. Only numbers are allowed in the Profit Sharing Percent of Salary box.");
		theForm.EmployerProfSharePct.focus();
		return false;
	}
}

//******************************************************************************************************************
// Name: checkPRHarbor()
// Description:
//	This function will validate PR401k.asp
//
//*******************************************************************************************************************
function checkPRHarbor(PR)
{
	if (checkRadio(document.forms[0].ElectiveDeferral)== false)
	{
		alert("Please select Elective Deferral's option.");
		return false;
	}
	if ((PR.ElectiveDeferral[6].checked==true) &&(PR.txtElectiveDeferral.value==""))
	{
		alert("Please enter the value for Elective Deferrral's Other option.");
		PR.txtElectiveDeferral.focus();
		return false;
	}
	if (isNaN(PR.txtElectiveDeferral.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.txtElectiveDeferral.focus();
		return false;
	}
	if (checkRadio(document.forms[0].EmployerMatchOpt)== false)
	{
		alert("Please select Employer Contribution.");
		return false;
	}
	if (checkRadio(document.forms[0].EmployerProfShareOpt)== false)
	{
		alert("Please select Employer Profit Sharing.");
		return false;
	}
	if (checkRadio(document.forms[0].EmployerProfShareOpt2)==false)
	{
		alert("Please select your Employer Profit Sharing 2.");
		return false;
	}	
	if ((PR.EmployerProfShareOpt2[0].checked==true) &&(PR.EmployerProfShareAmt.value==""))
	{
		alert("Please enter the value for Employer Profit Sharing 2");
		PR.EmployerProfShareAmt.focus();
		return false;
	}
	/*if (isNaN(PR.EmployerProfShareAmt.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}*/
	if ((PR.EmployerProfShareOpt2[1].checked==true) &&(PR.EmployerProfSharePct.value==""))
	{
		alert("Please enter the value for Employer Profit Sharing 2 (?)");
		PR.EmployerProfSharePct.focus();
		return false;
	}
	/*if (!isNumMoney(PR.EmployerProfSharePct.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfSharePct.focus();
		return false;*/
	}
	

//******************************************************************************************************************
// Name: checkPRSimple()
// Description:
//	This function will validate PRsimple.asp
//
//*******************************************************************************************************************

function checkPRSimple()
{
	if (checkRadio(document.forms[0].ElectiveDeferral) == false)
	 {
		alert(' Please select your Elective Deferral.');
		return false;
	}
	if ((PR.ElectiveDeferral[6].checked==true) &&(PR.txtElectiveDeferral.value==""))
	{
		alert("Please enter the value for Elective Deferrral's Other option.");
		PR.txtElectiveDeferral.focus();
		return false;
	}	
	if (isNaN(PR.txtElectiveDeferral.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.txtElectiveDeferral.focus();
		return false;
	}
	if (checkRadio(document.forms[0].EmployerMatchOpt) == false)
	{
		alert(' Please select your Employer Contribution .');
		return false;
	}
}

//******************************************************************************************************************
// Name: checkPRProfitSharing()
// Description:
//	To validate PRprofitSharing.asp
//
//*******************************************************************************************************************
function checkPRProfitSharing()
{
	if (checkRadio(document.forms[0].EmployerProfShareOpt) == false)
	{
		alert(' Please select your first profit sharing.');
		return false;
	}
	if (checkRadio(document.forms[0].EmployerProfShareOpt2) == false)
	{
		alert(' Please select your profit sharing .');
		return false;
	}
	if ((PR.EmployerProfShareOpt2[0].checked==true) &&(PR.EmployerProfShareAmt.value==""))
	{
		alert("Please enter a dollar amount for Employer Profit Sharing.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}
	/*if (isNaN(PR.EmployerProfShareAmt.value))
	{
		alert("Only numbers are allowed in the Employer Profit Sharing dollars box.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}*/
	if ((PR.EmployerProfShareOpt2[1].checked==true) &&(PR.EmployerProfSharePct.value==""))
	{
		alert("Please enter a percent for Employer Profit Sharing.");
		PR.EmployerProfSharePct.focus();
		return false;
	}	
	if (isNaN(PR.EmployerProfSharePct.value))
	{
		alert("Only numbers are allowed in the Employer Profit Sharing Percent box.");
		PR.EmployerProfSharePct.focus();
		return false;
	}
}

//******************************************************************************************************************
// Name: checkPRMoneyPurchase()
// Description:
//	To validate PRmoneyPurchase.asp
//*******************************************************************************************************************
function checkPRMoneyPurchase()
{
	if (checkRadio(document.forms[0].EmployerProfShareOpt)==false)
	{
		alert ("Please select your Employer Profit Sharing.");
		return false;
	}
	if (checkRadio(document.forms[0].EmployerProfShareOpt2)==false)
		{
			alert ("Please select your Employer Profit Sharing option2.");
			return false;
	}
	if((PR.EmployerProfShareOpt2[0].checked==true)&&(PR.EmployerProfShareAmt.value==""))
	{
		alert("Please enter a dollar amount for Employer Profit Sharing.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}
	/*if (isNaN(PR.EmployerProfShareAmt.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}*/
	if((PR.EmployerProfShareOpt2[1].checked==true)&&(PR.EmployerProfSharePct.value==""))
	{
		alert("Please enter a percent of salary for Employer Profit Sharing.");
		PR.EmployerProfSharePct.focus();
		return false;
	}
	if (isNaN(PR.EmployerProfSharePct.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfSharePct.focus();
		return false;
	}
}

//******************************************************************************************************************
// Name: checkPRdefinedBenefit()
// Description:
//	To validate PRdefinedBenefit.asp
//
//*******************************************************************************************************************
function checkPRdefinedBenefit()
{
	if (checkRadio(document.forms[0].EmployerProfShareOpt2)==false)
	{
		alert("Please select your Defined Benefit.");
		return false;
	}
	if ((PR.EmployerProfShareOpt2[1].checked==true)&&(PR.EmployerProfShareAmt.value==""))
	{
		alert("Please enter the value for your Defined Benefit.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}
	if (isNaN(PR.EmployerProfShareAmt.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}
	if ((PR.EmployerProfShareOpt2[2].checked==true)&&(PR.EmployerProfSharePct.value==""))
	{
		alert("Please enter the value for your Defined Benefit.");
		PR.EmployerProfSharePct.focus();
		return false;
	}	
	if (isNaN(PR.EmployerProfSharePct.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfSharePct.focus();
		return false;
	}
}

//******************************************************************************************************************
// Name: checkPRSep()
// Description:
//	To validate PRsep.asp
//
//*******************************************************************************************************************
function checkPRSep()
{
	// This function is the same as checkPRMoneyPurchase()	
}

//******************************************************************************************************************
// Name: checkPRNewComp()
// Description:
//	To validate PRnewComp.asp
//*******************************************************************************************************************
function checkPRNewComp()
{
	if(checkRadio(document.forms[0].ElectiveDeferral)==false)
	{
		alert("Please select your Elective Deferral.");
		return false;
	}
	if ((PR.ElectiveDeferral[6].checked==true)&&(PR.txtElectiveDeferral.value==""))
	{
		alert("Please enter the value for your Elective Deferral.");
		PR.txtElectiveDeferral.focus();
		return false;
	}
	if (isNaN(PR.txtElectiveDeferral.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.txtElectiveDeferral.focus();
		return false;
	}
	if(checkRadio(document.forms[0].EmployerMatchOpt)==false)
	{
		alert("Please select your Employer Matching Option.");
		return false;
	}
	
	if(checkRadio(document.forms[0].EmployerProfShareOpt)==false)
	{
		alert("Please select your Employer Contribution.");
		return false;
	}
	if(checkRadio(document.forms[0].EmployerProfShareOpt2)==false)
	{
		alert("Please select your Employer Contribution option2.");
		return false;
	}
	if((PR.EmployerProfShareOpt2[0].checked==true)&&(PR.EmployerProfShareAmt.value==""))
	{
		alert("Please enter the value of your Employer Profit Sharing Amount.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}
	/*if (isNaN(PR.EmployerProfShareAmt.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfShareAmt.focus();
		return false;
	}*/
	if((PR.EmployerProfShareOpt2[1].checked==true)&&(PR.EmployerProfSharePct.value==""))
	{
		alert("Please enter the value of your Employer Profit Sharing Percent (digit format).");
		PR.EmployerProfSharePct.focus();
		return false;
	}	
	if (isNaN(PR.EmployerProfSharePct.value))
	{
		alert("Invalid entry. Please do not enter any non-numeric character.");
		PR.EmployerProfSharePct.focus();
		return false;
	}
	
}

function checkChangePW(ChangePW)
{
	if (isEmpty(ChangePW.OldPassword.value))
	{
		alert("Please enter your old password.");
		ChangePW.OldPassword.select();
		ChangePW.OldPassword.focus();
		return false;
	}
	if (isEmpty(ChangePW.NewPassword1.value))
	{
		alert("Please enter your new password.");
		ChangePW.NewPassword1.select();
		ChangePW.NewPassword1.focus();
		return false;
	}
	if (isEmpty(ChangePW.NewPassword2.value))
	{
		alert("Please re-enter your new password.");
		ChangePW.NewPassword2.select();
		ChangePW.NewPassword2.focus();
		return false;
	}	
	if ((ChangePW.NewPassword1.value) !=(ChangePW.NewPassword2.value))
	{
		alert("Your password doesn't match. Please retype your new password.");
		ChangePW.NewPassword1.select();
		ChangePW.NewPassword1.focus();
		return false;
	}	
}

//******************************************************************************************************************
// Name: checkForms()
// Description:
//	To validate checkbox for forms library
//*******************************************************************************************************************
function checkForms(theForm)
{
	if(checkRadio(document.theForm.EmployeeSSN) == false)
	{
		alert("Please select your employee's name.");
		return false;
	}
}

//******************************************************************************************************************
// Name: checkaddNewBroker()
// Description:
//	To validate add new broker
//*******************************************************************************************************************


function checkaddNewBroker(theForm)
{
	if(isEmpty(theForm.Name.value))
	{
		alert("Please enter your name.");
		theForm.Name.focus();
		return false;
	}
	
	if(isEmpty(theForm.BrokerNumber.value))
	{
		alert("Please enter your broker number");
		theForm.BrokerNumber.focus();
		return false;
	}	
			
	if ((!isEmail(theForm.Email.value))||(isEmpty(theForm.Email.value)))
	{
		alert("Your email address is incorrect. Please re-enter your email address.");
		theForm.Email.value=""
		theForm.Email.focus();
		return false;
	}	

	if(isEmpty(theForm.Password.value))
	{
		alert("Please choose a password(upto 10 characters).");
		theForm.Password.focus();
		return false;
	}
	
	if(isEmpty(theForm.Password2.value))
	{
		alert("Please re-type your password");
		theForm.Password2.focus();
		return false;
	}
	if((theForm.Password.value) !=(theForm.Password2.value))
	{
		alert("Your password is not matched. Please re-type your password.");
		theForm.Password2.focus();
		return false;
	}
}

/* Add more function by Chu Ji*/
var digitsInZIPCode1 = 5
var digitsInZIPCode2 = 9
var ZIPCodeDelimiters = "-";
var reInteger = /^\d+$/; 
var reInteger = /^\d+$/; 
var reDigit = /^\d/;

var defaultEmptyOK = false;
var reEmail = /^.+\@.+\..+$/
var iEmail = "This field must be a valid email address (like broker@sbsb.com). Please reenter it now."
var iZIPCode = "This field must be a 5 or 9 digit U.S. ZIP Code (like 94043). Please reenter it now."
var iNumber = "This field must be numeric. Please rernter it now."
var iDate = "The date you supplied was invalid. Please try again"
var iMoney ="This field must be dollar format."

function warnInvalid (theField, s)
{   
	theField.focus();
    theField.select();
    alert(s);
    return false;
}

function isMoneyFormat(s)
{
	var sValidChars = "1234567890,.";
	for (var iCharPos = 0; iCharPos < s.length; iCharPos++){
		if (sValidChars.indexOf(s.charAt(iCharPos)) == -1){
			return false;
		}
	}
	
	return true;
}

function checkMoney(theField, emptyOK)
{
	if (checkMoney.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isMoneyFormat(theField.value)) 
       return warnInvalid (theField, iMoney);
    else return true;
}

function checkEmail (theField, emptyOK)
{   if (checkEmail.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isEmail(theField.value, false)) 
       return warnInvalid (theField, iEmail);
    else return true;
}
function isEmail (s)
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return defaultEmptyOK;
       else return (isEmail.arguments[1] == true);
    else {
       return reEmail.test(s)
    }
}
function checkZIPCode (theField, emptyOK)
{   if (checkZIPCode.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    { var normalizedZIP = stripCharsInBag(theField.value, ZIPCodeDelimiters)
      if (!isZIPCode(normalizedZIP, false)) 
         return warnInvalid (theField, iZIPCode);
      else 
      {  // if you don't want to insert a hyphen, comment next line out
         theField.value = reformatZIPCode(normalizedZIP)
         return true;
      }
    }
}

function reformatZIPCode (ZIPString)
{   if (ZIPString.length == 5) return ZIPString;
    else return (reformat (ZIPString, "", 5, "-", 4));
}

function stripCharsInBag (s, bag)
{   var i;
    var returnString = "";
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function isZIPCode (s)
{  if (isEmpty(s)) 
       if (isZIPCode.arguments.length == 1) return defaultEmptyOK;
       else return (isZIPCode.arguments[1] == true);
   return (isInteger(s) && 
            ((s.length == digitsInZIPCode1) ||
             (s.length == digitsInZIPCode2)))
}
function isInteger (s)
{   var i;
    if (isEmpty(s)) 
       if (isInteger.arguments.length == 1) return defaultEmptyOK;
       else return (isInteger.arguments[1] == true);
    return reInteger.test(s)
}
function checkNumber(theField, emptyOK)
{
if (checkNumber.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isInteger(theField.value, false)) 
       return warnInvalid (theField, iNumber);
    else return true;

}

function checkValidDate(theField, emptyOK)
{
if (checkValidDate.arguments.length == 1) emptyOK = defaultEmptyOK;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else if (!isValidDate(theField.value, false)) 
       return warnInvalid (theField, iDate);
    else return true;
}
function isValidDate(dateStr)
{
// dateStr must be of format month day year with 
// or dashes separating the 
// to be made to use day month year or another format. 
// This function returns True if the date is valid.
	var slash1=dateStr.indexOf("/");
	if(slash1==-1){slash1 = dateStr.indexOf("-");}
	// if no slashes or dashes, invalid date    
	if(slash1 ==-1) {return false;}
	var dateMonth = dateStr.substring(0, slash1);
	var dateMonthAndYear = dateStr.substring(slash1+1, dateStr.length);
		
	var slash2 = dateMonthAndYear.indexOf("/");
	if (slash2 == -1) { slash2 = dateMonthAndYear.indexOf("-"); }
		
	// if not a second slash or dash, invalid date    
	if (slash2 == -1) { return false;}

	var dateDay = dateMonthAndYear.substring(0, slash2);
	var dateYear = dateMonthAndYear.substring(slash2+1, dateMonthAndYear.length);
	if ( (dateMonth == "") || (dateDay == "") || (dateYear == "") ) { return false; }
	
	// if any non-digits in the month, invalid date    
	for(var x=0; x < dateMonth.length; x++){
		var digit = dateMonth.substring(x, x+1);
		if ((digit < "0") || (digit > "9")){
			return false;
		}
	}	
	//alert(dateStr);

	// convert the text month to a number    
	var numMonth = 0;
	for (var x=0; x < dateMonth.length; x++){
		digit=dateMonth.substring(x, x+1);
		numMonth *= 10;
		numMonth += parseInt(digit);
	}

	if ((numMonth <= 0) || (numMonth > 12)) { return false; }
	
	// if any non-digits in the day, invalid date    
	for (var x=0; x < dateDay.length; x++) {
		digit = dateDay.substring(x, x+1);
		if ((digit < "0") || (digit > "9")) { return false;}
	}
	// convert the text day to a number    
	var numDay = 0;
	for (var x=0; x < dateDay.length; x++) {
		digit = dateDay.substring(x, x+1);
		numDay *= 10;
		numDay += parseInt(digit);
	}
	
	
	if ((numDay <= 0) || (numDay > 31)) { return false; }
	// February can't be greater than 29 (leap year calculation comes later)
	if ((numMonth == 2) && (numDay >29)) { return false; }
	// check for months with only 30 days    
	if ((numMonth == 4) || (numMonth == 6) || (numMonth == 9) || (numMonth == 11)) {
		if (numDay > 30){return false;}
	}


	// if any non-digits in the year, invalid date    
	for (var x=0; x < dateYear.length; x++){
		digit = dateYear.substring(x, x+1);
		if ((digit < "0") || (digit > "9")) {return false;}
	}
	

	// convert the text year to a number    
	var numYear = 0;
	for (var x=0; x < dateYear.length; x++) {
		digit = dateYear.substring(x, x+1);
		numYear *= 10;
		numYear += parseInt(digit);
	}

	
	// Year must be a 2-digit year or a 4-digit year    
	if ( (dateYear.length != 2) && (dateYear.length!= 4) ) { return false; }
	
	// if 2-digit year, use 50 as a pivot date   
	if ( (numYear < 50) && (dateYear.length == 2) ) { numYear += 2000;}
	if ( (numYear < 100) && (dateYear.length == 2) ) { numYear += 1900;}
	if ((numYear <= 0) || (numYear > 9999)) {return false; }
	// check for leap year if the month and day is Feb 29    

	if ((numMonth == 2) && (numDay == 29)){
		var div4=numYear%4;
		var div100=numYear%100;
		var div400=numYear%400;
		
		// if not divisible by 4, then not a leap year so Feb 29 is invalid
		if(div4 != 0){return false;}
		// at this point, year is		
		//divisible by 4. So if year is divisible by   
		// 100 and not 400, then it's not a leap year so Feb 29 is invalid 
		if((div100==0) && (div400 !=0)){return false;}
	}

	iEffDay=numDay;
	iEffMonth=numMonth;
	iEffYear=numYear;

	return true;
}

