
var emailAddressCheckFailed=false;
	
function emailAddressCheckBlur(inEmAddress) {
	if (emailAddressCheckFailed) {
		inEmAddress.focus();
	}
	emailAddressCheckFailed=false;
}
	
	
	

function emailAddressCheck(inEmailField) {
	var CEFColor="#FFCC66";
	var inEmailv=new String(inEmailField.value);
	var whereAtSign=inEmailv.indexOf("@");
	var whereAtSignBwk=inEmailv.lastIndexOf("@");
	inEmailField.style.backgroundColor="#FFFFFF";
	if (inEmailv == "") {
		inEmailField.style.backgroundColor="#FFFFFF";
	} else if (inEmailv.indexOf(" ") != -1) {			// Email address has spaces in it
		emailAddressCheckFailed=true;
		inEmailField.style.backgroundColor=CEFColor;
		alert("\"" + inEmailv + "\" is not a valid e-mail address.\nPlease input an e-mail address that does not contain a space in it.\n\nExample:  webmaster@up.com");
		inEmailField.focus();		
		return false;
	} else if ((whereAtSign != -1) && (whereAtSign == whereAtSignBwk)){		// If only one @ symbol
		var EmailSplit=inEmailv.substring((whereAtSign + 1));
		if (EmailSplit.toUpperCase() == "UP") {			// did they only do a xxxx@up email address
			emailAddressCheckFailed=false;
			inEmailField.value=	inEmailField.value + ".com";
		} else if (EmailSplit.indexOf(".") == -1) {		// has no .xxx extension (ex. xxxx@xxx.com)
			emailAddressCheckFailed=true;
			inEmailField.style.backgroundColor=CEFColor;
			alert("\"" + inEmailv + "\" is not a valid e-mail address.\nPlease input an e-mail address that contains a \".\" extension (ex. .com , .net , .org , etc) after the \"@\" symbol.\n\nExample:  webmaster@up.com");
			inEmailField.focus();
			return false;
		} else {								// is a valid e-mail address
			emailAddressCheckFailed=false;
		}
	} else if (whereAtSign != whereAtSignBwk) {		// Multiple @ symbols
		var EmailSplit=inEmailv.substring((whereAtSignBwk + 1));
		if (EmailSplit.toUpperCase() == "INTERNET") {		// The Multiple @ is because it contains a @INTERNET at the end
			inEmailField.value=inEmailv.substring(0,whereAtSignBwk);
			emailAddressCheck(inEmailField);
		} else {								
			emailAddressCheckFailed=true;
			inEmailField.style.backgroundColor=CEFColor;
			alert("\"" + inEmailv + "\" is not a valid e-mail address.\nPlease input an e-mail address that contains only one \"@\" symbol.\n\nExample:  webmaster@up.com");
			inEmailField.focus();		
			return false;
		}
	} else {			// No @ symbols
		emailAddressCheckFailed=true;
		inEmailField.style.backgroundColor=CEFColor;
		alert("\"" + inEmailv + "\" is not a valid e-mail address.\nPlease input an e-mail address that contains a \"@\" symbol.\n\nExample:  webmaster@up.com");
		inEmailField.focus();
		return false;
	}
	return true;
}


