{% comment %}
<!--
  Copyright (C) 2012 University of Dundee & Open Microscopy Environment.
  All rights reserved.

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Affero General Public License for more details.

  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->
{% endcomment %}

<script type="text/javascript">

    if (typeof OME === "undefined") {OME = {}}
    // set the enabled status of the option to select a plugin. Set by index (0-based)
    OME.set_center_plugin_enabled = function (index, enabled) {
        // the first 'plugin' is actually the second option (first is thumbnails)
        var $plugin_option = $('#center_panel_chooser select option:nth-child('+ (index+1) +')');
        if (enabled) {
            $plugin_option.prop('disabled', false);
        } else {
            $plugin_option.prop('disabled', true);
        }
    }

    $(document).ready(function() {
        $(".center_panel_content").hide();
        $("#content_details").show();

        $('#center_panel_chooser select').on('change', function() {
            var panel_id = this.options[this.selectedIndex].value;
            $(".center_panel_content").hide();
            $(panel_id).show();
            // other listeners are bound to the parent element (independent of chooser being <select>)
            $('#center_panel_chooser').trigger("center_plugin_changed.ome");
        });
    });
</script>