/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

function echeck(theform) {

		var at="@"
		var dot="."
		var lat=theform.indexOf(at)
		var lstr=theform.length
		var ldot=theform.indexOf(dot)
		if (theform.indexOf(at)==-1){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (theform.indexOf(at)==-1 || theform.indexOf(at)==0 || theform.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (theform.indexOf(dot)==-1 || theform.indexOf(dot)==0 || theform.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (theform.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (theform.substring(lat-1,lat)==dot || theform.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (theform.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (theform.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

/* function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)


 		 return true					
	}*/

function ValidateForm(theform) { 
	if ((theform.email.value==null)||(theform.email.value=="")){
		alert("Please enter your e-mail address")
		theform.email.focus()
		return false
	}
	if (echeck(theform.email.value)==false){
		alert("Please enter a valid e-mail address")
		theform.email.focus()
		return false
	}
	return true
}