
function doVerify() {
	//alert(document.frmContact.frmName.value);
	if (document.frmContact.frmName.value.length == 0) {
		alert("Please enter your name.");
		document.frmContact.frmName.focus(); 
		return false;
	}


	var myTelNo = document.frmContact.frmPhone.value;
	// If invalid number, report back error
	if (!checkUKTelephone (myTelNo)) {
		alert (telNumberErrors[telNumberErrorNo]);
		document.frmContact.frmPhone.focus(); 
		return false;
	}
	// Otherwise redisplay telephone number on form in corrected format
	else {
		document.frmContact.frmPhone.value =  checkUKTelephone (myTelNo);
	}

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.frmContact.frmEmail.value)){
	}
	else
	{
		alert("Invalid E-mail Address! Please re-enter.")
		document.frmContact.frmEmail.focus(); 
		return false;
	}
	
	return true;

}


function checkUKTelephone (telephoneNumber) {

  var telnum;
  // Convert into a string and check that we were provided with a number
  telnum = telephoneNumber + " ";
  if (telnum.length == 1)  {
     telNumberErrorNo = 1;
     return false;
  }
  telnum.length = telnum.length - 1;
  
  // Don't allow country codes to be included (assumes a leading "+")
  exp = /^(\+)[\s]*(.*)$/;
  if (exp.test(telnum) == true) {
     telNumberErrorNo = 2;
     return false;
  }
  
  // Remove spaces from the telephone number to help validation
  while (telnum.indexOf(" ")!= -1)  {
    telnum = telnum.slice (0,telnum.indexOf(" ")) + telnum.slice (telnum.indexOf(" ")+1)
  }
  
  // Remove hyphens from the telephone number to help validation
  while (telnum.indexOf("-")!= -1)  {
    telnum = telnum.slice (0,telnum.indexOf("-")) + telnum.slice (telnum.indexOf("-")+1)
  }  
  
  // Now check that all the characters are digits
  exp = /^[0-9]{10,11}$/
  if (exp.test(telnum) != true) {
     telNumberErrorNo = 3;
     return false;
  }
  
  // Now check that the first digit is 0
  exp = /^0[0-9]{9,10}$/
  if (exp.test(telnum) != true) {
     telNumberErrorNo = 4;
     return false;
  }
  
  // Now check that the telephone number is appropriate.
  exp = /^(01|02|05|070|077|078|079)[0-9]+$/;
  if (exp.test(telnum) != true) {
     telNumberErrorNo = 5;
     return false;
  }
  
  // Seems to be valid - return the stripped telehone number
  
  return telnum;
}
var telNumberErrorNo = 0;
telNumberErrors = new Array (0);
telNumberErrors[0] = "Valid UK telephone number";
telNumberErrors[1] = "Telephone number not provided";
telNumberErrors[2] = "UK telephone number without the country code, please";
telNumberErrors[3] = "UK telephone numbers should contain 10 or 11 digits";
telNumberErrors[4] = "The telephone number should start with a 0";
telNumberErrors[5] = "The telephone number is either invalid or inappropriate";