(function($) {
    'use strict';

    $(function() {
        // Since we don't have PHP 5.4, pretty-print in Javascript
        var $json = $('#json-data');
        var $expand = $('#expand-data');
        var jsonVal = $json.val();
        try {
            var jsonPretty = JSON.stringify(JSON.parse(jsonVal), null, 4);
            $json.val(jsonPretty);
        } catch (e) {
            //alert(e); //error in the above string(in this case,yes)!
        }

        $expand.bind('click', function(e) {
            //$expand.on('click', function(e) {
            e.preventDefault();

            if ($json.hasClass('open')) {
                $expand.html('Expand Data &raquo;');
                $json.removeClass('open').hide();
            } else {
                $expand.html('&laquo; Collapse Data');
                $json.addClass('open').show();
            }
            return false;
        });

        $('.health-check-accordion').on('click', '.health-check-accordion-trigger', function() {
            var $this = $(this);
            if ('true' === $this.attr('aria-expanded')) {
                $this.attr('aria-expanded', 'false');
                $('#' + $this.attr('aria-controls')).attr('hidden', !0);
            } else {
                $this.attr('aria-expanded', 'true');
                $('#' + $this.attr('aria-controls')).attr('hidden', !1);
            }
        });
    });
})(jQuery);
