jQuery.fn.megamenu = function(options) {
    $(this).children("li").hover(
        function(){
            
            menuWrapper = $(this).parent();
            
            menu = $(this).children("div.hidden");
            pTop = menuWrapper.offset().top;
            pLeft = $(this).offset().left;
            
            menu.css({
                'position' : 'absolute',
                'z-index' : '1000',
                'left' : pLeft - 36 + 'px',
                'top' : pTop + 42 + 'px'
            });
            
            // Limit menu(li) inside the menuWrapper(ul)
            wrapper_right = menuWrapper.offset().left + menuWrapper.outerWidth();
            menu_right    = pLeft + menu.outerWidth();
            if( menu_right - 50 >= wrapper_right ) {
                menu.css({
                    'left': pLeft - 62 + 'px'
                });
            }
            
            menu.show();
        },
        function(){
            $(this).children("div.hidden").hide();
        }
    );
};

