if(jQuery){(function(){$.extend($.fn,{contextMenu:function(a,b){if(a.menu==undefined){return false}if(a.inSpeed==undefined){a.inSpeed=150}if(a.outSpeed==undefined){a.outSpeed=75}if(a.inSpeed==0){a.inSpeed=-1}if(a.outSpeed==0){a.outSpeed=-1}$(this).each(function(){var c=$(this);var d=$(c).offset();$("#"+a.menu).addClass("contextMenu");$(this).click(function(i){var h=i;var g=$(this);$(this).unbind("mouseup");$(".contextMenu").hide();var k=$("#"+a.menu);if($(c).hasClass("disabled")){return false}var j={},f,l;j=$(this).offset();f=j.left;l=j.top+$(this).height();$(document).unbind("click");$(k).css({top:l,left:f}).fadeIn(a.inSpeed);$(k).find("A").mouseover(function(){$(k).find("LI.hover").removeClass("hover");$(this).parent().addClass("hover")}).mouseout(function(){$(k).find("LI.hover").removeClass("hover")});$(document).keypress(function(m){switch(m.keyCode){case 38:if($(k).find("LI.hover").size()==0){$(k).find("LI:last").addClass("hover")}else{$(k).find("LI.hover").removeClass("hover").prevAll("LI:not(.disabled)").eq(0).addClass("hover");if($(k).find("LI.hover").size()==0){$(k).find("LI:last").addClass("hover")}}break;case 40:if($(k).find("LI.hover").size()==0){$(k).find("LI:first").addClass("hover")}else{$(k).find("LI.hover").removeClass("hover").nextAll("LI:not(.disabled)").eq(0).addClass("hover");if($(k).find("LI.hover").size()==0){$(k).find("LI:first").addClass("hover")}}break;case 13:$(k).find("LI.hover A").trigger("click");break;case 27:$(document).trigger("click");break}});$("#"+a.menu).find("A").unbind("click");$("#"+a.menu).find("LI:not(.disabled) A").click(function(){$(document).unbind("click").unbind("keypress");$(".contextMenu").hide();if(b){b($(this).attr("href").substr(1),$(g),{x:f-d.left,y:l-d.top,docX:f,docY:l})}return false});setTimeout(function(){$(document).click(function(){$(document).unbind("click").unbind("keypress");$(k).fadeOut(a.outSpeed);return false})},0);return false});if($.browser.mozilla){$("#"+a.menu).each(function(){$(this).css({MozUserSelect:"none"})})}else{if($.browser.msie){$("#"+a.menu).each(function(){$(this).bind("selectstart.disableTextSelect",function(){return false})})}else{$("#"+a.menu).each(function(){$(this).bind("mousedown.disableTextSelect",function(){return false})})}}});return $(this)},disableContextMenuItems:function(a){if(a==undefined){$(this).find("LI").addClass("disabled");return($(this))}$(this).each(function(){if(a!=undefined){var c=a.split(",");for(var b=0;b<c.length;b++){$(this).find('A[href="'+c[b]+'"]').parent().addClass("disabled")}}});return($(this))},enableContextMenuItems:function(a){if(a==undefined){$(this).find("LI.disabled").removeClass("disabled");return($(this))}$(this).each(function(){if(a!=undefined){var c=a.split(",");for(var b=0;b<c.length;b++){$(this).find('A[href="'+c[b]+'"]').parent().removeClass("disabled")}}});return($(this))},disableContextMenu:function(){$(this).each(function(){$(this).addClass("disabled")});return($(this))},enableContextMenu:function(){$(this).each(function(){$(this).removeClass("disabled")});return($(this))},destroyContextMenu:function(){$(this).each(function(){$(this).unbind("mousedown").unbind("mouseup")});return($(this))}})})(jQuery)};