(function(b){function h(a){if(a.attr("title")||typeof a.attr("original-title")!="string")a.attr("original-title",a.attr("title")||"").removeAttr("title")}function i(a,c){this.$element=b(a);this.options=c;this.enabled=true;h(this.$element)}i.prototype={show:function(){var a=this.getTitle();if(a&&this.enabled){var c=this.tip();c.find(".tipsy-inner")[this.options.html?"html":"text"](a);c[0].className="tipsy";c.remove().css({top:0,left:0,visibility:"hidden",display:"block"}).appendTo(document.body);var a=
b.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight}),d=c[0].offsetWidth,g=c[0].offsetHeight,f=typeof this.options.gravity=="function"?this.options.gravity.call(this.$element[0]):this.options.gravity,e;switch(f.charAt(0)){case "n":e={top:a.top+a.height+this.options.offset,left:a.left+a.width/2-d/2};break;case "s":e={top:a.top-g-this.options.offset,left:a.left+a.width/2-d/2};break;case "e":e={top:a.top+a.height/2-g/2,left:a.left-d-this.options.offset};
break;case "w":e={top:a.top+a.height/2-g/2,left:a.left+a.width+this.options.offset}}if(f.length==2)e.left=f.charAt(1)=="w"?a.left+a.width/2-15:a.left+a.width/2-d+15;c.css(e).addClass("tipsy-"+f);this.options.fade?c.stop().css({opacity:0,display:"block",visibility:"visible"}).animate({opacity:this.options.opacity}):c.css({visibility:"visible",opacity:this.options.opacity})}},hide:function(){this.options.fade?this.tip().stop().fadeOut(function(){b(this).remove()}):this.tip().remove()},getTitle:function(){var a,
b=this.$element,d=this.options;h(b);d=this.options;typeof d.title=="string"?a=b.attr(d.title=="title"?"original-title":d.title):typeof d.title=="function"&&(a=d.title.call(b[0]));return(a=(""+a).replace(/(^\s*|\s*$)/,""))||d.fallback},tip:function(){if(!this.$tip)this.$tip=b('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"/></div>');return this.$tip},validate:function(){this.$element[0].parentNode||this.hide()},enable:function(){this.enabled=true},disable:function(){this.enabled=
false},toggleEnabled:function(){this.enabled=!this.enabled}};b.fn.tipsy=function(a){function c(c){var d=b.data(c,"tipsy");d||(d=new i(c,b.fn.tipsy.elementOptions(c,a)),b.data(c,"tipsy",d));return d}function d(){var b=c(this);b.hoverState="in";a.delayIn==0?b.show():setTimeout(function(){b.hoverState=="in"&&b.show()},a.delayIn)}function g(){var b=c(this);b.hoverState="out";a.delayOut==0?b.hide():setTimeout(function(){b.hoverState=="out"&&b.hide()},a.delayOut)}if(a===true)return this.data("tipsy");else if(typeof a==
"string")return this.data("tipsy")[a]();a=b.extend({},b.fn.tipsy.defaults,a);a.live||this.each(function(){c(this)});if(a.trigger!="manual"){var f=a.live?"live":"bind",e=a.trigger=="hover"?"mouseleave":"blur";this[f](a.trigger=="hover"?"mouseenter":"focus",d)[f](e,g)}return this};b.fn.tipsy.defaults={delayIn:0,delayOut:0,fade:false,fallback:"",gravity:"n",html:false,live:false,offset:0,opacity:0.8,title:"title",trigger:"hover"};b.fn.tipsy.elementOptions=function(a,c){return b.metadata?b.extend({},
c,b(a).metadata()):c};b.fn.tipsy.autoNS=function(){return b(this).offset().top>b(document).scrollTop()+b(window).height()/2?"s":"n"};b.fn.tipsy.autoWE=function(){return b(this).offset().left>b(document).scrollLeft()+b(window).width()/2?"e":"w"}})(jQuery);
