function IsNumeric(strString)

   //  check for valid numeric strings	

   {

   var strValidChars = "0123456789";

   var strChar;

   var blnResult = true;



   if (strString.length == 0) return false;



   //  test strString consists of valid characters listed above

   for (i = 0; i < strString.length && blnResult == true; i++)

      {

      strChar = strString.charAt(i);

      if (strValidChars.indexOf(strChar) == -1)

         {

         blnResult = false;

         }

      }

   return blnResult;

   }
   
function checkEmail() {
	var email = document.getElementById('emailfrom');
	var filter = /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
	if (!filter.test(document.contact.emailfrom.value)) {
		return false;
	} else {
		return true;
	}
}

function formCheck(){
	var errmsg = "Please correct the following errors before submitting:\n";
	var valid = true;
	
	if ( document.contact.name.value == "" || document.contact.name.value == "Your Name")
        {
                errmsg += " > Please fill in the 'Your Name' box.\n";
                valid = false;
        }
		
	
		
	if (!IsNumeric(document.contact.phone.value))
		{
            errmsg += " > Phone numbers must be 10 digits and include area code if necessary.\n";
            valid = false;
		}
				
		if (!checkEmail())
		{
			errmsg += " > Please enter a valid email address.\n";
			valid = false;
		}
		
		if (!IsNumeric(document.contact.postcode.value))
		{
            errmsg += " > Please enter a valid postcode.\n";
            valid = false;
		}
	
	if (valid)
		{
			document.forms["contact"].submit();
		} else
		{
			alert(errmsg);
		}
}
