﻿		function  isStandardDomain(domainIn)  
		{
			var  isStandardReturn = false;
			var  last4chars  =  domainIn.substring(domainIn.length-4, domainIn.length);
			var  last3chars  =  domainIn.substring(domainIn.length-3, domainIn.length);
			last4chars = last4chars.toUpperCase();
			var  countryCodePattern = /\.[a-zA-Z][a-zA-Z]/;

			if      (last4chars == ".COM") isStandardReturn = true;
			else if (last4chars == ".EDU") isStandardReturn = true;
			else if (last4chars == ".GOV") isStandardReturn = true;
			else if (last4chars == ".NET") isStandardReturn = true;
			else if (last4chars == ".MIL") isStandardReturn = true;
			else if (last4chars == ".BIZ") isStandardReturn = true;
			else if (last4chars == ".ALT") isStandardReturn = true;
			else if (last4chars == ".INT") isStandardReturn = true;
			else if (last4chars == ".REC") isStandardReturn = true;
			else if (last4chars == "MISC") isStandardReturn = true;
			else if (last4chars == "AERO") isStandardReturn = true;
			else if (last4chars == "COOP") isStandardReturn = true;
			else if (last4chars == "INFO") isStandardReturn = true;
			else if (last4chars == "NAME") isStandardReturn = true;
			else if (last4chars == ".PRO") isStandardReturn = true;
			else if (last4chars == "SEUM") isStandardReturn = true;
			else if (last4chars == ".ORG") isStandardReturn = true;
		
			else if (last3chars.search(countryCodePattern) !=  -1)
				isStandardReturn = true;
			
			return  isStandardReturn;
			
		}
			
						
		function  InvalidEmail( emailIn )  
		{
			var  numAtChars; // Number of '@' 
			var  userNameIn; // The part of input address before the '@'
			var  domainNameIn; 	// The part of input address after the '@' 
			var  addressFields = new Array(); // Holds the fields of the entered address, delimited by '@' chars.

			addressFields = emailIn.split('@');
			numAtChars = addressFields.length - 1;

			if (emailIn == "")
				return (1)
			else if (numAtChars == 0)
				return (1)
			else if (numAtChars > 1)
				return (1)
			else if (addressFields[0] == "")
				return (1)
			else if (addressFields[1] == "")
				return (1)
			else
				{
				userNameIn   = addressFields[0];
				domainNameIn = addressFields[1];
		
				if (userNameIn.indexOf(" ") != -1)
					return (1)
				else if ( domainNameIn.indexOf(" ") != -1 )
					return (1)
				else if (isStandardDomain(domainNameIn) == false)
					return (1)
				}
		}


