function promptWaiver( form ) {
    var msg = "If you have already printed the waiver form out to bring" + 
              " in with you, click 'OK' to finish the submission process.\n\n" +
              " Otherwise, please click 'Cancel' and print the waiver form" +
              " before submitting your information.";
    var answer = confirm( msg );
    if( answer == true ) {
        return checkWaiverForm( form );
    } else {
        return false;
    }
}

function promptWaiverKids( form ) {
    var msg = "If you have already printed the waiver form out to bring" + 
              " in with you, click 'OK' to finish the submission process.\n\n" +
              " Otherwise, please click 'Cancel' and print the waiver form" +
              " before submitting your information.";
    var answer = confirm( msg );
    if( answer == true ) {
        return checkKidWaiverForm( form );
    } else {
        return false;
    }
}

function checkWaiverForm( form ) {

    form.waiverName.required = true;
    form.waiverName.requiredError = "The name on the release was not provided.";
    form.waiverName.pattern = "alphanumeric";
    form.waiverName.patternError = "The name contains invalid characters.";

    form.waiverFirstName.required = true;
    form.waiverFirstName.requiredError = "The participant's first name was not provided.";
    form.waiverFirstName.pattern = "alphanumeric";
    form.waiverFirstName.patternError = "The participant's first name contains invalid characters.";

    form.waiverLastName.required = true;
    form.waiverLastName.requiredError = "The participant's last name was not provided.";
    form.waiverLastName.pattern = "alphanumeric";
    form.waiverLastName.patternError = "The participant's last name contains invalid characters.";

    form.waiverDOBMonth.required = true;
    form.waiverDOBMonth.requiredError = "The month field of the participant's date of birth was not provided.";
    form.waiverDOBMonth.pattern = "numeric";
    form.waiverDOBMonth.patternError = "The month field of the participant's date of birth contains invalid characters.";
    form.waiverDOBMonth.minlength = 1;
    form.waiverDOBMonth.minlengthError = "The month field of the participant's date of birth must be between 1 and 2 digits long.";
    form.waiverDOBMonth.maxlength = 2;
    form.waiverDOBMonth.maxlengthError = form.waiverDOBMonth.minlengthError;

    form.waiverDOBDay.required = true;
    form.waiverDOBDay.requiredError = "The day field of the participant's date of birth was not provided.";
    form.waiverDOBDay.pattern = "numeric";
    form.waiverDOBDay.patternError = "The day field of the participant's date of birth contains invalid characters.";
    form.waiverDOBDay.minlength = 1;
    form.waiverDOBDay.minlengthError = "The day field of the participant's date of birth must be between 1 and 2 digits long.";
    form.waiverDOBDay.maxlength = 2;
    form.waiverDOBDay.maxlengthError = form.waiverDOBDay.minlengthError;

    form.waiverDOBYear.required = true;
    form.waiverDOBYear.requiredError = "The year field of the participant's date of birth must be provided.";
    form.waiverDOBYear.pattern = "numeric";
    form.waiverDOBYear.patternError = "The year field of the participant's date of birth contains invalide characters.";
    form.waiverDOBYear.minlength = 4;
    form.waiverDOBYear.minlengthError = "The year field of the participant's date of birth must be 4 digits long.";
    form.waiverDOBYear.maxlength = 4;
    form.waiverDOBYear.maxlengthError = form.waiverDOBYear.minlengthError;

    form.waiverDLN.required = true;
    form.waiverDLN.requiredError = "The participant's driver's license number must be provided.";
    form.waiverDLN.pattern = "numeric";
    form.waiverDLN.patternError = "The participant's driver's license number contains invalid characters.";

    form.waiverAddress.required = true;
    form.waiverAddress.requiredError = "The participant's address must be provided.";

    form.waiverCity.required = true;
    form.waiverCity.requiredError = "The participant's city of residence must be provided.";

    form.waiverState.required = true;
    form.waiverState.requiredError = "The participant's state of residence must be provided.";
    form.waiverState.pattern = "alphabetic";
    form.waiverState.patternError = "The participant's state contains invalid characters.";
    form.waiverState.minlength = 2;
    form.waiverState.minlength = "The participant's state must be at least 2 characters long.";
    //form.waiverState.disallowEmptyValue = true;
    //form.waiverState.disallowEmptyValueError = "Please select the state in which the participant resides.";

    form.waiverZip.required = true;
    form.waiverZip.requiredError ="The participant's zipcode must be provided.";
    form.waiverZip.pattern = "zipcode";
    form.waiverZip.patternError = "The participant's zipcode is not valid.";

    form.waiverPhoneArea.required = true;
    form.waiverPhoneArea.requiredError = "The participant's phone number (area code) must be provided.";
    form.waiverPhonePrefix.required = true;
    form.waiverPhonePrefix.requiredError = "The participant's phone number (prefix) must be provided.";
    form.waiverPhoneSuffix.required = true;
    form.waiverPhoneSuffix.requiredError = "The participant's phone number (suffix) must be provided.";
    form.waiverPhoneArea.prefix = "waiverPhonePrefix";
    form.waiverPhoneArea.suffix = "waiverPhoneSuffix";
    form.waiverPhoneArea.pattern = "us phone number";
    form.waiverPhoneArea.patternError = "The participant's phone number is not valid.";

    form.waiverEmName.required = true;
    form.waiverEmName.requiredError = "The emergency contact name must be provided.";

    form.waiverEmPhoneArea.required = true;
    form.waiverEmPhoneArea.requiredError = "The emergency phone (area code) must be provided.";
    form.waiverEmPhonePrefix.required = true;
    form.waiverEmPhonePrefix.requiredError = "The emergency phone (prefix) must be provided.";
    form.waiverEmPhoneSuffix.required = true;
    form.waiverEmPhoneSuffix.requiredError = "The emergency phone (suffix) must be provided.";
    form.waiverEmPhoneArea.prefix = "waiverEmPhonePrefix";
    form.waiverEmPhoneArea.suffix = "waiverEmPhoneSuffix";
    form.waiverEmPhoneArea.pattern = "us phone number";
    form.waiverEmPhoneArea.patternError = "The emergency phone number is not valid.";

    //form.waiverEmail.required = false;
    //form.waiverEmail.requiredError = "";
    //form.waiverEmail.pattern = "email";
    //form.waiverEmail.patternError = "The participant's email is not valid.";

    form.waiverPrintName.required = true;
    form.waiverPrintName.requiredError = "The printed name field must be provided.";

    form.waiverMonth.required = true;
    form.waiverMonth.requiredError = "The sign month field was not provided.";
    form.waiverMonth.pattern = "numeric";
    form.waiverMonth.patternError = "The sign month field contains invalid characters.";
    form.waiverMonth.minlength = 1;
    form.waiverMonth.minlengthError = "The sign month field must be between 1 and 2 digits long.";
    form.waiverMonth.maxlength = 2;
    form.waiverMonth.maxlengthError = form.waiverMonth.minlengthError;
 
    form.waiverDay.required = true;
    form.waiverDay.requiredError = "The sign day field was not provided.";
    form.waiverDay.pattern = "numeric";
    form.waiverDay.patternError = "The sign day field contains invalid characters.";
    form.waiverDay.minlength = 1;
    form.waiverDay.minlengthError = "The sign day field must be between 1 and 2 digits long.";
    form.waiverDay.maxlength = 2;
    form.waiverDay.maxlengthError = form.waiverDay.minlengthError;
 
    form.waiverYear.required = true;
    form.waiverYear.requiredError = "The sign year field was not provided.";
    form.waiverYear.pattern = "numeric";
    form.waiverYear.patternError = "The sign year field contains invalide characters.";
    form.waiverYear.minlength = 4;
    form.waiverYear.minlengthError = "The sign year field must be 4 digits long.";
    form.waiverYear.maxlength = 4;
    form.waiverYear.maxlengthError = form.waiverYear.minlengthError;


    var errors = getFormErrors( form );
    if( errors.length > 0 ) {
        var errorMessage = "The form was not submitted due to the following " +
                " problem" + ((errors.length > 1) ? "s" : "" ) + ":\n\n";
        for( var errorIndex = 0; errorIndex < errors.length; errorIndex++ ) {
            errorMessage += "* " + errors[errorIndex] + "\n";
        }
        errorMessage += "\nPlease fix " + 
                        ((errors.length > 1) ? "these" : "this" ) + " problem" +
                        ((errors.length > 1) ? "s" : "" ) + " and resubmit " +
                        "the form.";
        alert( errorMessage );
        return false;
    }

    // all is well...
    return true;
} // end checkWaiverForm()
