function SubmitForm(theForm)
{
//To require javascript checks, you should have hidden field name=jsChecks value=No in HTML form and
//check $_POST['jsChecks'="Yes" in form processing PHP and uncomment line below...

//theForm.jsChecks.value="Yes";

//now check for required fields and move cursor there in form if missing

if(theForm.Name.value == "")
	{
		alert("Please enter your name.");
		theForm.Name.focus();
return (false);
	}
	else if(theForm.Company.value == "")
	{
		alert("Please enter your Company.");
		theForm.Company.focus();
return (false);
	}
	else if(theForm.Email.value == "")
	{
		alert("Please enter your email address.");
		theForm.Email.focus();
return (false);
	}
	else if(theForm.Phone.value == "")
	{
		alert("Please enter your phone number.");
		theForm.Phone.focus();
return (false);
	}
//check email address
var check=echeck(theForm.Email.value);
if (check== false)
	{
		theForm.Email.focus();
	return (false);
	}		
//check phone number if exists
var check=CheckPhoneNumber(theForm.Phone.value);
if (check== false)
	{
		theForm.Phone.focus();
	return (false);
	}		
		
}


function CheckPhoneNumber(TheNumber) {
	var valid = 1
	var GoodChars = "0123456789()-+ "
	var i = 0
	//if (TheNumber=="") {
		// Return false if number is empty
		//valid = 0
	//}
	for (i =0; i <= TheNumber.length -1; i++) {
		if (GoodChars.indexOf(TheNumber.charAt(i)) == -1) {
 alert(TheNumber.charAt(i) + " is not valid in a phone number.")
			valid = 0
			return valid
} // End if statement
	} // End for loop
	return valid
}

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("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("E-mail not in correct format.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("E-mail not in correct format.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("E-mail not in correct format.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("E-mail not in correct format.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("E-mail not in correct format.")
		    return false
		 }

 		 return true					
 }


