(function ($) {

Drupal.behaviors.voteFunctionStatus = {
  attach: function (context, settings) {
    $('#edit-function-status-wrapper input.form-checkbox', context).once('function-status', function () {
      var $checkbox = $(this);
      var tab = $('#' + $checkbox.attr('id').replace(/-status$/, '-settings'), context).data('verticalTab');

      $checkbox.bind('click.functionsUpdate', function () {
        if ($checkbox.is(':checked')) {
          if (tab) {
            tab.tabShow().updateSummary();
          }
        } else {
          if (tab) {
            tab.tabHide().updateSummary();
          }
        }
      });

      if (tab) {
        tab.fieldset.drupalSetSummary(function (tabContext) {
          return $checkbox.is(':checked') ? Drupal.t('Enabled') : Drupal.t('Disabled');
        });
      }

      $checkbox.triggerHandler('click.functionsUpdate');
    });
  }
};

})(jQuery);
