(function($) {
    
    $.fn.acordeon = function() {
        return this.each(function() {
            new Acordeon(this);
        })
    };
    
    var Acordeon = function(el) {
        this.el = $(el);
        this.items = this.el.children();
        
        this.init();
    }
    
    Acordeon.prototype.extend = $.extend;
    Acordeon.prototype.extend({
        init: function() {
            this.opened = this.items.filter('.abierto').find('ul').show();
            
            var that = this;
            this.el.find('h3').click(function(e) {
                that.switch_item($(this.parentNode));
            });
            
        },
        
        switch_item: function($li) {
            this.opened.slideUp()
            //this.opened = $li.find('ul').slideDown();
            
        }
    });
    
})(jQuery);
