!function(a){function d(a,b,c){return typeof a=="function"?a.apply(b,c):a}var b;a(document).ready(function(){a.support.transition=function(){var a=document.body||document.documentElement,b=a.style,c=b.transition!==undefined||b.WebkitTransition!==undefined||b.MozTransition!==undefined||b.MsTransition!==undefined||b.OTransition!==undefined;return c}();if(a.support.transition){b="TransitionEnd";if(a.browser.webkit){b="webkitTransitionEnd"}else if(a.browser.mozilla){b="transitionend"}else if(a.browser.opera){b="oTransitionEnd"}}});var c=function(b,c){this.$element=a(b);this.options=c;this.enabled=true;this.fixTitle()};c.prototype={show:function(){var b,c,e,f,g,h;if(this.getTitle()&&this.enabled){g=this.tip();this.setContent();if(this.options.animate){g.addClass("fade")}g.remove().css({top:0,left:0,display:"block"}).prependTo(document.body);b=a.extend({},this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight});c=g[0].offsetWidth;e=g[0].offsetHeight;f=d(this.options.placement,this,[g[0],this.$element[0]]);switch(f){case"below":h={top:b.top+b.height+this.options.offset,left:b.left+b.width/2-c/2};break;case"above":h={top:b.top-e-this.options.offset,left:b.left+b.width/2-c/2};break;case"left":h={top:b.top+b.height/2-e/2,left:b.left-c-this.options.offset};break;case"right":h={top:b.top+b.height/2-e/2,left:b.left+b.width+this.options.offset};break}g.css(h).addClass(f).addClass("in")}},setContent:function(){var a=this.tip();a.find(".twipsy-inner")[this.options.html?"html":"text"](this.getTitle());a[0].className="twipsy"},hide:function(){function e(){d.remove()}var c=this,d=this.tip();d.removeClass("in");a.support.transition&&this.$tip.hasClass("fade")?d.bind(b,e):e()},fixTitle:function(){var a=this.$element;if(a.attr("title")||typeof a.attr("data-original-title")!="string"){a.attr("data-original-title",a.attr("title")||"").removeAttr("title")}},getTitle:function(){var a,b=this.$element,c=this.options;this.fixTitle();if(typeof c.title=="string"){a=b.attr(c.title=="title"?"data-original-title":c.title)}else if(typeof c.title=="function"){a=c.title.call(b[0])}a=(""+a).replace(/(^\s*|\s*$)/,"");return a||c.fallback},tip:function(){if(!this.$tip){this.$tip=a('<div class="twipsy" />').html('<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>')}return this.$tip},validate:function(){if(!this.$element[0].parentNode){this.hide();this.$element=null;this.options=null}},enable:function(){this.enabled=true},disable:function(){this.enabled=false},toggleEnabled:function(){this.enabled=!this.enabled}};a.fn.twipsy=function(b){a.fn.twipsy.initWith.call(this,b,c,"twipsy");return this};a.fn.twipsy.initWith=function(b,c,d){function k(){var a=i(this);a.hoverState="out";if(b.delayOut==0){a.hide()}else{setTimeout(function(){if(a.hoverState=="out"){a.hide()}},b.delayOut)}}function j(){var a=i(this);a.hoverState="in";if(b.delayIn==0){a.show()}else{a.fixTitle();setTimeout(function(){if(a.hoverState=="in"){a.show()}},b.delayIn)}}function i(e){var f=a.data(e,d);if(!f){f=new c(e,a.fn.twipsy.elementOptions(e,b));a.data(e,d,f)}return f}var e,f,g,h;if(b===true){return this.data(d)}else if(typeof b=="string"){e=this.data(d);if(e){e[b]()}return this}b=a.extend({},a.fn[d].defaults,b);if(!b.live){this.each(function(){i(this)})}if(b.trigger!="manual"){f=b.live?"live":"bind";g=b.trigger=="hover"?"mouseenter":"focus";h=b.trigger=="hover"?"mouseleave":"blur";this[f](g,j)[f](h,k)}return this};a.fn.twipsy.Twipsy=c;a.fn.twipsy.defaults={animate:true,delayIn:0,delayOut:0,fallback:"",placement:"above",html:false,live:false,offset:0,title:"title",trigger:"hover"};a.fn.twipsy.elementOptions=function(b,c){return a.metadata?a.extend({},c,a(b).metadata()):c}}(window.jQuery||window.ender)
