(function(n){var m;var h;var k=function(b,a){return{width:(b&&parseInt(b))?(b-n(window).width()-n(window).scrollLeft()):0,height:(a&&parseInt(a))?(a-n(window).height()-n(window).scrollTop()):0}};var i=function(b){if(h[m.activeId].currentHover){var d=b?h[m.activeId].currentHover.nextAll(":not(."+h[m.activeId].separatorClass+"):visible:first"):h[m.activeId].currentHover.prevAll(":not(."+h[m.activeId].separatorClass+"):visible:first");if(d.length==0){d=h[m.activeId].currentHover.parent().find("> li:visible");d=(b?n(d[0]):n(d[d.length-1]))}d.mouseover()}else{var a=n("#"+m.activeId+", #"+m.activeId+" ul").filter(function(){return(n(this).is(":visible")&&n(this).parents(":hidden").length==0)});if(a.length>0){var c=n(a[a.length-1]).find("> li:visible");n(c[(b?0:(c.length-1))]).mouseover()}}};var l=function(){for(cm in h){n(h[cm].allContext).removeClass(m.activeClass)}};var j=function(){if(m.activeId){n("#"+m.activeId).add("#"+m.activeId+" ul").hide()}window.clearInterval(m.keyUpDown);m.keyUpDownStop=false;if(h[m.activeId]){h[m.activeId].currentHover=null}m.activeId=null;n(document).unbind(".jeegoocontext")};n.fn.jeegoocontext=function(a,b){if(!m){m={}}if(!h){h={}}if(b&&b.menuClass){m.menuClass=b.menuClass}if(!m.menuClass){m.menuClass="jeegoocontext"}if(b&&b.activeClass){m.activeClass=b.activeClass}if(!m.activeClass){m.activeClass="active"}h[a]=n.extend({hoverClass:"hover",submenuClass:"submenu",separatorClass:"separator",operaEvent:"dblclick",fadeIn:200,delay:300,keyDelay:100,widthOverflowOffset:0,heightOverflowOffset:0,submenuLeftOffset:0,submenuTopOffset:0,autoAddSubmenuArrows:true},b||{});h[a].allContext=this.selector;if(h[a].autoAddSubmenuArrows){n("#"+a).find("li:has(ul)").not(":has(."+h[a].submenuClass+")").prepend('<span class="'+h[a].submenuClass+'"></span>')}n("#"+a).find("li").unbind(".jeegoocontext").bind("mouseover.jeegoocontext",function(f){var x=h[a].currentHover=n(this);window.clearTimeout(h[a].show);window.clearTimeout(h[a].hide);n("#"+a).find("*").removeClass(h[a].hoverClass);var w=x.parents("li");x.add(x.find("> *")).add(w).add(w.find("> *")).addClass(h[a].hoverClass);var v=true;if(h[a].onHover){if(h[a].onHover.apply(this,[f,h[a].context])==false){v=false}}if(!h[a].proceed){h[a].show=window.setTimeout(function(){h[a].proceed=true;x.mouseover()},h[a].delay);f.stopPropagation();return false}h[a].proceed=false;x.parent().find("ul").not(x.find("> ul")).hide();if(!v){f.preventDefault();return false}var g=x.find("> ul");if(g.length!=0){var d=x.offset();var u=k((d.left+x.parent().width()+h[a].submenuLeftOffset+g.width()+h[a].widthOverflowOffset),(d.top+h[a].submenuTopOffset+g.height()+h[a].heightOverflowOffset));var e=g.parent().parent().width();var t=d.top-x.parent().offset().top;g.css({left:(u.width>0)?(-e-h[a].submenuLeftOffset+"px"):(e+h[a].submenuLeftOffset+"px"),top:(u.height>0)?(t-u.height+h[a].submenuTopOffset)+"px":t+h[a].submenuTopOffset+"px"});g.fadeIn(h[a].fadeIn)}f.stopPropagation()}).bind("click.jeegoocontext",function(d){if(h[a].onSelect){if(h[a].onSelect.apply(this,[d,h[a].context])==false){d.stopPropagation();return false}}j();n(h[a].context).removeClass(m.activeClass);d.stopPropagation()});var c=h[a].event;if(!c){c=n.browser.opera?h[a].operaEvent+".jeegoocontext":"contextmenu.jeegoocontext"}else{c+=".jeegoocontext"}return n(this)[h[a].livequery?"livequery":"bind"](c,function(d){h[a].context=this;var f=n("#"+a);var e=k((d.pageX+f.width()+h[a].widthOverflowOffset),(d.pageY+f.height()+h[a].heightOverflowOffset));if(e.width>0){d.pageX-=e.width}if(e.height>0){d.pageY-=e.height}if(h[a].onShow){if(h[a].onShow.apply(f,[d,h[a].context])==false){d.stopPropagation();return false}}j();m.activeId=a;n("#"+m.activeId).add("#"+m.activeId+" ul").hide();l();n(h[a].context).addClass(m.activeClass);f.find("li, li > *").removeClass(h[a].hoverClass);f.css({left:d.pageX+"px",top:d.pageY+"px"}).fadeIn(h[a].fadeIn);n(document).bind("mouseover.jeegoocontext",function(g){if(n(g.relatedTarget).parents("#"+a).length>0){window.clearTimeout(h[a].show);var p=n(g.relatedTarget).parent().find("li");p.add(p.find("> *")).removeClass(h[a].hoverClass);h[m.activeId].currentHover=null;h[a].hide=window.setTimeout(function(){p.find("ul").hide()},h[a].delay)}}).bind("click.jeegoocontext",function(g){if(m.activeId&&h[m.activeId].onHide){if(h[m.activeId].onHide.apply(n("#"+m.activeId),[g,h[m.activeId].context])==false){return false}}l();j()}).bind("keydown.jeegoocontext",function(q){switch(q.which){case 38:if(m.keyUpDownStop){return false}i();m.keyUpDown=window.setInterval(i,h[m.activeId].keyDelay);m.keyUpDownStop=true;return false;case 39:if(h[m.activeId].currentHover){h[m.activeId].currentHover.find("ul:visible:first li:visible:first").mouseover()}else{var g=n("#"+m.activeId+", #"+m.activeId+" ul:visible");if(g.length>0){n(g[g.length-1]).find(":visible:first").mouseover()}}return false;case 40:if(m.keyUpDownStop){return false}i(true);m.keyUpDown=window.setInterval(function(){i(true)},h[m.activeId].keyDelay);m.keyUpDownStop=true;return false;case 37:if(h[m.activeId].currentHover){n(h[m.activeId].currentHover.parents("li")[0]).mouseover()}else{var r=n("#"+m.activeId+" li."+h[m.activeId].hoverClass);if(r.length>0){n(r[r.length-1]).mouseover()}}return false;case 13:if(h[m.activeId].currentHover){h[m.activeId].currentHover.click()}else{n(document).click()}break;case 27:n(document).click();break;default:break}}).bind("keyup.jeegoocontext",function(g){window.clearInterval(m.keyUpDown);m.keyUpDownStop=false});d.stopPropagation();return false})};n.fn.nojeegoocontext=function(a){n(this).unbind(".jeegoocontext");if(a&&h[a] instanceof Object){h[a]={}}}})(jQuery);