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('2s','dDMTO',function () {
                    $('.dDMUl .dDMUl').each(function () {
                        if (!this.overFlag&&$(this).is(':visible')) {
                            $(this).slideUp(100);
                        }
                    });
                });
            }
        );
    });
}
/*
$(function() {
    window.dDMTO=false;
    $('.dDMLi').hover(
        function () { // mouse over LI
            $('#dropDownMenu').stopTime('dDMTO');
            var ulo=$(this).children('.dDMUl:first');
            if (ulo.length) {
                ulo.get(0).overFlag=true
                if ($(this).parent().parent().attr('id')=='dropDownMenu') { // 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
            }
            $('#dropDownMenu').oneTime('2s','dDMTO',function () {
                $('.dDMUl .dDMUl').each(function () {
                    if (!this.overFlag&&$(this).is(':visible')) {
                        $(this).slideUp(100);
                    }
                });
            });
        }
    );
});
*/
//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
/*
var arrowimages={down:['downarrowclass', 'down.gif', 23], right:['rightarrowclass', 'right.gif']}

var jqueryslidemenu={

    animateduration: {over: 200, out: 100}, //duration of slide in/ out animation, in milliseconds

    buildmenu:function(menuid, arrowsvar) {
        jQuery(document).ready(function($){

            var $mainmenu=$("#"+menuid+">.dDMUl");
            $headers=$mainmenu
                .find(".dDMUl")
//                .each(function () {this.overFlag=false;})
                .parent();
            $drops=$headers.children('.dDMUl');
            $drops.each(function () {
                    this.overFlag=false;
                });
            $headers.each(function(i){
                var $curobj=$(this);
                var $subul=$(this).find('.dDMUl:eq(0)');
                this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
                this.istopheader=$curobj.parents(".dDMUl").length==1? true : false
                $subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
                $curobj.hover(
                    function(e){
                        if ($subul.get(0).overFlag==false&&$subul.get(0).to) {
                            clearTimeout($subul.get(0).to);
                        }
                        $subul.get(0).overFlag=true;
                        // close all
                        $drops
                            .stop(true,true)
                            .each(function () {
                                //$subul.get(0).overFlag
                                // alert(this.overFlag);
                                if (!this.overFlag) {
                                    $(this).fadeOut();
                                }
                            });
                        var $targetul=$(this).children(".dDMUl:eq(0)")
                        this._offsets={left:$(this).offset().left, top:$(this).offset().top}
                        var menuleft=this.istopheader? 0 : this._dimensions.w
                        menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
                        // $targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(jqueryslidemenu.animateduration.over)
                        if ($targetul.queue().length) {
                            $targetul.stop(true,true);
                            $targetul.show();
                        } else if ($targetul.is(':hidden')) {
//alert($targetul.attr('id'));
                            $targetul.css({left:menuleft+"px"}).fadeIn();
                        }
                    },
                    function(e){
                        $subul.get(0).overFlag=false;

                        var $targetul=$(this).children(".dDMUl:eq(0)")
                        // $targetul.slideUp(jqueryslidemenu.animateduration.out)
                        // $targetul.stop(true,true);

                        $subul.get(0).to=setTimeout(function() {
                            if (!$targetul.get(0).overFlag) {
                                $targetul.fadeOut()
                            }
                        },5000);

                    }
                ) //end hover
            }) //end $headers.each()
            $mainmenu.find(".dDMUl").css({display:'none', visibility:'visible'})
        }) //end document.ready
    }
}

jqueryslidemenu.buildmenu("dropDownMenu", arrowimages)
*/