// JavaScript Document
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		
		//no @ symbol
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address (1)")
		   return false
		}
		//no @ - starts with an @ - ends with an @
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address (2)")
		   return false
		}
		//no dot - starts with a dot, ends with a dot
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID (3)")
		    return false
		}
		//More than one @ symbol
		if (str.indexOf(at,(lat+1))!=-1){
		   alert("Invalid E-mail ID (4)")
		   return false
		}
		//There is a dot just before or after the @ symbol
		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Invalid E-mail ID (5)")
		   return false
		}
		//No dot after the @ symbol
		if (str.indexOf(dot,(lat+2))==-1){
		   alert("Invalid E-mail ID (6)")
		   return false
		}
		//No spaces allowed
		if (str.indexOf(" ")!=-1){
		   alert("Invalid E-mail ID (7)")
		   return false
		}
		// no percent signs allowed
		if (str.indexOf("%")!=-1){
		   alert("Invalid E-mail Address (8)")
		   return false
		}
		// No colons allowed
		if (str.indexOf(":")!=-1){
		   alert("Invalid E-mail Address (9)")
		   return false
		}
		// No less than signs allowed
		if (str.indexOf("<")!=-1){
		   alert("Invalid E-mail Address (10)")
		   return false
		}
 	  return true					
  }

function ValidateEmail(){
	var emailID=document.email.email_address;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email Address")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		alert("That email address is not valid. Please Enter another Email Address")
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
