function doValidation(theForm)
{
    var checkStr=theForm.firstname.value;
	if (checkStr == null || checkStr == "" || isNaN(checkStr)==false) {
		alert("Please enter a valid first name.");
		theForm.firstname.focus();
		return (false);
	}
	
	checkStr=theForm.lastname.value;
	if (checkStr == null || checkStr == "" || isNaN(checkStr)==false) {
		alert("Please enter a valid last name.");
		theForm.lastname.focus();
		return (false);
	}

	if (!checkEmptyField (theForm.address, "Please enter a valid address.")) {
		return false;
	}

	if (!checkEmptyField (theForm.city, "Please enter a valid city.")) {
		return false;
	}
		
	/*  Allows only valid State */
	checkStr = theForm.state[ theForm.state.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Please select a state.");
		theForm.state.focus();
		return (false);
	}

	/* Allows only valid Zip */
	if (!checkZip (theForm)) {
		return false;
	}

	/* Allows only valid Email address. */
	checkStr=theForm.email.value;
	if(checkStr=="" || checkStr.lastIndexOf("@")==-1 || checkStr.lastIndexOf(".")==-1)
	{
	alert("Please enter a valid Email address");
	theForm.email.focus();
	return false;
	}

	var emailArr=checkStr.split("@");
	var user = new String( emailArr[0] );
	var domainAddress = new String( emailArr[1] );
	var domainAddressArr = domainAddress.split(".");
	var domain = new String( domainAddressArr[0] );
	var net = new String( domainAddressArr[1] );
	
	if(user.length==0)
	{
	alert("Please enter a valid Email address.");
	theForm.email.focus();
	return false;	
	}
	if(domain.length==0)
	{
	alert("Please enter a valid Email address.");
	theForm.email.focus();
	return false;
	}
	if(net.length==0)
	{
	alert("Please enter a valid Email address.");
	theForm.email.focus();
	return false;
	}
	
	checkStr=theForm.dayareacode.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr) || checkStr.length!=3){
	alert("Please enter a valid day phone number");
	theForm.dayareacode.focus();
	return(false);
	}

	checkStr=theForm.dayprefix.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr) || checkStr.length!=3){
	alert("Please enter a valid day phone number.");
	theForm.dayprefix.focus();
	return(false);
	}

	checkStr=theForm.dayphone.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr) || checkStr.length!=4){
	alert("Please enter a valid day phone number.");
	theForm.dayphone.focus();
	return(false);
	}

	checkStr=theForm.eveareacode.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr) || checkStr.length!=3){
	alert("Please enter valid evening phone number.");
	theForm.eveareacode.focus();
	return(false);
	}

	checkStr=theForm.eveprefix.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr) || checkStr.length!=3){
	alert("Please enter valid evening phone number.");
	theForm.eveprefix.focus();
	return(false);
	}

	checkStr=theForm.evephone.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr) || checkStr.length!=4){
	alert("Please enter valid evening phone number.");
	theForm.evephone.focus();
	return(false);
	}
	/* Best time 
	checkStr = theForm.bestime[ theForm.bestime.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Please select the best time for contact.");
		theForm.bestime.focus();
		return (false);
	}*/
	/* currentry insured */
	checkStr = theForm.insured[ theForm.insured.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Are you currently insured?");
		theForm.insured.focus();
		return (false);
	}
	/* pre-existing cond */
	checkStr = theForm.conditions[ theForm.conditions.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Any pre-existing conditions that might affect you premium?");
		theForm.conditions.focus();
		return (false);
	}
	/* prescriptions 
	checkStr = theForm.prescriptions[ theForm.prescriptions.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Are you taking prescription medication?\n(excluding birth control, viagra, allergy)");
		theForm.prescriptions.focus();
		return (false);
	}*/

	var checkStr = theForm.gender[ theForm.gender.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Please indicate your gender.");
		theForm.gender.focus();
		return (false);
	}
	
	
	
	var filledOut = true;

	filledOut = checkEmptyField (theForm.bmonth, "Please select your date of birth.");
	if (!filledOut) {
		return false;
	}
	filledOut = checkEmptyField (theForm.bday, "Please select your date of birth.");
	if (!filledOut) {
		return false;
	}

	var currentTime = new Date()
	var year = currentTime.getFullYear()
	checkStr=theForm.byear.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr) || checkStr.length!=4 || checkStr<1900 || checkStr>year){
	alert("Please select your date of birth.");
	theForm.byear.focus();		
	return(false);
	}
	
	/* height - ft */
	checkStr=theForm.ft.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr)){
	alert("Please enter your height.");
	theForm.ft.focus();
	return(false);
	}
	/* height - inches */
	checkStr=theForm.inch.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr)){
	alert("Please enter your height.");
	theForm.inch.focus();
	return(false);
	}
	/* weight */
	checkStr=theForm.wgt.value;
	if(checkStr == null || checkStr == "" || isNaN(checkStr)){
	alert("Please enter your weight.");
	theForm.wgt.focus();
	return(false);
	}

	var checkStr = theForm.tobacco[ theForm.tobacco.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Are you a tobacco user?");
		theForm.tobacco.focus();
		return (false);
	}
	/*
	var checkStr = theForm.selfemp[ theForm.selfemp.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Are you Self-Employed?");
		theForm.selfemp.focus();
		return (false);
	}*/

	var checkLife = getCheckedValue(theForm.life);
	
	if (checkLife=='Y'){
		
		var checkStr = theForm.lengthterm[ theForm.lengthterm.selectedIndex ].value;
		if (checkStr == null || checkStr == "") {
			alert("Please select the length of term.");
			theForm.lengthterm.focus();
			return (false);
		}
		
		var checkStr = theForm.coverageammount[ theForm.coverageammount.selectedIndex ].value;
		if (checkStr == null || checkStr == "") {
			alert("Please select the coverage amount.");
			theForm.coverageammount.focus();
			return (false);
		}
		var checkStr = theForm.income[ theForm.income.selectedIndex ].value;
		if (checkStr == null || checkStr == "") {
			alert("Please select your total household income.");
			theForm.income.focus();
			return (false);
		}
	}
	/*
	var checkStr = theForm.diagnosed[ theForm.diagnosed.selectedIndex ].value;
	if (checkStr == null || checkStr == "") {
		alert("Please select if you or anyone requesting insurance ever been diagnosed with Asthma and/or High Blood Pressure (HBP)");
		theForm.diagnosed.focus();
		return (false);
	}
	
	var checkStr = theForm.pregnant[ theForm.pregnant.selectedIndex ].value;
	if(checkStr == null || checkStr == "") {
		alert("Please select if anyone requesting coverage is currently pregnant.");
		theForm.pregnant.focus();		
		return(false);
	}*/
	
    return (true);
}

function checkEmptyField (fieldObj, message)
{
	var checkStr=fieldObj.value;

	if(checkStr == null || checkStr == "") {
		alert(message);
		fieldObj.focus();
		return false;
	}

	return true;
}

function checkZip (theForm)
{
	var objRegExp = /(^\d{5}$)/;

	//check for valid US Zipcode
	if (!objRegExp.test(theForm.zip.value)) {
		alert("Please enter a valid zip.");
		theForm.zip.focus();
		return false;
	}

	return true;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}