function validate_name() {
  var check = document.getElementById("name").value;
  if (check=="" || check==" ") {
	  alert("You did not enter a parent/enquirer name.\n\nPlease enter your name in the 'Parent/enquirer's Name' field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_phone() {
  var check = document.getElementById("phone").value;
  var checkmob = document.getElementById("mobile").value;
  if ((check=="" || check==" ") && (checkmob=="" || checkmob==" ")) {
	  alert("You did not enter a phone or mobile number.\n\nPlease enter a phone or mobile number in the appropriate field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_email() {
  var check = document.getElementById("email").value;
  apos=check.indexOf("@")
  dotpos=check.lastIndexOf(".")
  if (check=="" || check==" ") {
	  alert("You did not enter your email address.\n\nPlease enter your email address\n in the 'Email address' field.");
	  return false;
  }  
  else if (check.length<6||apos<1||dotpos-apos<2) {
	  alert("The email address you have entered is not valid.\n\nPlease re-enter a valid email address in the 'Email address' field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_pref_contact() {
  var check = document.getElementById("pref_contact").value;
  if (check=="" || check==" " || check=="--- Please select ---") {
	  alert("You did not select a preferred method of contact.\n\nPlease select an option from the 'Preferred method of contact' field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_child_name() {
  var check = document.getElementById("child_name").value;
  if (check=="" || check==" ") {
	  alert("You did not enter a child/adolescent's name.\n\nPlease enter a name in the 'Child/adolescent's name' field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_relationship() {
  var check = document.getElementById("relationship").value;
  if (check=="" || check==" ") {
	  alert("You did not enter a relationship to the child/adolescent.\n\nPlease enter a relationship in the 'Relationship to child/adolescent' field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_pref_day() {
  var check = document.getElementById("pref_day").value;
  if (check=="" || check==" " || check=="--- Please select ---") {
	  alert("You did not select a preferred day for the booking.\n\nPlease select a preferred day for the booking from the the 'Preferred day of booking' field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_pref_gender() {
  var check = document.getElementById("pref_gender").value;
  if (check=="" || check==" " || check=="--- Please select ---") {
	  alert("You did not select a preferred psychologist gender.\n\nPlease select an option from the 'Preferred psychologist gender' field.");
	  return false;
  } else {
	  return true;
  }
}

function validate_form(thisform) {
	with (thisform) {
		if (validate_name()==false  || validate_phone()==false || validate_email()==false || validate_pref_contact()==false || validate_child_name()==false || validate_relationship()==false || validate_pref_day()==false || validate_pref_gender()==false) {
			return false;
		}
	}
}