function emailValidator(theForm){
    var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
    if (Flag == false && theForm.email.value != "") {
		if (theForm.email.value.match(emailExp)){
			Flag = false;
		} else {
			alert("You must enter a valid email address.");
			theForm.email.focus();
			Flag = true;
		}
	}
}

function nameField(theForm) {
	if (theForm.name.value == "") {
		return false;
	} else {
		return true;
	}	
}

function firstNameField(theForm) {
	if (theForm.first_name.value == "") {
		return false;
	} else {
		return true;
	}	
}

function lastNameField(theForm) {
	if (theForm.last_name.value == "") {
		return false;
	} else {
		return true;
	}	
}

function emailField(theForm) {
	if (theForm.email.value == "") {
		return false;
	} else {
		return true;
	}	
}

function address1Field(theForm) {
	if (theForm.address1.value == "") {
		return false;
	} else {
		return true;
	}	
}

function cityField(theForm) {
	if (theForm.city.value == "") {
		return false;
	} else {
		return true;
	}	
}

function stateField(theForm) {
	if (theForm.state.value == "??") {
		return false;
	} else {
		return true;
	}	
}

function zipField(theForm) {
	if (theForm.zip.value == "") {
		return false;
	} else {
		return true;
	}	
}

function countyField(theForm) {
	if (theForm.county.value == "") {
		return false;
	} else {
		return true;
	}	
}

function phoneNbrField(theForm) {
	if (theForm.phone_number.value == "") {
		return false;
	} else {
		return true;
	}
}

function estimatedValField(theForm) {
	if (theForm.estimated_value.value == "") {
		return false;
	} else {
		return true;
	}
}

var Flag = false;


function validateFAForm(form) {
	personalInfoFABlanks(form);
	emailValidator(form);
	if (Flag == true) {
		return false;
	}
}

function personalInfoFABlanks(form){
	if (firstNameField(form)==true && lastNameField(form)==true && address1Field(form)==true && cityField(form)==true && stateField(form)==true && zipField(form)==true && countyField(form)==true && emailField(form)==true && phoneNbrField(form)==true && estimatedValField(form)==true){
		Flag = false;
	} else if (firstNameField(form)==false || lastNameField(form)==false || address1Field(form)==false || cityField(form)==false || stateField(form)==false || zipField(form)==false || countyField(form)==false || emailField(form)==false || phoneNbrField(form)==false || estimatedValField(form)==false){
		Flag = true;
		freeAnalysisErrors(form);
	}
}

function freeAnalysisErrors(form){
	var text = "The following fields are required:";
	if(firstNameField(form)==false){
		text += "\n - First Name";
	}
	if(lastNameField(form)==false){
		text += "\n - Last Name";
	}
	if(address1Field(form)==false){
		text += "\n - Address";
	}
	if(cityField(form)==false){
		text += "\n\ - City";
	}
	if(stateField(form)==false){
		text += "\n\ - State";
	}
	if(zipField(form)==false){
		text += "\n - Zip";
	}
	if(countyField(form)==false){
		text += "\n - County";
	}
	if(phoneNbrField(form)==false){
		text += "\n - Phone Number";
	}
	if(emailField(form)==false){
		text += "\n - Email";
	}
	if(estimatedValField(form)==false){
		text += "\n - Estimated Value";
	}
	text += "\nPlease enter information and resubmit.";
	alert(text);
}

function commentsField(theForm) {
	if (theForm.comments.value == "") {
		return false;
	} else {
		return true;
	}	
}

function personalInfoTABlanks(form){
	if (firstNameField(form)==true && lastNameField(form)==true && address1Field(form)==true && cityField(form)==true && stateField(form)==true && zipField(form)==true && countyField(form)==true && emailField(form)==true && phoneNbrField(form)==true){
		Flag = false;
	} else if (firstNameField(form)==false || lastNameField(form)==false || address1Field(form)==false || cityField(form)==false || stateField(form)==false || zipField(form)==false || countyField(form)==false || emailField(form)==false || phoneNbrField(form)==false){
		Flag = true;
		orderTaxAppealErrors(form);
	}
}

function validateOrderTAForm(form) {
	personalInfoTABlanks(form);
	emailValidator(form);
	if (Flag == true) {
		return false;
	}
}

function orderTaxAppealErrors(form){
	var text = "The following fields are required:";
	if(firstNameField(form)==false){
		text += "\n - First Name";
	}
	if(lastNameField(form)==false){
		text += "\n - Last Name";
	}
	if(address1Field(form)==false){
		text += "\n - Address";
	}
	if(cityField(form)==false){
		text += "\n\ - City";
	}
	if(stateField(form)==false){
		text += "\n\ - State";
	}
	if(zipField(form)==false){
		text += "\n - Zip";
	}
	if(countyField(form)==false){
		text += "\n - County";
	}
	if(phoneNbrField(form)==false){
		text += "\n - Phone Number";
	}
	if(emailField(form)==false){
		text += "\n - Email";
	}
		
	text += "\nPlease enter information and resubmit.";
	alert(text);
}

function validateContactForm(form) {
	contactBlanks(form);
	emailValidator(form);
	if (Flag == true) {
		return false;
	}
}

function contactBlanks(form){
	if (nameField(form)==true && emailField(form)==true && commentsField(form)==true){
		Flag = false;
	} else if (nameField(form)==false || emailField(form)==false || commentsField(form)==false){
		Flag = true;
		contactErrors(form);
	}
}

function contactErrors(form){
	var text = "The following fields are required:";
	if(nameField(form)==false){
		text += "\n - Name";
	}
	if(emailField(form)==false){
		text += "\n\ - Email";
	}
	if(commentsField(form)==false){
		text += "\n\ - Comments";
	}
	text += "\nPlease enter information and resubmit.";
	alert(text);
}



