function TheFormCheck() 
{	
	
	if (document.form.realname.value=="") 
	{
		alert("Please enter your name.");
		return false;	
	}
		
	if (document.form.email.value=="") 
	{
		alert("Please enter your email address.");
		return false;	
	}
	
	if (document.form.confirmemail.value=="") 
	{
		alert("Please confirm your email address.");
		return false;	
	}
	
	if (document.form.confirmemail.value!=document.form.email.value) 
	{
		alert("Your email addresses do not match.");
		return false;	
	}
	
	
	
	if(ValidateForm() == false)
	{
		return false;	
	}
	
	return true;
	//alert(ValidateForm());
	
}


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("Invalid Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid Address")
		    return false
		 }

		 
 		 return true					
	}

function ValidateForm(){
	
	var emailID=document.form.email
	var emailID2=document.form.confirmemail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	
	if ((emailID2.value==null)||(emailID2.value=="")){
		alert("Please enter your email address.")
		emailID2.focus()
		return false
	}
	if (echeck(emailID2.value)==false){
		emailID2.value=""
		emailID2.focus()
		return false
	}
	return true
 }
