(function($) {
    $.menuWidget = {};

    $.fn.menuWidget = function() {
        var parent = $('li:has(ul.sub-menu)', this);
        parent.each(function() {
            $(this).bind('mouseenter', function(event) {
                $('> ul.sub-menu', this).fadeIn('fast');
                if ($('> ul.sub-menu', this).parents('ul.sub-menu').length > 0) {
                    $('> ul.sub-menu', this).css('margin-left', $(this).width()).css('width', '160%').css('top', $(this).css('margin-top'));
                }
            }).bind('mouseleave', function(event) {
                $('> ul.sub-menu', this).fadeOut('fast');
            });
        });
    };
})(jQuery);

