function verify(form) {
//Check to see that all required fields are filled in
var themessage = "Please complete the following fields: ";
if (!doesExist(form.Title.value)) {
themessage = themessage + " -  Title";
}
if (!doesExist(form.FirstName.value)) {
themessage = themessage + " -  First name";
}
if (!doesExist(form.Surname.value)) {
themessage = themessage + " -  Surname";
}
if (!doesExist(form.HouseRoad.value)) {
themessage = themessage + " -  House and Road";
}
if (!doesExist(form.TownCity.value)) {
themessage = themessage + " -  Town/City";
}
if (!doesExist(form.Postcode.value)) {
themessage = themessage + " -  Postcode";
}
if (!doesExist(form.Email.value)) {
themessage = themessage + " -  Email";
}
if (doesExist(form.Email.value)) {
	//Everything OK so far, check for a valid email address
	checkEmail(form);
	if (emailok == false) {
	themessage = themessage +  " - Invalid E-mail Address! Please re-enter";
	}
}

//alert if fields are empty and cancel form submit
if (themessage == "Please complete the following fields: ") {
	return true;
}
else {
alert(themessage);
return false;
   }
}

function doesExist(inputValue) {
	var aCharExists=0
	if (inputValue) {
		for (var i=0; i<inputValue.length; i++) {
			if (inputValue.charAt(i) != " ") {			
				aCharExists = 1
			}
		}
	}
	if (!aCharExists) {
		return false			
	}
	else {
		return true
	}
}

function checkEmail(form) {
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(form.Email.value)){
emailok=true;
}
else {
emailok=false;
}
}

function goSubmit() {    if (verify(document.form)) { document.form.submit(); }}
