(function(B){var A=0;B.popover=function(G,N){var L=B(G),I=this;var F,O,J,H,D,K,M;var E={trigger:"click",closeHTML:"&#215;",appearUnder:G,baseClass:"popover",escape:true,clickOff:true,maskOpacity:0,animationSpeed:370,title:L.text(),content:function(){var P=L.attr("href");return B(P).html();},onTrigger:function(){},onDisplay:function(){},onClose:function(){}};I.settings={};I.init=function(){I.settings=B.extend({},E,N);J=I.settings.baseClass;H="#"+J+"-bg";D=B(H);K=J+"-active";M=I.settings.animationSpeed/2.5;C();F=B("."+J+"-wrap");O=B(F[A]);O.find("."+J+"-content").html(I.settings.content());var P="."+J+"-wrap a.close";P+=(I.settings.clickOff)?", "+H:"";L.bind(I.settings.trigger,function(Q){I.settings.onTrigger.call(this);I.showPopover();Q.preventDefault();});if(I.settings.escape){B("body").keyup(function(R){if(R.which===27){var Q=(R.shiftKey)?M*7:M;I.hidePopover(Q);}});}B(P).click(function(R){var Q=(R.shiftKey)?M*7:M;I.hidePopover(Q);R.preventDefault();});};I.destroy=function(){};I.showPopover=function(T){T=typeof (T)!="undefined"?T:I.settings.animationSpeed;I.hidePopover();I.settings.onDisplay.call(this);D.css("opacity",I.settings.maskOpacity).show();L.addClass(K);var Q=B(I.settings.appearUnder);var U=Q.offset();var S=Q.width();var P=Q.height();var R=O.width();O.css({left:(U.left+(S/2)-(R/2))+"px",top:(U.top+P+14)+"px"}).fadeIn(T);};I.hidePopover=function(P){P=typeof (P)!="undefined"?P:M;I.settings.onClose.call(this);D.hide();B("."+K).removeClass(K);F.fadeOut(P);};var C=function(){if(!D.length){B("body").append('<div id="'+J+'-bg" />');}D=B(H);var P='<div class="'+J+'-wrap"><div class="'+J+'">';P+='<h3 class="'+J+'-title">'+I.settings.title+"</h3>";P+='<div class="'+J+'-content" />';P+='<a href="#" class="close">'+I.settings.closeHTML+"</a>";P+='<br class="clear" /></div></div>';B("body").append(P);};I.init();};B.fn.popover=function(C){return this.each(function(){if(!B(this).data("popover")){var D=new B.popover(this,C);B(this).data("popover",D);A++;}});};})(jQuery);
