<!--
//======================================================================
function isEmpty(s)
//======================================================================
{   return ((s == null) || (s.length == 0))
}
//======================================================================
function isWhitespace (s)
//======================================================================
// Search through string's characters one by one
// until we find a non-whitespace character.
// When we do, return false; if we don't, return true.
//======================================================================
{   var i;
    var whitespace = " \t\n\r";
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++)
    {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    // All characters are whitespace.
    return true;
}
//======================================================================
function isEmail (s)
//======================================================================
// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
// If emptyOK is false (or any value other than true), 
//      the function will return false if s is empty.
// If emptyOK is true, the function will return true if s is empty.
//======================================================================
{   if (isEmpty(s)) 
       if (isEmail.arguments.length == 1) return false;
       else return (isEmail.arguments[1] == true);
   
    // is s whitespace?
    if (isWhitespace(s)) return false;

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(s))) 
       return false;
    else
       return true;
}
//======================================================================
// -->
