// JavaScript Document

function validate_form(){

var name = document.contact_form.name.value;

var email = document.contact_form.email.value;

var comment = document.contact_form.comment.value;

var phone = document.contact_form.phone.value;
var phoneRegxp = /^([0-9\s]{12})$/;	

var nameRegxp = /^([a-zA-Z\.]+) ([a-zA-Z]+)$/;

var emailRegxp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})$/

	if (nameRegxp.test(name) != true) {

 		alert("Invalid name.\r\n\r\nYou must enter at least an initial and a surname.");
		document.contact_form.name.focus();
		document.contact_form.name.select();
		return false;
		}
		    if (emailRegxp.test(email) != true) {

	  		alert("Invalid email.\r\n\r\nYou must enter an email address in the following example format: you@domain.com");
			document.contact_form.email.focus();
			document.contact_form.email.select();
			return false;
			}
				if (phoneRegxp.test(phone) != true) {

		      	alert("The Phone Number entered appears to be invalid.\r\n\r\nYou can only enter a UK phone number in the following example format: 01234 567891");
				document.contact_form.phone.focus();
				document.contact_form.phone.select();
				return false;
				}
		
					if (document.contact_form.comment.value == "") {
		
					 alert("Please enter an enquiry");
					document.contact_form.comment.focus();
					document.contact_form.comment.select();
				return false;
				}
    else {
	return true;
				}
	}



function validate_feedback_form(){

var comment = document.feedback_form.feedback.value;

	if (document.feedback_form.feedback.value == "") {
		
	alert("Please enter some feedback");
	document.feedback_form.feedback.focus();
	document.feedback_form.feedback.select();
	return false;
				}
	
    else {
	return true;
				}
}
