// JScript source code

function ValidateForm()
{
    var nm, errors = '', args = ValidateForm.arguments;
    var argPrefix='', isNullable=false;

    
    for (i=0; i<(args.length); i+=1) 
    { 
        nm = args[i];
        val = document.getElementById(nm);
        
        try
        {
            var argPrefix = nm.substring(0,5);
            if(argPrefix == 'null_')
            {
                isNullable = true;
                nm = nm.substring(5,nm.length);
            }
        }
        catch(e)
        {
            alert('error on '+nm);
        }
        
        
        if(val == null)
        {
            if(!isNullable)
                errors += nm+' is required.\n'; 
        }
        else if(val.value == "null" || val.value == "")
        {
            errors += nm+' is required.\n'; 
        }
    }

    if (errors) 
        alert('The following error(s) occurred:\n\n'+errors);

    return errors == '';
    
}

function ValidateEmail()
{
    var filter=/^.+@.+\..{2,3}$/
    var nm, errors = '', args = ValidateEmail.arguments;

    for (i=0; i<(args.length); i+=1) 
    { 
        nm = args[i];
        val = document.getElementById(nm);   
        
        if (val == null)
            errors += 'Field '+nm+' not found.\n'; 
        if (!filter.test(val.value))
            errors += val.value+' is not a valid email address.\n'; 
    }

    if (errors) 
        alert('The following error(s) occurred:\n\n'+errors);

    return errors == '';
}




