function echeck( strng )
{
    // From http://developer.apple.com/internet/javascript/validation.html
    //
    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) {
           return "Please enter a valid email address";
    }

    // Again, we want to check to make sure that no forbidden characters have slipped in.
    // For email addresses, we're forbidding the following: ( ) < > [ ] , ; : \ / "
    //
    var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]]/
    if (strng.match(illegalChars)) {
       return "The email address contains illegal characters";
    }

    return "";
}

function checkMandatory( formobj, list )
{
    var missing = "";
    var names = list.split(",");

    for ( i=0; i < names.length; i++ )
    {
        var elname = names[i];
        var parts = elname.split(":");

        elname    = parts[0];
        var label;

        if ( parts.length > 1 )
        {
            label = parts[1];
        }
        else
        {
            label = elname;
        }

        var theval = formobj.elements[elname].value;

        theval = theval.replace(/ /g, "");

        if ( theval == "" )
        {
            if ( missing == "" )
            {
                missing = label;
            }
            else
            {
                missing += "\n" + label;
            }
        }
        else if ( elname.toUpperCase().indexOf("EMAIL") >= 0 )
        {
            res = echeck( theval );
            if ( res != "" )
            {
                missing += "\n" + label + " - " + res;
            }
        }
        else if ( elname.toUpperCase().indexOf("DATE") >= 0 )
        {
            res = validateDate( theval );
            if ( res != "" )
            {
                missing += "\n" + label + " - " + res;
            }
        }
    }

    if ( missing == "" )
    {
        return true;
    }
    else
    {
        alert("The following fields must be completed\n\n" + missing );
        return false;
    }
}

