
jQuery(document).bind("gform_load_field_settings", function (event, field, form) {
	fieldSettings.apbgf_appointment_calendar += '.enable_enhanced_ui_setting, .label_setting, .error_message_setting, .label_placement_setting, .admin_label_setting, .size_setting, .css_class_setting, .apbgf_categories_setting, .apbgf_location_setting, .apbgf_service_setting, .apbgf_staff_setting, .rules_setting';

	var firstLocationId = apbgf_admin_data.first_location_id;

	if (field.type === 'apbgf_appointment_calendar') {
		jQuery('.apbgf_field_setting').show();

		jQuery("#apbgf_staff").val(typeof field["apbgf_staff"] !== "undefined" ? field["apbgf_staff"] : 'all');
		if (field["apbgf_staff_hide"]) {
			jQuery("#apbgf_staff_hide").prop("checked", true);
		}

		jQuery("#apbgf_service").val(typeof field["apbgf_service"] !== "undefined" ? field["apbgf_service"] : 'all');
		if (field["apbgf_service_hide"]) {
			jQuery("#apbgf_service_hide").prop("checked", true);
		}

		if (firstLocationId) {
			SetFieldProperty('apbgf_location', firstLocationId);
			jQuery("#apbgf_location").val(firstLocationId);
			SetFieldProperty('apbgf_location_hide', true);
			jQuery("#apbgf_location_hide").prop("checked", true);
		}

		jQuery("#apbgf_service_category").val(typeof field["apbgf_service_category"] !== "undefined" ? field["apbgf_service_category"] : 0).trigger('change');
		if (field["apbgf_service_category_hide"]) {
			jQuery("#apbgf_service_category_hide").prop("checked", true);
		}
	}
});