﻿function submitChk(xform)
{	
	if (xform.name.value == '')
	{
		alert("ERROR - Please enter your name.");
		xform.name.focus();
		return false;
	}
	
	if (xform.company.value == '')
	{
		alert("ERROR - Please enter your company.");
		xform.company.focus();
		return false;
	}
	
	if (xform.email.value == '')
	{
		alert("ERROR - Please enter your email address.");
		xform.email.focus();
		return false;
	}
	
	if (EmailValidate(xform.email) == false) {return false;}
	
	if (xform.phone.value == '')
	{
		alert("ERROR - Please enter your phone number.");
		xform.phone.focus();
		return false;
	}
	
	alert("Thank you!! We will be in touch shortly.");
}

function EmailValidate(txtCtrl)	
{
	txtCtrl.value=txtCtrl.value.replace(/ \*/g,"");

	var str = txtCtrl.value;	

	var at="@"

	var dot="."

	var lat=str.indexOf(at)

	var lstr=str.length

	var ldot=str.indexOf(dot)

	if (str.indexOf(at)==-1)
	{

		alert("ERROR - Invalid email address. Please re-enter.");

		txtCtrl.focus();

		txtCtrl.select();

		return false

	}	

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
	{

		alert("ERROR - Invalid email address. Please re-enter.");

		txtCtrl.focus();

		txtCtrl.select();

		return false

	}	

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
	{

		alert("ERROR - Invalid email address. Please re-enter.");

		txtCtrl.focus();

		txtCtrl.select();

		return false

	}	

	if (str.indexOf(at,(lat+1))!=-1)
	{

		alert("ERROR - Invalid email address. Please re-enter.");

		txtCtrl.focus();

		txtCtrl.select();

		return false

	}	

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
	{

		alert("ERROR - Invalid email address. Please re-enter.");

		txtCtrl.focus();

		txtCtrl.select();

		return false

	}	

	if (str.indexOf(dot,(lat+2))==-1)
	{

		alert("ERROR - Invalid email address. Please re-enter.");

		txtCtrl.focus();

		txtCtrl.select();

		return false

	}	

	if (str.indexOf(" ")!=-1)
	{

		alert("ERROR - Invalid email address. Please re-enter.");

		txtCtrl.focus();

		txtCtrl.select();

		return false

	}

	return true

}