// JavaScript Document

function checkWholeForm(theForm) {
    var why = "";
	why += isEmpty(theForm.name.value,"Name");
    why += checkEmail(theForm.email.value);
	why += isEmpty(theForm.utility.value,"Utility Name");
	why += isEmpty(theForm.jobTitle.value,"Job Title");
	why += isEmpty(theForm.address1.value,"Address");
	why += isEmpty(theForm.city.value,"City");
	why += isEmpty(theForm.state.value,"State/Prov");
	why += isEmpty(theForm.zipcode.value,"Zip/Postal Code");
	why += isEmpty(theForm.country.value,"Country");
	why += isEmpty(theForm.country.value,"Phone");
    
    if (why != "") {
       alert(why);
       return false;
    }
return true;
}

function checkEmail(strng){
	var emailFilter=/^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
	if (!(emailFilter.test(strng))) { 
		   error = "Please enter a valid email address.\n";
	}
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
	if (strng.match(illegalChars)) {
	   error = "The email address contains illegal characters.\n";	
	}
	return error;
}

function isEmpty(strng,theField){
	error = ""
	if (strng == "") {
		error = theField+" is a required field.\n";
	}
	return error;
}
