(function(D){function C(E){var F=D.data(D(E).parents().andSelf().filter("ul.jd_menu")[0],"jdMenuSettings");
D("> li",E).bind("mouseenter.jdmenu mouseleave.jdmenu",function(G){D(this).toggleClass("jdm_hover");
var H=D("> ul",this);
if(H.length==1){clearTimeout(this.$jdTimer);
var J=(G.type=="mouseenter");
var I=(J?B:A);
this.$jdTimer=setTimeout(function(){I(H[0],F.onAnimate,F.isVertical)
},J?F.showDelay:F.hideDelay)
}}).bind("click.jdmenu",function(H){var I=D("> ul",this);
if(I.length==1&&(F.disableLinks==true||D(this).hasClass("accessible"))){B(I,F.onAnimate,F.isVertical);
return false
}if(H.target==this){var J=D("> a",H.target).not(".accessible");
if(J.length>0){var G=J[0];
if(!G.onclick){window.open(G.href,G.target||"_self")
}else{D(G).trigger("click")
}}}if(F.disableLinks||(!F.disableLinks&&!D(this).parent().hasClass("jd_menu"))){D(this).parent().jdMenuHide();
H.stopPropagation()
}}).find("> a").bind("focus.jdmenu blur.jdmenu",function(G){var H=D(this).parents("li:eq(0)");
if(G.type=="focus"){H.addClass("jdm_hover")
}else{H.removeClass("jdm_hover")
}}).filter(".accessible").bind("click.jdmenu",function(G){G.preventDefault()
})
}function B(H,G,F){var H=D(H);
if(H.is(":visible")){return 
}H.bgiframe();
var E=H.parent();
H.trigger("jdMenuShow").positionBy({target:E[0],targetPos:(F===true||!E.parent().hasClass("jd_menu")?0:3),elementPos:1,hideAfterPosition:true});
if(!H.hasClass("jdm_events")){H.addClass("jdm_events");
C(H)
}E.addClass("jdm_active").siblings("li").find("> ul:eq(0):visible").each(function(){A(this)
});
if(G===undefined){H.show()
}else{G.apply(H[0],[true])
}}function A(F,E){var F=D(F);
D(".bgiframe",F).remove();
F.filter(":not(.jd_menu)").find("> li > ul:eq(0):visible").each(function(){A(this)
}).end();
if(E===undefined){F.hide()
}else{E.apply(F[0],[false])
}F.trigger("jdMenuHide").parents("li:eq(0)").removeClass("jdm_active jdm_hover").end().find("> li").removeClass("jdm_active jdm_hover")
}D.fn.jdMenu=function(E){var E=D.extend({showDelay:200,hideDelay:500,disableLinks:false},E);
if(!D.isFunction(E.onAnimate)){E.onAnimate=undefined
}return this.filter("ul.jd_menu").each(function(){D.data(this,"jdMenuSettings",D.extend({isVertical:D(this).hasClass("jd_menu_vertical")},E));
C(this)
})
};
D.fn.jdMenuUnbind=function(){D("ul.jdm_events",this).unbind(".jdmenu").find("> a").unbind(".jdmenu")
};
D.fn.jdMenuHide=function(){return this.filter("ul").each(function(){A(this)
})
};
D(window).bind("click.jdmenu",function(){D("ul.jd_menu ul:visible").jdMenuHide()
})
})(jQuery);
