// *******************************************************************************
// **********  Call all contact form checking functions  ***************
// *******************************************************************************

function checkForm() {
	var myName = document.getElementById('name').value;
	var myEmail = document.getElementById('email').value;
	var myTelephone = document.getElementById('tel').value;
	var myMessage = document.getElementById('message').value;

	if (checkEmpty(myName))
	{
		alert ("You did not include your name");
		document.getElementById('name').focus();
		return false;
	}	
			
	if ((checkEmpty(myEmail)) && (checkEmpty(myTelephone)))
	{ 
		alert ("Please include a telephone number or email address so we can contact you.");
		document.getElementById('email').focus();
		return false;			
	}
	var emailChecked = false;

	if ((!checkEmpty(myEmail)) && (!emailChecked))
	{ 
			emailChecked == false;
	  	if (myEmail.indexOf("/") > -1) {
    	window.alert("E-mail address has invalid character: /");
   	 	document.getElementById('email').focus();
			return false;			
   	 }
  	if (myEmail.indexOf(":") > -1) {
     	window.alert("E-mail address has invalid character: :");
   	 	document.getElementById('email').focus();
			return false;			
    	}
  	if (myEmail.indexOf(",") > -1) {
     	window.alert("E-mail address has invalid character: ,");
   	  document.getElementById('email').focus();
			return false;			
    	}
  	if (myEmail.indexOf(";") > -1) {
     	window.alert("E-mail address has invalid character: ;");
      document.getElementById('email').focus();
		return false;			
    	}
  	if (myEmail.indexOf("@") < 0) {
     	window.alert("E-mail address is missing @");
   	 	document.getElementById('email').focus();
			return false;			
    	}
  	if (myEmail.indexOf("\.") < 0) {
     	window.alert("E-mail address is missing .");
   	 	document.getElementById('email').focus();
			return false;			
    	}
	}

	
	if (checkEmpty(myMessage))
	{
		alert ("You did not include a message");
		document.getElementById('message').focus();
  	return false;
	}
	

	return true;
}

// *******************************************************************************
// ******************************  Check for empty fields ************************
// *******************************************************************************

function checkEmpty(fieldtotest) {
	 var formOK = false;
     if (fieldtotest == "") {
       formOK = true;
     }
     return formOK;
   }