<!--

// Checks if a string only contains whitespace
function empty(s) 
{
        for (var i = 0; i < s.length; i++) 
        {
                var c = s.charAt(i);
                if((c != " ") && (c != '\n') && (c != '\t')) return false;
        }
}

// Verifies form data. Checks that all required fields are complete and also checks the number ranges of numeric fields.
function verify(f) 
{
        var msg;
        var empties = "";
        var errors = "";

        for (var i = 0; i < f.length; i++) 
        {
                var e = f.elements[i];
                if (((e.type == "text") || (e.type == "textarea")) && !e.optional) 
                {

                        // check for empty fields
                        if((e.value == null) || (e.value == "") || empty(e.value)) 
                        {
                                empties += "\n" + e.name;
                                continue;
                        }

                        // check if numeric fields have numbers
                        if(e.numeric || (e.min != null) || (e.max != null)) 
                        {
                                var val = parseFloat(e.value);
                                if (isNaN(val) || ((e.min != null) && (val < e.min)) || ((e.max != null) && (val > e.max))) 
                                {
                                        errors += e.name + " must be a number";
                                        if(e.min != null) 
                                        {
                                                errors += " greater than " + e.min;
                                        }
                                        
                                        if(e.max != null && e.min != null) 
                                        {
                                                errors += " and less than " + e.max;
                                        } 
                                        else if (e.max != null) 
                                        {
                                                errors += " less than " + e.max;
                                        }
                                        errors += ".\n";
                                }
                        }
                }
        }

        if (!empties && !errors) return true;

        msg = "";
        
        if(empties) 
        {
                msg += "Please complete the following fields:\n" + empties + "\n";
                if(errors) {
                        msg += "\n";
                }
        }
        msg += errors;
        alert(msg);
        return false;
}

//-->
