//========================================================================
// Who	             When	   Why
//------------------------------------------------------------------------
// Tzuching Wang	5-8-03     Check email text fields' format 
//=========================================================================

function checkEmailAddressFormat(inputValue) {
	var isMac = (navigator.appVersion.indexOf('Mac') != -1);
	if (isMac) {
		 var s=inputValue

	// there must be >= 1 character before @, so we
    // start looking at character position 1 
    // (i.e. second character)
       var i = 1;
       var sLength = s.length;
	   
     // look for @
       while ((i < sLength) && (s.charAt(i) != "@")){ 
	     	i++
       }
   
       if ((i >= sLength) || (s.charAt(i) != "@")) {
			alert("The email address you have entered seems to have been formatted incorrectly.");
			return false;
		}
       else i += 2;
   
     // look for .
       while ((i < sLength) && (s.charAt(i) != ".")){ 
	   		i++
       }
   
     // there must be at least one character after the .
       if ((i >= sLength - 1) || (s.charAt(i) != ".")) {
			alert("The email address you have entered seems to have been formatted incorrectly.");	
			return false;
		}
       else return true;
	}
	else {
		var rExp = /^[\w-#!\'(\)]+(\.[\w-#!\'(\)]+)*@[\w-#!\'(\)]+(\.[\w-#!\'(\)]+)+$/
		if (rExp.test(inputValue))
			return true;
		else
			alert("The email address you have entered seems to have been formatted incorrectly.");
		return false;
	}
} // end function checkEmailAddressFormat

	
