function checkForm(){
	var problem = "";
	
	if(document.form1.subject.value == "select") {
		problem += "* Choose Subject\n";
	};
	
	if(document.form1.email.value){
		if(document.form1.email.value.indexOf('@',0)==-1 || document.form1.email.value.indexOf('.',0)==-1) {
				problem += "* Invalid email\n";
		};
		if(document.form1.email.value != document.form1.email2.value) {
			problem += "* Reconfirm email\n";
			document.form1.email2.value = '';
		};
	}
	
	if(document.form1.reply.value != "NO REPLY" && document.form1.reply.value != "select") {
		if(!document.form1.fName.value) {
			problem +=  "* Enter First Name to recieve reply\n";
		};
		if(document.form1.reply.value == "EMAIL" && !document.form1.email.value) {
			problem +=  "* Enter Email Address to recieve reply\n";
		};
		if(document.form1.reply.value == "PHONE" && !document.form1.phone.value) {
			problem +=  "* Enter Phone number to recieve reply\n";
		};
	};
	
	if(document.form1.add1.value || document.form1.add2.value || document.form1.city.value || document.form1.state.value != "select" || document.form1.zip.value) {
		if(!document.form1.fName.value != "") {
			problem +=  "* Enter First Name to recieve reply\n";
		};
		if(!document.form1.add1.value) {
			problem +=  "* Enter Street Address to complete address\n";
		};
		if(!document.form1.city.value) {
			problem +=  "* Enter City to complete address\n";
		};
		if(document.form1.state.value == "select") {
			problem +=  "* Enter State to complete address\n";
		};
		if(!document.form1.zip.value || document.form1.zip.value.length != 5) {
			problem +=  "* Enter valid Zip to complete address\n";
		};
	};
	if(document.form1.phone.value.length == 0) {
		problem += "* Enter valid phone number.\n";
	};
	if(!document.form1.comments.value) {
		problem +=  "* Enter comments\n";
	};
	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkSysAddonVars() {
	var problem = "";

	if(document.page.NumberOfZones.value.length == 0) {
		problem += "* Need to enter a value for current number of zones.\n";
	}
	if(document.page.NumberOfZonesOnTimer.value.length == 0) {
		problem += "* Need to enter a value for number of zones the timer can handle.\n";
	}
	if(document.page.comments.value.length == 0) {
		problem += "* Need to enter a description of the work.\n";
	}
	if(!(document.page.Front.checked || document.page.LeftSide.checked || document.page.RightSide.checked || document.page.Back.checked)) {
		problem += "* Need to specify an area in which to do the work.\n";
	};
	if(document.page.WellNow[0].checked) {
		if(!(document.page.WellType[0].checked || document.page.WellType[1].checked || document.page.WellType[2].checked)) {
			problem += "* Need to specify well type.\n";
		};
		if(!(document.page.DrinkingWell[0].checked || document.page.DrinkingWell[1].checked || document.page.DrinkingWell[2].checked)) {
			problem += "* Need to specify well use.\n";
		};
	};

	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkSysNewVars() {
	var problem = "";

	if(!(document.page.Front.checked || document.page.LeftSide.checked || document.page.RightSide.checked || document.page.Back.checked)) {
		problem += "* Need to specify an area to do the work.\n";
	};
	if(document.page.ShrubOrOther[0].checked && document.page.comments.value.length == 0) {
		problem += "* Need to enter a description of the work.\n";
	};
	if(document.page.WellNow[0].checked) {
		if(!(document.page.WellType[0].checked || document.page.WellType[1].checked || document.page.WellType[2].checked)) {
			problem += "* Need to specify well type.\n";
		};
		if(!(document.page.DrinkingWell[0].checked || document.page.DrinkingWell[1].checked || document.page.DrinkingWell[2].checked)) {
			problem += "* Need to specify well use.\n";
		};
	};
	if(document.page.EstimateTimeFrame[3].checked && document.page.OtherEstimateTimeFrame.value.length == 0) {
		problem += "* Need to specify a time frame for the work.\n";
	};
	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkContInfoVars() {
	var problem = "";

	if(document.page.CompanyName.value.length == 0) {
		problem += "* Need to enter a company name.\n";
	};
	if(document.page.JobContact.value.length == 0) {
		problem += "* Need to specify who will be the contact for this job.\n";
	};
	if(document.page.JobAddress.value.length == 0) {
		problem += "* Need to enter a job address.\n";
	};
	if(document.page.JobCity.value.length == 0) {
		problem += "* Need to enter a city to complete the job address.\n";
	};
	if(document.page.JobState.selectedIndex == 0) {
		problem += "* Need to enter a city to complete the job address.\n";
	};
	if(document.page.JobZip.value.length != 5) {
		problem += "* Need to enter a valid job zip code to complete the job address.\n";
	};
	if(document.page.CompanyAddress.value.length == 0) {
		problem += "* Need to enter a company address.\n";
	};
	if(document.page.CompanyCity.value.length == 0) {
		problem += "* Need to enter a city to complete the company address.\n";
	};
	if(document.page.CompanyState.selectedIndex == 0) {
		problem += "* Need to enter a state to complete the company address.\n";
	};
	if(document.page.CompanyZip.value.length != 5) {
		problem += "* Need to enter a valid zip code to complete the company address.\n";
	};
	if(document.page.WorkNumber1.value.length == 0) {
		problem += "* Need to enter a valid company phone number.\n";
	};

	if(document.page.ReplyBy.selectedIndex == 0) {
		problem += "* Need to enter a method to reply.\n";
	} else if (document.page.ReplyBy.selectedIndex == 1) {
	} else {
		if(document.page.EmailAddress.value.length == 0 || document.page.EmailConfirm.value.length == 0) {
			problem += "* Need to enter a valid email address.\n";
		} else if(document.page.EmailAddress.value.indexOf('@',0)==-1 || document.page.EmailAddress.value.indexOf('.',0)==-1) {
			problem += "* The email address entered was not valid.\n";
		} else if(document.page.EmailAddress.value != document.page.EmailConfirm.value) {
			problem += "* Confirmation email address does not match.\n";
			document.page.EmailConfirm.value = "";
		};
	};

	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkHomeInfoVars() {
	var problem = "";

	if(document.page.FirstName.value.length == 0) {
		problem += "* Need to enter a First Name.\n";
	};
	if(document.page.LastName.value.length == 0) {
		problem += "* Need to enter a last name.\n";
	};
	if(document.page.JobAddress.value.length == 0) {
		problem += "* Need to enter a job address.\n";
	};
	if(document.page.JobCity.value.length == 0) {
		problem += "* Need to enter a city to complete the job address.\n";
	};
	if(document.page.JobState.selectedIndex == 0) {
		problem += "* Need to enter a state to complete the job address.\n";
	};
	if(document.page.JobZip.value.length != 5) {
		problem += "* Need to enter a valid zip code to complete the job address.\n";
	};
	if(document.page.MailingAddress.value.length == 0) {
		problem += "* Need to enter a mailing address.\n";
	};
	if(document.page.MailingCity.value.length == 0) {
		problem += "* Need to enter a city to complete the mailing address.\n";
	};
	if(document.page.MailingState.selectedIndex == 0) {
		problem += "* Need to enter a state to complete the mailing address.\n";
	};
	if(document.page.MailingZip.value.length != 5) {
		problem += "* Need to enter a valid zip code to complete the mailing address.\n";
	};
	if(document.page.HomeNumber.value.length == 0) {
		problem += "* Need to enter a home phone number.\n";
	};

	if(document.page.ReplyBy.selectedIndex == 0) {
		problem += "* Need to enter a method to reply.\n";
	} else if (document.page.ReplyBy.selectedIndex == 1) {
	} else {
		if(document.page.EmailAddress.value.length == 0 || document.page.EmailConfirm.value.length == 0) {
			problem += "* Need to enter a valid email address.\n";
		} else if(document.page.EmailAddress.value.indexOf('@',0)==-1 || document.page.EmailAddress.value.indexOf('.',0)==-1) {
			problem += "* The email address entered was not valid\n";
		} else if(document.page.EmailAddress.value != document.page.EmailConfirm.value) {
			problem += "* Reconfirm email\n";
			document.page.EmailConfirm.value = "";
		};
	};

	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkSysRepairVars() {
	var problem = "";

	if(!(document.page.Front.checked || document.page.LeftSide.checked || document.page.RightSide.checked || document.page.Back.checked)) {
		problem += "* Need to specify an area to do the work.\n";
	};
	if(document.page.RepairType[0].checked) {
		if(!(document.page.brokenHeads.checked || document.page.exPipes.checked || document.page.inPipes.checked || document.page.headMoves.checked)) {
			problem += "* Need to specify what needs to be repaired.\n";
		};
		if(document.page.brokenHeads.checked && document.page.NumberHeads.value.length == 0) {
			problem += "* Need to specify the number of broken heads.\n";
		};
		if(document.page.exPipes.checked && document.page.NumberExPipes.value.length == 0) {
			problem += "* Need to specify the number of broken exterior pipes.\n";
		};
		if(document.page.inPipes.checked && document.page.NumberInPipes.value.length == 0) {
			problem += "* Need to specify the number of broken interior pipes.\n";
		};
		if(document.page.headMoves.checked && document.page.NumberMoves.value.length == 0) {
			problem += "* Need to specify the number of heads to be moved.\n";
		};
	} else if(document.page.RepairType[1].checked) {
		if(document.page.RepairComments.value.length == 0) {
			problem += "* Need to specify.\n";
		};
	} else if(document.page.RepairType[2].checked) {
		if(!(document.page.WellType[0].checked || document.page.WellType[1].checked || document.page.WellType[2].checked)) {
			problem += "* Need to specify well type. \n";
		};
		if(!(document.page.DrinkingWell[0].checked || document.page.DrinkingWell[1].checked || document.page.DrinkingWell[2].checked)) {
			problem += "* Need to specify well use. \n";
		};
		if(document.page.WellComments.value.length == 0) {
			problem += "* Confirmation email address does not match.\n";
		};
	};

	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function autoHomeMailingAddress() {
	if(document.page.MailingSame.checked) {
		document.page.MailingAddress.value = document.page.JobAddress.value;
		document.page.MailingAddress2.value = document.page.JobAddress2.value;
		document.page.MailingCity.value = document.page.JobCity.value;
		document.page.MailingZip.value = document.page.JobZip.value;
		document.page.MailingState.selectedIndex = document.page.JobState.selectedIndex;
	} else {
		document.page.MailingAddress.value = '';
		document.page.MailingAddress2.value = '';
		document.page.MailingCity.value = '';
		document.page.MailingZip.value = '';
		document.page.MailingState.selectedIndex = 0;
	};
};

function autoContMailingAddress() {
	if(document.page.MailingSame.checked) {
		document.page.JobAddress.value = document.page.CompanyAddress.value;
		document.page.JobAddress2.value = document.page.CompanyAddress2.value;
		document.page.JobCity.value = document.page.CompanyCity.value;
		document.page.JobZip.value = document.page.CompanyZip.value;
		document.page.JobState.selectedIndex = document.page.CompanyState.selectedIndex;
	} else {
		document.page.JobAddress.value = '';
		document.page.JobAddress2.value = '';
		document.page.JobCity.value = '';
		document.page.JobZip.value = '';
		document.page.JobState.selectedIndex = 0;
	};
};

function changeDrinkingWater() {
	if(document.page.DrinkingWell[0].checked == true) {
		document.page.CityWaterEstimate[1].checked = true;
	} else {
		document.page.CityWaterEstimate[0].checked = true;
	};
};

function checkNewWellVars() {
	var problem = "";

	if(!(document.page.Front.checked || document.page.LeftSide.checked || document.page.RightSide.checked || document.page.Back.checked)) {
		problem += "* Need to specify a preferred area for the well installation.\n";
	};

	if(document.page.EstimateTimeFrame[3].checked==true&&document.page.OtherEstimateTimeFrame.value.length==0) {
		problem += "* Need to enter a time frame in which you would like the work done.\n";
	};
	
	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkWinterizeVars() {
	var problem = "";

	if(document.page.EstimateTimeFrame[3].checked==true&&document.page.OtherEstimateTimeFrame.value.length==0) {
		problem += "* Need to enter a time frame in which you would like the work done.\n";
	};
		
	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkStartupVars() {
	var problem = "";

	if(document.page.EstimateTimeFrame[3].checked==true&&document.page.OtherEstimateTimeFrame.value.length==0) {
		problem += "* Need to enter a time frame in which you would like the work done.\n";
	};
		
	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkRepairVars() {
	var problem = "";

	if(document.page.EstimateTimeFrame[3].checked==true&&document.page.OtherEstimateTimeFrame.value.length==0) {
		problem += "* Need to enter a time frame in which you would like the work done.\n";
	};
		
	if(problem) {
		alert("Please make necessary changes to the following generated errors:\n" + problem);
		return false;
	} else {
		return true;
	};
};

function checkExtensions() {
	var badList = Array('exe','com','bat','pl','php','cgi','html','htm','shtml','shtm','php3','php4','php2','mp3','mpg','avi');
	
	if(document.page.userfile.value=="") {
		alert("* Must enter a value for the filename.");
		return false;
	};

	var filename = document.page.userfile.value;
	var extension = filename.substring((filename.indexOf('.')+1),filename.length);

	if(filename.indexOf('.')<0) {
		alert("* Filename must have a valid extension.");
		return false;
	};
	
	var problem = "";
	
	for(var i=0; i<badList.length; i++) {
		if(extension==badList[i]) problem += "* File cannot have an extension of "+extension;
	};
	
	if(problem.length!=0) {
		alert(problem);
		return false;	
	} else {
		return true;
	};
};

function checkSearchSize() {
	if(document.searchform.query.value.length<3) {
		alert("Search needs to be atleast 3 characters long.");
		return false;
	} else {
		return true;
	};
};