$(function() {
    var enableAutoDj = $('form #field_enable_autodj input[type="checkbox"]');

    toggleFieldset('fieldset_autodj', enableAutoDj.is(':checked'));

    enableAutoDj.on('change', function() {
        toggleFieldset('fieldset_autodj', $(this).is(':checked'));
    });
});

function toggleFieldset(fieldset_class, is_visible) {
    var fieldset = $('form fieldset.'+fieldset_class);

    if (is_visible) {
        fieldset.slideDown('fast');
    } else {
        fieldset.slideUp('fast');
    }
}
