

;(function($) {
    $.fn.simpleAccordion = function(o) {

        // default settings
        var o = jQuery.extend({
            trigger: 'h2',
            container: 'div',
            speed: 'slow',
            index: 0
        }, o);


        return this.each(function() {
            // this => the accordion container
            var $this = this;

            // Variable for the current open item
            $this.curThis = "";

            // Set trigger cursor to pointer
            $(this).find(o.trigger).css('cursor', 'pointer');

            // Default close all item containers
            $(this).find(o.trigger).next(o.container).hide();

            // Add click logic to all triggers
            $(this).find(o.trigger).click(function() {
                if ($this.curThis != "") {
                    $($this.curThis).next(o.container).toggle(o.speed);
                }

                var newThis = this;
                if ($this.curThis == newThis) {
                    $this.curThis = "";
                }
                else {
                    $this.curThis = newThis;
                    $(newThis).next(o.container).toggle(o.speed);
                }
            });
        });
    };
})(jQuery);