function validEmail(obj, blankOK)
{ 
// Method Name: validEmail                                                             
// Description: Check for valid email addresses.  It alerts user of specific error.    
// Syntax: validEmail(document.<formname>.emailname, 'Y')                              
// Inputs: obj     = email form object (obj)                                           
//		   blankOK = Y or N string   Y is blanks are OK, N is they are not		       
// Returns: true = email format is OK                                                  
//          false = email for at is bad                                            
  var errmsg ="";
  var str = obj.value;
  var locAt = str.indexOf('@');
  var locDot = str.indexOf('.');
  if ( str.isNull() && blankOK == 'Y') 
  	  return true; 
  if ( str.isNull() && blankOK == 'N' ) 
      errmsg = "The email address must NOT be left blank.";
  else if (locAt == 0)
      errmsg = "The email address cannot begin with an '@' sign.";
  else if (locAt == -1)
      errmsg = "The email address must have an '@' sign inside it.";
  else if (locDot == -1)
      errmsg = "The email address must have an '.' inside it.";
  else if (str.length < 5)   //Must at least be 5 digits long (i.e x@x.x)
      errmsg = "The email address is not well formatted.";
  else if (str.substring(locAt,str.length).indexOf('.') == -1) // check for '.' after the '@'
	  errmsg = "The  email address must have '.' after the '@' sign."
  else if (str.indexOf('@yourcompany.com') != -1)
      errmsg = "The email address cannot have @yourcompany.com in it.";
  else if (str.charAt(str.length-1) == '.' || str.charAt(0) == '.') 
      errmsg = "The email address cannot begin or end with a '.'";
  else if ( (locDot+1 == locAt) || (locDot-1 == locAt) )
      errmsg = "The email address cannot have a '.' next to a '@'.";
  else if (str.indexOf('@',locAt+1) != -1)
      errmsg = "The email address cannot have 2 or more'@' signs.";
  else if (str.indexOf(' ') != -1)
      errmsg = "The email address cannot have spaces.";
// -- allow single quotes for o'conner and such. oh well. (8/10/01 MRG)
//else if (str.indexOf("'") != -1)
//      errmsg = "The email field cannot have Quotes (').";
  else if (str.indexOf('"') != -1)
      errmsg = 'The email address cannot have Double Quotes (").';
  else if (str.indexOf(',') != -1)
      errmsg = "The email address cannot have Commas (,).";
  else if (str.indexOf("|") != -1 || str.indexOf("<") != -1 || str.indexOf(">") != -1 ||
   		   str.indexOf("{") != -1 || str.indexOf("}") != -1 || str.indexOf("[") != -1 ||
  		   str.indexOf("]") != -1 || str.indexOf("(") != -1 || str.indexOf(")") != -1 ||
  		   str.indexOf("^") != -1 || str.indexOf("%") != -1 || 
   		   str.indexOf("~") != -1 || str.indexOf("?") != -1 || str.indexOf(":") != -1 ||
		   str.indexOf("\\") != -1|| str.indexOf("`") != -1 ||
   		   str.indexOf("#") != -1 || str.indexOf("*") != -1 || str.indexOf("&") != -1 ||		   
   		   str.indexOf(";") != -1 || str.indexOf("$") != -1 )
   	  errmsg = "The email address cannot have unusual punctuation characters .";
  else
  	  errmsg = "";
	  
  if (errmsg != "")  //Gives Alert msg and returns false
  {
  	  alert(errmsg);
	  obj.focus();
  	  obj.select();
	  return false;
  }	  

  return true;
}

