function Submit() {
	if (validate()){
		document.forms["frmApplication"].submit();
	}
	
}

function validate() {
	document.frmApplication.txtLastName.value = trim(document.frmApplication.txtLastName.value)
	if (document.frmApplication.txtLastName.value == ''){
		alert ("Please enter a Last Name.");
		document.frmApplication.txtLastName.focus();
		return false;
	}
	document.frmApplication.txtFirstName.value = trim(document.frmApplication.txtFirstName.value)
	if (document.frmApplication.txtFirstName.value == ''){
		alert ("Please enter a First Name.");
		document.frmApplication.txtFirstName.focus();
		return false;
	}
	if (document.frmApplication.txtSSN.value == ''){
	}
	else {	
			if (!isFieldNumeric(document.frmApplication.txtSSN)){
				alert ("Please enter a numeric Social Security Number.");
				document.frmApplication.txtSSN.focus();
				return false;
			}
	}
	if (document.frmApplication.txtSSN.value == ''){
	}
	else {	
			if ((document.frmApplication.txtSSN.value.length)== '9'){
			}
			else{	
				alert ("Please enter a 9 digit Social Security Number.");
				document.frmApplication.txtSSN.focus();
				return false;
			}
			if ((document.frmApplication.txtSSN.value)> '799999999'){
				alert ("Please enter a Social Security Number smaller than 799999999.");
				document.frmApplication.txtSSN.focus();
				return false;
			}	
	}
	
	

	var intBirthMonth
	var intBirthDay
	var intBirthYear
	intBirthMonth = document.frmApplication.txtBirthMonth.value;
	intBirthDay = document.frmApplication.txtBirthDay.value;
	intBirthYear = document.frmApplication.txtBirthYear.value;

	if ((intBirthMonth == '')&&(intBirthDay == '')&&(intBirthYear == '')) {
		alert ("Please enter a Date of Birth in MM DD YYYY format.");
		document.frmApplication.txtBirthMonth.focus();
		return false;
	}
	else 
	{
		// make sure the birth date is valid	
		if (!isValidDate(intBirthMonth, intBirthDay, intBirthYear)){
			alert ("Please enter a valid Date of Birth in MM DD YYYY format.");
			document.frmApplication.txtBirthMonth.focus();
			return false;x
		}
		// make sure the birth date is not in the future		
		if (isFutureDate(intBirthMonth, intBirthDay, intBirthYear)){
			alert ("Please enter a birth date that is not in the future.");
			document.frmApplication.txtBirthMonth.focus();
			return false;
		}
		
		var now = new Date;
		var maxYear;
		var minYear;
		minYear = now.getFullYear() - 10;
		maxYear = now.getFullYear() - 95;
		
		if (intBirthYear > minYear){
			alert ("Consumer must be at least 10 years old.");
			document.frmApplication.txtBirthMonth.focus();
			return false;
		}
		else if (intBirthYear  == minYear){
			if ((now.getMonth() + 1) < intBirthMonth){
				alert ("Consumer must be at least 10 years old.");
				document.frmApplication.txtBirthMonth.focus();
				return false;
			}
			else if ((now.getMonth() + 1) == intBirthMonth){
				if (now.getDate() < intBirthDay){
					alert ("Consumer must be at least 10 years old.");
					document.frmApplication.txtBirthMonth.focus();
					return false;
				}
			}			
		}
					
		else if (intBirthYear > maxYear){
		}
		else if (intBirthYear == maxYear){
			if ((now.getMonth() + 1) > intBirthMonth){
				alert ("Consumer must be less than 95 years old.");
				document.frmApplication.txtBirthMonth.focus();				
				return false;
			}
			else if ((now.getMonth() + 1) == intBirthMonth){
				if (now.getDate() >= intBirthDay){
					alert ("Consumer must be less than 95 years old.");
					document.frmApplication.txtBirthMonth.focus();
					return false;
				}
			}
		}
		else if (intBirthYear < maxYear){
			alert ("Consumer must be less than 95 years old");
			document.frmApplication.txtBirthMonth.focus();
			return false;
		}
	}
	
	if ((document.frmApplication.chkAIDSHIV.checked) ||
		(document.frmApplication.chkHemophilia.checked)||
		(document.frmApplication.chkAlcohol.checked)||
		(document.frmApplication.chkHipKnee.checked)||
		(document.frmApplication.chkAmputation.checked)||
		(document.frmApplication.chkKidneyFailure.checked)||
		(document.frmApplication.chkArthritis.checked)||
		(document.frmApplication.chkMentalIllness.checked)||
		(document.frmApplication.chkAttentionDef.checked)||
		(document.frmApplication.chkCognitiveDisability.checked)||
		(document.frmApplication.chkAutism.checked)||
		(document.frmApplication.chkMissingLimb.checked)||
		(document.frmApplication.chkBackInjury.checked)||
		(document.frmApplication.chkMultipleSclerosis.checked)||
		(document.frmApplication.chkBlindness.checked)||
		(document.frmApplication.chkMuscularDystrophy.checked)||
		(document.frmApplication.chkBrainInjury.checked)||
		(document.frmApplication.chkMyofascialDisorder.checked)||
		(document.frmApplication.chkCancer.checked)||
		(document.frmApplication.chkParaplegia.checked)||
		(document.frmApplication.chkCarpalTunnel.checked)||
		(document.frmApplication.chkPostTraumStress.checked)||
		(document.frmApplication.chkCerebralPalsy.checked)||
		(document.frmApplication.chkRespiratoryPulmonary.checked)||
		(document.frmApplication.chkCysticFibrosis.checked)||
		(document.frmApplication.chkSevereArthritis.checked)||
		(document.frmApplication.chkDeaf.checked)||
		(document.frmApplication.chkSpecificLearningDis.checked)||
		(document.frmApplication.chkDepression.checked)||
		(document.frmApplication.chkSpinalCordInjury.checked)||
		(document.frmApplication.chkDiabetes.checked)||
		(document.frmApplication.chkStroke.checked)||
		(document.frmApplication.chkEpilepsy.checked)||
		(document.frmApplication.chkOther.checked)||
		(document.frmApplication.chkFibromyalgia.checked)||
		(document.frmApplication.chkUnknown.checked)||
		(document.frmApplication.chkHeartDisease.checked)){
	}
	else{	
		alert ("Please select an Impairment.");
		document.frmApplication.chkAIDSHIV.focus();
		return false;
	}
	
	
	//
	// verify UNKNOWN and OTHER explainations
	//
	frmApplication.txtOther.value = trim(frmApplication.txtOther.value);
	frmApplication.txtUnknown.value = trim(frmApplication.txtUnknown.value);

	if ((document.frmApplication.chkOther.checked) && (document.frmApplication.txtOther.value == '')) {
		alert ("Please enter Other - Please Explain.");
		document.frmApplication.txtOther.focus();
		return false;
	}

	if ((!document.frmApplication.chkOther.checked) && (document.frmApplication.txtOther.value != '')) {
		alert ("Other explaination found, please select Other impairment.");
		document.frmApplication.chkOther.focus();
		return false;
	}
	
	if ((document.frmApplication.chkUnknown.checked) && (document.frmApplication.txtUnknown.value == '')) {
		alert ("Please enter Unknown - Please Explain.");
		document.frmApplication.txtUnknown.focus();
		return false;
	}
	
	if ((!document.frmApplication.chkUnknown.checked) && (document.frmApplication.txtUnknown.value != '')) {
		alert ("Unknown explaination found, please select Unknown impairment.");
		document.frmApplication.chkUnknown.focus();
		return false;
	}
	
	
	if (document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == ''){
		alert ("Please enter a Way to contact you.");
		document.frmApplication.cmbContactMethod.focus();
		return false;
	}
	//cmbContactMethod.value 004 = "Other"
	if ((document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == '004') && (document.frmApplication.txtOtherContactMethodDesc.value == '')){
		alert ("Please enter an Other Contact Method.");
		document.frmApplication.txtOtherContactMethodDesc.focus();
		return false;
	}
	//cmbContactMethod.value 001 = "Mail"
	//5/29/02 change to make address info required all of the time not just when contact method = mail
	//if ((document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == '001') && (document.frmApplication.txtAddress1.value == '') && (document.frmApplication.txtAddress2.value == '')){
	if ((document.frmApplication.txtAddress1.value == '') && (document.frmApplication.txtAddress2.value == '')){
		alert ("Please enter an Address.");
		document.frmApplication.txtAddress1.focus();
		return false;
	}
	//cmbContactMethod.value 001 = "Mail"
	//5/29/02 change to make address info required all of the time not just when contact method = mail
	//if ((document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == '001') && (document.frmApplication.txtCity.value == '')){
	if (document.frmApplication.txtCity.value == ''){
		alert ("Please enter a City.");
		document.frmApplication.txtCity.focus();
		return false;
	}
	//cmbContactMethod.value 001 = "Mail"
	//5/29/02 change to make address info required all of the time not just when contact method = mail
	//if ((document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == '001') && (document.frmApplication.cmbState.options[document.frmApplication.cmbState.selectedIndex].value == '')){
	if (document.frmApplication.cmbState.options[document.frmApplication.cmbState.selectedIndex].value == ''){	
		alert ("Please select a State.");
		document.frmApplication.cmbState.focus();
		return false;
	}
	//cmbContactMethod.value 001 = "Mail"
	//5/29/02 change to make address info required all of the time not just when contact method = mail
	//if ((document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == '001') && (document.frmApplication.txtZipCode1.value == '')){
	if (document.frmApplication.txtZipCode1.value == ''){	
		alert ("Please enter a Zip Code.");
		document.frmApplication.txtZipCode1.focus();
		return false;
	}
	if (document.frmApplication.txtZipCode1.value == ''){
	}
	else{
		if (!isFieldNumeric(document.frmApplication.txtZipCode1)){
			alert ("Please enter a numeric Zip Code.");
			document.frmApplication.txtZipCode1.focus();
			return false;
		}
	}		
	if (document.frmApplication.txtZipCode1.value == ''){
	}
	else{
		if ((document.frmApplication.txtZipCode1.value.length)== '5'){
		}
		else{	
			alert ("Please enter a 5 digit Zip Code.");
			document.frmApplication.txtZipCode1.focus();
			return false;
		}
	}
	if (document.frmApplication.txtZipCode2.value == ''){
	}
	else{
		if (!isFieldNumeric(document.frmApplication.txtZipCode2)){
			alert ("Please enter a numeric Zip Code.");
			document.frmApplication.txtZipCode2.focus();
			return false;
		}
	}
	if (document.frmApplication.txtZipCode2.value == ''){
	}
	else{
		if (document.frmApplication.txtZipCode2.value.length == '4'){
		}	
		else{
			alert ("Please enter a valid Zip Code.  The 4 digit extension is optional.");
			document.frmApplication.txtZipCode2.focus();
			return false;
		}
	}
	if(document.frmApplication.cmbState.options[document.frmApplication.cmbState.selectedIndex].value == 'WI'){
		if ((document.frmApplication.txtZipCode1.value < '53000') || (document.frmApplication.txtZipCode1.value > '54999')){
			alert ("Please enter a valid Wisconsin Zip Code.");
			document.frmApplication.txtZipCode1.focus();
			return false;
		}
	}
	if (!document.frmApplication.txtZipCode2.value == ''){
		if (document.frmApplication.txtZipCode1.value == ''){
			alert ("Please enter a Zip Code.");
			document.frmApplication.txtZipCode1.focus();
			return false;
		}
	}		
	if (document.frmApplication.txtZipCode2.value == ''){
	}
	else{
		if (!isFieldNumeric(document.frmApplication.txtZipCode2)){
			alert ("Zip Code must be numeric.");
			document.frmApplication.txtZipCode2.focus();
			return false;
		}
	}
	if (document.frmApplication.cmbCounty.value == ''){
		alert ("Please enter a County.");
		document.frmApplication.cmbCounty.focus();
		return false;
	}
	//cmbContactMethod.value 002 = "Telephone"
	if ((document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == '002') && (document.frmApplication.txtTelephone1.value == '') & (document.frmApplication.txtTelephoneMess1.value == '')){
		alert ("Please enter a Telephone Number.");
		document.frmApplication.txtTelephone1.focus();
		return false;
	}		
	if ((document.frmApplication.txtTelephone1.value == '') && (document.frmApplication.txtTelephone2.value == '') && (document.frmApplication.txtTelephone3.value == ''))	{
	}
	else {	
			if ((!isFieldNumeric(document.frmApplication.txtTelephone1)) || (!isFieldNumeric(document.frmApplication.txtTelephone2)) || (!isFieldNumeric(document.frmApplication.txtTelephone3))){
				alert ("Please enter a numeric Telephone Number.");
				document.frmApplication.txtTelephone1.focus();
				return false;
			}
	}
	if ((document.frmApplication.txtTelephone1.value == '') && (document.frmApplication.txtTelephone2.value == '') && (document.frmApplication.txtTelephone3.value == ''))	{
	}
	else {
		if ((document.frmApplication.txtTelephone1.value.length) + (document.frmApplication.txtTelephone2.value.length) + (document.frmApplication.txtTelephone3.value.length) == '10'){
		}
		else {	
				alert ("Please enter a 10 digit Telephone Number.");
				document.frmApplication.txtTelephone1.focus();
				return false;
		}
	}
	if ((document.frmApplication.txtTelephoneMess1.value == '') && (document.frmApplication.txtTelephoneMess2.value == '') && (document.frmApplication.txtTelephoneMess3.value == ''))	{
	}
	else {	
			if ((!isFieldNumeric(document.frmApplication.txtTelephoneMess1)) || (!isFieldNumeric(document.frmApplication.txtTelephoneMess2)) || (!isFieldNumeric(document.frmApplication.txtTelephoneMess3))){
				alert ("Please enter a numeric Messages Telephone Number.");
				document.frmApplication.txtTelephoneMess1.focus();
				return false;
			}
	}
	if ((document.frmApplication.txtTelephoneMess1.value == '') && (document.frmApplication.txtTelephoneMess2.value == '') && (document.frmApplication.txtTelephoneMess3.value == ''))	{
	}
	else {	
		if ((document.frmApplication.txtTelephoneMess1.value.length) + (document.frmApplication.txtTelephoneMess2.value.length) + (document.frmApplication.txtTelephoneMess3.value.length) == '10'){
		}
		else {	
				alert ("Please enter a 10 digit Messages Telephone Number.");
				document.frmApplication.txtTelephoneMess1.focus();
				return false;
		}
	}
	//cmbContactMethod.value 003 = "e-Mail"
	if ((document.frmApplication.cmbContactMethod.options[document.frmApplication.cmbContactMethod.selectedIndex].value == '003') && (document.frmApplication.txtEmail.value == '')){
		alert ("Please enter an E-mail Address.");
		document.frmApplication.txtEmail.focus();
		return false;
	}
	if (document.frmApplication.cmbServiceLocation.options[document.frmApplication.cmbServiceLocation.selectedIndex].value == ''){
		alert ("Please enter a Preferred Service Location.");
		document.frmApplication.cmbServiceLocation.focus();
		return false;
	}
	//cmbAccommodation.value '005' = "Other"
	if ((document.frmApplication.cmbAccommodation.options[document.frmApplication.cmbAccommodation.selectedIndex].value == '005') && (document.frmApplication.txtOtherAccommodation.value == '')){
		alert ("Please enter an Other Accommodation.");
		document.frmApplication.txtOtherAccommodation.focus();
		return false;
	}

	// the length of txtComments should be less than 2000 characters
	if (textLength(document.frmApplication.txtComments) > 2000){
		alert ("Comments must be less than 2000 character long. Your comments has "+textLength(document.frmApplication.txtComments)+" characters.");
		document.frmApplication.txtComments.focus();
		return false;
	}
		
return true;
}
