(function($)
{
    $(document).ready(function()
    {
        $('#MenuBar1>li>a').focus(function()
        {
            $(this).parent().addClass('jsHover');
        });
        $('#MenuBar1 a').blur(function()
        {
            var parent = $(this).parent();
            while (!(parent[0].nodeName.toLowerCase() == 'li' && parent.hasClass('jsHover') && parent[0].nodeName.toLowerCase() != 'body'))
            {
                parent = parent.parent();
            }
            
            setTimeout(function() // necessary, as blur fires before focus, and we need to find elements which have the focus
            {
                if(parent.find('a:focus').length === 0)
                {
                    parent.removeClass('jsHover');
                }
            }, 0);
        });
    });
})(jQuery);

// tnx to https://gist.github.com/450017
jQuery.expr[':'].focus = function( elem )
{
  return elem === document.activeElement && ( elem.type || elem.href );
};

