// JavaScript Document
// The function to validate the entire form before submitting
function validateForm() {
	if (document.form1.first.value.length < 2 || document.form1.last.value.length < 3 || document.form1.phone.value.length <5 || document.form1.email.value.length < 7 || document.form1.email.value.indexOf("@") < 1 || document.form1.email.value.indexOf(".") < 1 || document.form1.address1.value.length <5 || document.form1.zip.value.length <5 || document.form1.country.value.length <5 || document.form1.occ.value.length <5){
		window.alert("Please make sure you have completed all fields before submitting the form. The fields containing errors are highlighted in red.");
		return false;
	}
	return true;
}

//To validate the individual sections as we're going along
function validateFirst() {
	if (document.form1.first.value.length < 2){
		document.form1.first.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.first.style.backgroundColor="#DfD";
	return true
}

//To validate the Last name
function validateLast() {
	if (document.form1.last.value.length < 3) {
		document.form1.last.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.last.style.backgroundColor="#DfD";
	return true;
}

function validatePhone() {
	if (document.form1.phone.value.length <5){
		document.form1.phone.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.phone.style.backgroundColor="#DfD";
	return true;
}
//To validate the email
function validateEmail() {
	if (document.form1.email.value.length < 7 || document.form1.email.value.indexOf("@") < 1 || document.form1.email.value.indexOf(".") < 1) {
		document.form1.email.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.email.style.backgroundColor="#DfD";
	return true;
}
//To validate Line 1 of the address
function validateAdd1() {
	if (document.form1.address1.value.length <5){
		document.form1.address1.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.address1.style.backgroundColor="#DfD";
	return true;
}
// To validate Zip
function validateZip() {
	if (document.form1.zip.value.length <5){
		document.form1.zip.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.zip.style.backgroundColor="#DfD";
	return true;
}
//To validate country
function validateCountry() {
	if (document.form1.country.value.length <5){
		document.form1.country.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.country.style.backgroundColor="#DfD";
	return true;
}
//To validate occupation
function validateOcc() {
	if (document.form1.occ.value.length <5){
		document.form1.occ.style.backgroundColor="#fbcdc9";
		return false;
	}
	document.form1.occ.style.backgroundColor="#DfD";
	return true;
}
