(function(a){a.fn.contextMenu=function(b){var c=b;return this.each(function(f){var e=(a(this).data("index")==undefined?f+Math.round(Math.random()*10000).toString():a(this).data("index"));a(this).data("index",e);var g=(a(this).attr("buttons")==undefined?[]:a(this).attr("buttons").split(","));for(var f in c){if(a.inArray(c[f],g)==-1){g.push(c[f])}}if(!a.isArray(g)){g=[]}var h={anchor:a(this),buttons:g,index:e};var d;a(this).hover(function(){a("ul.context_plugin_dropdown").hide();if(d){clearTimeout(d);d=null}d=setTimeout(function(){var l=a("ul#context_plugin_dropdown_"+h.index);if(l.length==0){a("body:first").prepend('<ul id="context_plugin_dropdown_'+h.index+'" class="context_plugin_dropdown"></ul>');l=a("ul#context_plugin_dropdown_"+h.index);var j="";for(var k in h.buttons){if(a.fn.contextMenu.actions[h.buttons[k]]){j+='<li class="context_plugin_item"><a class="'+a.fn.contextMenu.actions[h.buttons[k]].name+'" href="javascript:void(0);">'+a.fn.contextMenu.actions[h.buttons[k]].title+"</a></li>"}}l.html(j);l.children("li.context_plugin_item").children("a").data("objectData",h);l.hover(function(){},function(){a(this).hide()})}l.css("top",Math.round(h.anchor.offset().top-h.anchor.scrollTop())+"px");l.css("left",Math.round(h.anchor.offset().left-h.anchor.scrollLeft())+"px");if(h.anchor.offset().top+l.height()>a(document).height()){l.css("top",Math.round(h.anchor.offset().top-l.height()+h.anchor.height()-h.anchor.scrollTop())+"px")}if(h.anchor.offset().left+l.width()>a(document).width()){l.css("left",Math.round(h.anchor.offset().left-l.width()+h.anchor.width()-h.anchor.scrollLeft())+"px")}l.show()},a.fn.contextMenu.settings.delayHoverEvent)},function(){if(d){clearTimeout(d);d=null}})})};a.fn.contextMenu.actions=[];a.fn.contextMenu.addAction=function(b){a.fn.contextMenu.actions[b.name]=b;a("a."+b.name).live("click",function(){a("ul.context_plugin_dropdown").hide()});a("a."+b.name).live("click",b.bind)};a.fn.contextMenu.settings={delayHoverEvent:333}})(jQuery);
