// JavaScript Document
function verify(theForm) {
	empties = ""; //set up variable for list of fields that are empty
	subm = "true"; //set up for allowing submit form if no fields are empty
	
	// clear suspicious characters from fields
	for (var i = 0; i < theForm.elements.length; i++) {
		if (theForm.elements[i].type == "text" || theForm.elements[i].type == "textarea") {
			thisvalue = theForm.elements[i].value;
			if (thisvalue.length > 0) {
				newvalue = thisvalue.replace(/[<>\[\]\{\}:]/g,"");
				theForm.elements[i].value = newvalue;
			}
		}
	}

	if (theForm.formid.value == "paypal") {
		if (theForm.os1.value == "") addToList("Please enter your Name.");
		if (theForm.amount.value == "") addToList("Please enter the amount.");
	}
	if (theForm.formid.value == "clientedit" || theForm.formid.value == "newsletter") {
		if (theForm.fname.value == "") addToList("Please enter your First Name.");
		if (theForm.lname.value == "") addToList("Please enter your Last Name.");
		if (theForm.email.value == "") addToList("Your email is needed.");
		if (theForm.passwd.value == "") addToList("Please enter a password.");
		if (theForm.passverify.value == "") addToList("Please verify your password.");
		if (theForm.passwd.value != theForm.passverify.value) addToList("Passwords do not match.");
	}
	if (theForm.formid.value == "survey") {
		if (theForm.custname.value == "") addToList("Please enter your Name.");
		if (theForm.email.value == "") addToList("Please enter your Email.");
		if (theForm.servicetype.value == "") addToList("What was the requested service?");
		if (theForm.referredhow.value == "") addToList("How did you hear about us?");
	}
	if (theForm.formid.value == "testimonial") {
		if (theForm.name.value == "") addToList("Please enter your Name.");
	}

	if (subm == "false") {
		if (empties != "") alert ("The following must be corrected: \r" + empties);
		return false;
	} else {
		theForm.submit();
	}
}
	
function addToList(fldname) {
	empties += fldname + "\r";
	subm = "false";
}

