/****global document, jQuery, alert */

jQuery(document).ready(function () {    
    jQuery(".griffinforms-empty-field-error").hide();
    jQuery(".griffinforms-field-length-error").hide();
    
    jQuery("#griffinforms-name-inputtext").blur(function () {
        var fieldValue = jQuery(this).val();
        fieldValue = jQuery.trim(fieldValue);
        if (fieldValue === '') {
            jQuery(".griffinforms-empty-field-error").show();
        } else {
            jQuery(".griffinforms-empty-field-error").hide();
        }
    });
    
    jQuery(".griffinforms-inputdate").datepicker({
        changeMonth: true,
        changeYear: true,
        yearRange: "1900:2100",
        showButtonPanel: true,
        prevText: "←",
        nextText: "→",
        dateFormat: "mm/dd/yy"
    });

    // Handle dismiss button clicks for gf notices
    jQuery(document).on('click', '.gf-dismiss-notice', function () {
        jQuery(this).closest('.gf-is-dismissible').hide();
    });

});
