Index: contextMenu.js
===================================================================
--- contextMenu.js	(revision 484)
+++ contextMenu.js	(working copy)
@@ -18,19 +18,21 @@
     $.extend($.fn, {
 
         contextMenu: function(o, callback) {
+
             // Defaults
-            if( o.menu == undefined ) return false;
+            if( o.menu == undefined && o.chooseMenu == undefined ) return false;
             if( o.inSpeed == undefined ) o.inSpeed = 150;
             if( o.outSpeed == undefined ) o.outSpeed = 75;
+
             // 0 needs to be -1 for expected results (no fade)
             if( o.inSpeed == 0 ) o.inSpeed = -1;
             if( o.outSpeed == 0 ) o.outSpeed = -1;
+
             // Loop each context menu
             $(this).each( function() {
                 var el = $(this);
                 var offset = $(el).offset();
-                // Add contextMenu class
-                $('#' + o.menu).addClass('contextMenu');
+
                 // Simulate a true right click
                 $(this).mousedown( function(e) {
                     var evt = e;
@@ -40,8 +42,6 @@
                         if( evt.button == 2 ) {
                             // Hide context menus that may be showing
                             $(".contextMenu").hide();
-                            // Get this context menu
-                            var menu = $('#' + o.menu);
 
                             if( $(el).hasClass('disabled') ) return false;
 
@@ -67,6 +67,33 @@
                             (e.pageX) ? x = e.pageX : x = e.clientX + d.scrollLeft;
                             (e.pageY) ? y = e.pageY : x = e.clientY + d.scrollTop;
 
+                            var pos = {x: x - offset.left, y: y - offset.top, docX: x, docY: y};
+
+                            // Determine which menu to show
+                            var menu;
+                            if( o.menu ) {
+                                menu = $('#' + o.menu);
+                            } else if( o.chooseMenu ) {
+                                menu = o.chooseMenu(pos);
+                                if ( ! menu )
+                                    return false;
+                                menu = $('#' + menu);
+                            }
+                            if( menu == undefined ) return false;
+
+                            // Setup classes and no menus
+                            $(menu).addClass('contextMenu');
+                            $('UL.contextMenu').bind('contextmenu', function() { return false; });
+
+                            // Disable text selection
+                            if( $.browser.mozilla ) {
+                                $(menu).each( function() { $(this).css({ 'MozUserSelect' : 'none' }); });
+                            } else if( $.browser.msie ) {
+                                $(menu).each( function() { $(this).bind('selectstart.disableTextSelect', function() { return false; }); });
+                            } else {
+                                $(menu).each(function() { $(this).bind('mousedown.disableTextSelect', function() { return false; }); });
+                            }
+
                             // Show the menu
                             $(document).unbind('click');
                             $(menu).css({ top: y, left: x }).fadeIn(o.inSpeed);
@@ -107,12 +134,12 @@
                             });
 
                             // When items are selected
-                            $('#' + o.menu).find('A').unbind('click');
-                            $('#' + o.menu).find('LI:not(.disabled) A').click( function() {
+                            $(menu).find('A').unbind('click');
+                            $(menu).find('LI:not(.disabled) A').click( function() {
                                 $(document).unbind('click').unbind('keypress');
                                 $(".contextMenu").hide();
                                 // Callback
-                                if( callback ) callback( $(this).attr('href').substr(1), $(srcElement), {x: x - offset.left, y: y - offset.top, docX: x, docY: y} );
+                                if( callback ) callback( $(this).attr('href').substr(1), $(srcElement), pos );
                                 return false;
                             });
 
@@ -128,16 +155,8 @@
                     });
                 });
 
-                // Disable text selection
-                if( $.browser.mozilla ) {
-                    $('#' + o.menu).each( function() { $(this).css({ 'MozUserSelect' : 'none' }); });
-                } else if( $.browser.msie ) {
-                    $('#' + o.menu).each( function() { $(this).bind('selectstart.disableTextSelect', function() { return false; }); });
-                } else {
-                    $('#' + o.menu).each(function() { $(this).bind('mousedown.disableTextSelect', function() { return false; }); });
-                }
                 // Disable browser context menu (requires both selectors to work in IE/Safari + FF/Chrome)
-                $(el).add('UL.contextMenu').bind('contextmenu', function() { return false; });
+                $(el).bind('contextmenu', function() { return false; });
 
             });
             return $(this);
