function mail_validate(e_mail){
  var msg="";
	  if(e_mail.value.search(/[A-Za-z0-9-_.]+\@[A-Za-z0-9-_.]+/)==-1){
         msg+="\nE-mail address should be in the form \"someone@domain\".";
		} else {
			if (e_mail.value.match(/[A-Za-z0-9-_.]+\@[A-Za-z0-9-_.]+/).toString().length!=e_mail.value.length) 
				msg+="\nE-mail address should contain only numbers, digits, and (-), (_) or (.).";
    }
    if(e_mail.value.search(/[.-_]+/)==0||((e_mail.value.lastIndexOf(".")==e_mail.value.length-1||e_mail.value.lastIndexOf("-")==e_mail.value.length-1||e_mail.value.lastIndexOf("_")==e_mail.value.length-1)&&e_mail.value!="")){
         msg+="\nE-mail address cannot start or end with a hyphen, underscore or period.";
    }
    if(e_mail.value.search(/[.-_]+[._-]+/)>-1){
         msg+="\nE-mail address can never have adjacent hyphens, underscores, or periods.";
    }
		if(e_mail.value.lastIndexOf(".")<e_mail.value.lastIndexOf("@")){
  		msg+="\nE-mail address must end with suffix like .com, .org, or .edu";
  	}
	if(msg!=""){
		alert("The following errors need to be corrected before continuing:\n"+msg);
		e_mail.focus();
		return false;
	} else {
		return true;
	}
}
