(function($){
    /*
    $.fn.mondimenu=function(action, opt){
        if(typeof(action)=='string'){
            this.each(function(){
                var opts=$(this).data('menu_opts');
                switch(action){
                    case 'show':
                        $.get(
                            opts.lvl1_xhr_url,
                            {},
                            function(r_data){
                                if(opt && opt.length){
                                    var menu=$(this).data('menu').html('');
                                    $.map(opt, function(el){
                                        var div=$('<div>').addClass('pulsante_menu').html(el);
                                        menu.append(div);
                                        return div;
                                    });
                                }
                                $(this).show();
                            }
                        );
                        break;
                    case 'hide':
                        $(this).hide();
                        break;
                }
            });
        }else{
            opt=$.extend({
                menu_container: '#menu',
                lvl1_xhr_url: ''
            },
            action);
            $(this).data('menu', $(opt.menu_container));
            $(this).data('menu_opts', opt);
            $(this).hide();
        }  
    };
    */
    $.fn.mondimenu=function(button, opt){
        $.extend({click_callback:function(){}}, opt);
        button=$(button);
        var elements=this;
        this.each(function(){
            $(this).hide();
        });
        $('body').click(function(e){
            elements.each(function(){
                $(this).hide();
            });
        });
        button.click(function(e){
            $('body').click();
            opt.click_callback();
            elements.each(function(){
                $(this).show();
            });
            return false;
        });
    };
})(jQuery);

