(function(b){function j(a){if(a.attr("title")||typeof a.attr("original-title")!="string")a.attr("original-title",a.attr("title")||"").removeAttr("title")}function k(a,c){this.$element=b(a);this.options=c;this.enabled=true;j(this.$element)}k.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);a= b.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight});var d=c[0].offsetWidth,h=c[0].offsetHeight,g=typeof this.options.gravity=="function"?this.options.gravity.call(this.$element[0]):this.options.gravity,f;switch(g.charAt(0)){case "n":f={top:a.top+a.height+this.options.offset,left:a.left+a.width/2-d/2};break;case "s":f={top:a.top-h-this.options.offset,left:a.left+a.width/2-d/2};break;case "e":f={top:a.top+a.height/2-h/2,left:a.left-d-this.options.offset}; break;case "w":f={top:a.top+a.height/2-h/2,left:a.left+a.width+this.options.offset};break}if(g.length==2)f.left=g.charAt(1)=="w"?a.left+a.width/2-15:a.left+a.width/2-d+15;c.css(f).addClass("tipsy-"+g);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, c=this.$element,d=this.options;j(c);d=this.options;if(typeof d.title=="string")a=c.attr(d.title=="title"?"original-title":d.title);else if(typeof d.title=="function")a=d.title.call(c[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(){if(!this.$element[0].parentNode){this.hide();this.options=this.$element=null}}, enable:function(){this.enabled=true},disable:function(){this.enabled=false},toggleEnabled:function(){this.enabled=!this.enabled}};b.fn.tipsy=function(a){function c(e){var i=b.data(e,"tipsy");if(!i){i=new k(e,b.fn.tipsy.elementOptions(e,a));b.data(e,"tipsy",i)}return i}function d(){var e=c(this);e.hoverState="in";a.delayIn==0?e.show():setTimeout(function(){e.hoverState=="in"&&e.show()},a.delayIn)}function h(){var e=c(this);e.hoverState="out";a.delayOut==0?e.hide():setTimeout(function(){e.hoverState== "out"&&e.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 g=a.live?"live":"bind",f=a.trigger=="hover"?"mouseleave":"blur";this[g](a.trigger=="hover"?"mouseenter":"focus",d)[g](f,h)}return this};b.fn.tipsy.defaults={delayIn:0,delayOut:0,fade:false,fallback:"",gravity:"n",html:false,live:false,offset:0,opacity:1,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);
