function checkEmail(val){
	var emailStr=val;
	
	var emailPat=/^(.+)@(.+)$/
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		var validChars="\[^\\s" + specialChars + "\]"
		var firstChars=validChars
		var quotedUser="(\"[^\"]*\")"
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		var atom="(" + firstChars + validChars + "*" + ")"
		var word="(" + atom + "|" + quotedUser + ")"
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
				alert("The email address you entered is not valid, please verify.")
			
				return false;
		}
		var user=matchArray[1]
		var domain=matchArray[2]
		
		// See if "user" is valid 
		if (user.match(userPat)==null) {
			// user is not valid
			alert("The email address you entered is not valid, please verify.")
			
			return false;
		}
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			// this is an IP address
				  for (var i=1;i<=4;i++) {
					if (IPArray[i]>255) {
						alert("The email address you entered is not valid, please verify.")
				
						return false;
					}
			}
		}
		
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
				alert("The email address you entered is not valid, please verify.")
			
			return false;
		}
		
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>4) {
		   // the address must end in a two letter or three letter word.
		   alert("Your email address must end in a valid domain extension.")
		
		   return false;
		}
		
		if (domArr[domArr.length-1].length<=3 && len<2) {
		   var errStr="The email address you entered is not valid, please verify."
		   alert(errStr)
			 
			  return false;
		}
		
		return true;
}
