<!-- <![CDATA[
xponsor.validator = {
  isValidEmail: function() {
    // These comments use the following terms from RFC2822:
    // local-part, domain, domain-literal and dot-atom.
    // Does the address contain a local-part followed an @ followed by a domain?
    // Note the use of lastIndexOf to find the last @ in the address
    // since a valid email address may have a quoted @ in the local-part.
    // Does the domain name have at least two parts, i.e. at least one dot,
    // after the @? If not, is it a domain-literal?
    // This will accept some invalid email addresses
    // BUT it doesn't reject valid ones.

    if (arguments.length == 0) { return false; }
    var str = arguments[0];
    var atSym = str.lastIndexOf('@');
    if (atSym < 1) { return false; }
    if (atSym == str.length - 1) { return false; }
    if (atSym > 64) { return false; }
    if (str.length - atSym > 255) { return false; }

    var lastDot = str.lastIndexOf('.');

    if (lastDot > atSym + 1 && lastDot < str.length - 1) { return true; }

    if (str.charAt(atSym + 1) == '[' &&  str.charAt(str.length - 1) == ']') { return true; }
    return false;
  }
};
// ]]> -->
