(function ($) {
    



var flyout = {


    activetli: null,
    timerhandle: null,
    timerhandle2: null,
    show: function (topli) {
        this.cleartimer();
        if (this.activetli != null) {
            this.hide(this.activetli);
        }
        this.activetli = topli;
        topli.addClass('mover');
    },

    hide: function (topli) {
        topli.removeClass('mover');
    },
    starttimeout: function () {
        this.timerhandle = window.setTimeout(function () { flyout.ontimeout(); }, 500)
    },
    ontimeout: function () {
        this.hide(this.activetli);
        this.activetli = null;
    },

    cleartimer: function () {
        window.clearTimeout(this.timerhandle);
    },

    delay: function (f, t) {
        this.abort();
        this.timerhandle2 = window.setTimeout(function () { f(); flyout.timerhandle2 = null; }, t);
    },
    abort: function () {
        if (this.timerhandle2 != null) {
            window.clearTimeout(this.timerhandle2);
            this.timerhandle2 = null;
        }
    },
    rdy: function () {


        // get submenus
        var submenus = $('#dropMenu div.dropMenuSub');
        var topli = $('#dropMenu > div.menuitem');
        
        topli.mouseover(function () {
            flyout.show($(this));
        });

        topli.mouseout(function () {
            flyout.starttimeout();
        });

        var topa = jQuery('#dropMenu > div.menuitem  > a');
        topa.focus(function () {
            flyout.abort();
            flyout.show(jQuery($(this).parents(".menuitem")[0]));
        });
        topa.blur(
        function () {
            var target = $(this);
            flyout.delay(
            function () {
                flyout.hide(jQuery($(this).parents(".menuitem")[0]));
            }, 10
        );
        }
    );
        var suba = $('.dropMenu > div.dropMenuSub > div.inner > div.menuitem > a');
        suba.focus(function () {
            flyout.abort();
        });
        suba.blur(
        function () {
            var target = $(this);
            flyout.delay(
                function () {
                    flyout.hide(target.parent().parent().parent().parent());
                }, 10
            );
        }
    );
    }
};

jQuery(flyout.rdy);
})(jQuery)
