
function checkEvaluationForm(evaluation_form) {
	var why = "";
	why += checkField(document.forms.evaluation_form.dinedate.value, 'dine date');
	why += checkName(document.forms.evaluation_form.name.value);
	why += checkEmail(document.forms.evaluation_form.email.value);
	
	
	if (why != "") {
	   alert(why);
	   return false;
	}else{
		return true;
	}
}
function checkApplicationForm(application) {
	var why = "";
	why += checkField(document.forms.application.first_name.value, 'first name');
	why += checkField(document.forms.application.last_name.value, 'last name');
	why += checkField(document.forms.application.address.value, 'address');
	why += checkField(document.forms.application.city.value, 'city');
	why += checkField(document.forms.application.state.value, 'state');
	why += checkField(document.forms.application.zipcode.value, 'zipcode');
	why += checkField(document.forms.application.phone.value, 'phone');
	why += checkEmail(document.forms.application.email.value);
	
	
	if (why != "") {
	   alert(why);
	   return false;
	}else{
		return true;
	}
}

function checkContactForm(contact_form) {
	var why = "";
	why += checkName(document.forms.contact_form.name.value);
	why += checkEmail(document.forms.contact_form.email.value);
	why += checkComments(document.forms.contact_form.comments.value);
	
	if (why != "") {
	   alert(why);
	   return false;
	}else{
		return true;
	}
}

function checkField (strng, field_name) {
	var error = "";
	if (strng == "") {
		error = "Please enter your "+field_name+'.\n';
	}
	if (strng == " ") {
		error = "Please enter your "+field_name+'.\n';
	}
	return error; 
}

function checkEmail (strng) {
	var error="";
	if (strng == "") {
	   error = "You didn't enter an email address.\n";
	}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}

function checkComments(strng) {
	//alert(strng);
	var error = "";
	if (strng == "") {
		error = "Please enter your comment or question.\n";
	}
	if (strng == " ") {
		error = "Please enter your comment or question.\n";
	}
	return error;
	
}

function checkName(strng) {
	//alert(strng);
	var error = "";
	if (strng == "") {
		error = "Please enter your name.\n";
	}
	if (strng == " ") {
		error = "Please enter your name.\n";
	}
	return error;
	
}