function setFocus()
{
document.getElementById("nameField").focus();
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please check your e-mail address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please check your e-mail address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please check your e-mail address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please check your e-mail address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please check your e-mail address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please check your e-mail address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please check your e-mail address")
		    return false
		 }

 		 return true					
	}

function checkFields(){
if (document.getElementById("nameField").value == ""){
alert("Please enter 'Your Name'");
document.getElementById("nameField").focus();
return false;
}
if (document.getElementById("phoneNum").value == ""){
alert("Please enter your 'Phone Number'");
document.getElementById("phoneNum").focus();
return false;
}
	var email1ID=document.contactForm.email1
   // checks the whole e-mail address string
	if ((email1ID.value==null)||(email1ID.value=="")){
		alert("Please enter your e-mail address")
		email1ID.focus()
		return false
	}
   // sets the focus on the e-mail1 address field if values are not correct
	if (echeck(email1ID.value)==false){
		email1ID.focus()
		return false
	}
	var email2ID=document.contactForm.email2
   // checks the second whole e-mail address string
	if ((email2ID.value==null)||(email2ID.value=="")){
		alert("Please confirm your e-mail address")
		email2ID.focus()
		return false
	}
   // sets the focus on the e-mail2 address field if values are not correct
	if (echeck(email2ID.value)==false){
		email2ID.focus()
		return false
	}
  var confirmEmail
// checks that both e-mails are the same and sets the focus on the e-mail2 address field
  if ((document.getElementById("email1").value) != (document.getElementById("email2").value)) {
    alert("Your 'E-mails' are not the same, please check")
    document.getElementById("email2").focus();
    return false
}
if (document.getElementById("message").value == ""){
alert("Please type your 'Message'");
document.getElementById("message").focus();
return false;
}
return true;
}




