//***BEGIN - FUNCTION check_form is used in forcrafts/email.asp****

function email_form_submit()
{
	if(document.form1.fname.value==""){
		alert("First Name is a required field.");
		document.form1.fname.focus();
		return false;
	}//end if
	
	if(document.form1.lname.value==""){
		alert("Last Name is a required field.");
		document.form1.lname.focus();
		return false;
	}//end if
	
	if(document.form1.email.value==""){
		alert("Email Address is a required field.");
		document.form1.email.focus();
		return false;
	}//end if
	
	if (!echeck(document.form1.email.value)) 
  	{
		alert("You have entered an invalid Email Address. Please enter your Email Address in the form: yourname@yourdomain.com ");
		document.form1.email.focus();
		return false;
	}//end if
	
	if (document.form1.age != null) {
		if(document.form1.age.checked==false){
			alert("You need to confirm you are over 19 years old.");
			document.form1.age.focus();
			return false;
		}//end if
	}
	
	//if (document.form1.age.checked == false){
	//	return false;
	//}//end if
	
	return true;
}

function echeck(str) {
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
/*
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true		*/			
	}

