jQuery.fn.menu = function(options){
    var options = jQuery.extend({
        show: 200,
        hide: 100
    }, options);
    
    return this.each(function(){
        var mainId = this.id;
        $(this).find('.dDMLi').hover(function(){ // mouse over LI
            $('#' + mainId).stopTime('dDMTO');
            var ulo = $(this).children('.dDMUl:first');
            if (ulo.length) {
                ulo.get(0).overFlag = true
                if ($(this).parent().parent().attr('id') == mainId) { // 1 level
                    ulo.css({
                        top: $(this).height()
                    });
                }
                else { // 2+ level
                    ulo.css({
                        visibility: 'visible',
                        left: $(this).width()
                    });
                }
                if (ulo.queue().length) {
                    ulo.stop(true, true);
                    ulo.show();
                }
                else 
                    if (ulo.is(':hidden')) {
                        ulo.slideDown(200);
                    }
            }
            $('.dDMUl .dDMUl').each(function(){
                if (!this.overFlag && $(this).is(':visible')) {
                    $(this).slideUp(100);
                }
            });
        }, function(){ // mouse out LI
            var ulo = $(this).children('.dDMUl:first');
            if (ulo.length) {
                ulo.get(0).overFlag = false
            }
            $('#' + mainId).oneTime('1s', 'dDMTO', function(){
                $('.dDMUl .dDMUl').each(function(){
                    if (!this.overFlag && $(this).is(':visible')) {
                        $(this).slideUp(100);
                    }
                });
            });
        });
    });
}