// jQuery
jQuery(document).ready(function() {
    // Function to toggle the visibility of reCAPTCHA settings
    function toggleRecaptchaSettings() {
        if (jQuery('#griffinforms-settings-antispam-enablerecaptcha').is(':checked')) {
            jQuery('#griffinforms-settings-antispam-recaptcha_site_key').prop('disabled', false); 
            jQuery('#griffinforms-settings-antispam-recaptcha_secret_key').prop('disabled', false); 
            jQuery('#griffinforms-settings-antispam-recaptcha_version').prop('disabled', false); 
        } else {
            jQuery('#griffinforms-settings-antispam-recaptcha_site_key').prop('disabled', true); 
            jQuery('#griffinforms-settings-antispam-recaptcha_site_key').val(''); 
            jQuery('#griffinforms-settings-antispam-recaptcha_secret_key').prop('disabled', true); 
            jQuery('#griffinforms-settings-antispam-recaptcha_secret_key').val(''); 
            jQuery('#griffinforms-settings-antispam-recaptcha_version').prop('disabled', true); 
        }
    }

    // Initial check on page load
    toggleRecaptchaSettings();

    // Event listener for checkbox state change
    jQuery('#griffinforms-settings-antispam-enablerecaptcha').on('change', function() {
        toggleRecaptchaSettings();
    });
});