(function($) {
  Drupal.behaviors.incubatorEventsNodeForm = {
    attach: function (context, settings) {
      var fieldset = $('.field-name-field-event-date fieldset.form-wrapper');
      var field = $('.field-name-field-event-date .start-date-wrapper input').first();
      fieldset.once('collapsible').addClass('collapsible');
      if (field.val().length === 0) {
        fieldset.addClass('collapsed');
      }
      else {
        fieldset.removeClass('collapsed');
      }
    }
  };
}(jQuery));
