/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
var radiochecked;

 function checkNo()
  {
  radiochecked ="NO";
  }
function checkYes()
  {
  radiochecked ="YES";
  }

function ValidateForm(){
	var dot=".";
	var emailID=document.getElementById('EMAIL');
	if (document.getElementById('FIRSTNAME').value == "")
		{
			alert("Please enter your first name.");
			return false;
		}
	if (document.getElementById('LASTNAME').value == "")
		{
			alert("Please enter your last name.");
		    return false;
		}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email.");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
		if (radiochecked != "YES")
		{
			if (radiochecked != "NO")
			{
				alert("Please choose if you would like to receive more information about our products.");
				return false;
			}
		}
		return true;
 }

function echeck(str) {
	
		var dot=".";
		var at="@";
		var lat=str.indexOf(at);
		var lstr=str.length;
		var ldot=str.indexOf(dot);
		if (str.indexOf(at)==-1){
		   alert("The email address is incorrect.  Please re-enter your email.");
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("The email address is incorrect.  Please re-enter your email.");
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("The email address is incorrect.  Please re-enter your email.");
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("The email address is incorrect.  Please re-enter your email.");
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("The email address is incorrect.  Please re-enter your email.");
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("The email address is incorrect.  Please re-enter your email.");
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("The email address is incorrect.  Please re-enter your email.");
		    return false
		 }
		return true;
	}
	
	
