(function($){
    $.fn.slideMenu = function(settings) {

        var config = {
            duration: 200
        };
        if (settings) $.extend(config, settings);

        var bindLevel = function($l,l){
            
            if($l.children('ul').length>0){
                $l.children('ul').children('li').each(function(){
                    if($(this).children('ul').length>0){
                        $(this).children('ul').hide();
                    }
                    $(this).hover(function(){
                        $(this).children('ul').stop(true,true).slideDown(config.duration);
                    },function(){
                        $(this).children('ul').stop(true,true).slideUp(config.duration);
                    });
                    
                    $(this).children('ul').children('li').each(function(){
                        if($(this).children('ul').length>0){
                            bindLevel($(this),l+1);
                        }
                    });

                });
            }

        }

        this.each(function() {

            var $t = $(this);
            bindLevel($t,0);

        });
        

        return this;

    };

})(this.jQuery);
