text: !function(a){"use strict";a.Zebra_Tooltips=function(b,c){var d,e,f,g,h={animation_speed:250,animation_offset:20,background_color:"#000",close_on_click:!0,color:"#FFF",content:!1,default_position:"above",hide_delay:100,keep_visible:!0,max_width:250,opacity:".95",position:"center",prerender:!1,show_delay:100,vertical_offset:0,onBeforeHide:null,onHide:null,onBeforeShow:null,onShow:null},i=this;i.settings={},i.hide=function(b,c){b.each(function(){var b=a(this),d=b.data("Zebra_Tooltip");d&&(d.sticky=!1,c&&(d.destroy=!0),b.data("Zebra_Tooltip",d),l(b))})},i.show=function(b,c){b.each(function(){var b=a(this),d=b.data("Zebra_Tooltip");d&&(d.sticky=!0,d.muted=!1,c&&(d.destroy=!0),b.data("Zebra_Tooltip",d),m(b))})};var j=function(){i.settings=a.extend({},h,c),b.each(function(){var b=a(this),c=b.attr("title"),d=b.data("zebra-tooltip");(c&&""!==c||d&&""!==d||void 0!==i.settings.content)&&(b.bind({mouseenter:function(){c&&a(this).attr("title",""),m(b)},mouseleave:function(){l(b),c&&a(this).attr("title",c)}}),b.data("Zebra_Tooltip",{tooltip:null,content:d||c||"",window_resized:!0,window_scrolled:!0,show_timeout:null,hide_timeout:null,animation_offset:i.settings.animation_offset,sticky:!1,destroy:!1,muted:!1}),i.settings.prerender&&k(b))}),a(window).bind("scroll resize",function(c){b.each(function(){var b=a(this).data("Zebra_Tooltip");b&&("scroll"==c.type?b.window_scrolled=!0:b.window_resized=!0,a(this).data("Zebra_Tooltip",b))})})},k=function(b){var c=b.data("Zebra_Tooltip");if(!c.tooltip){var h=jQuery("<div>",{"class":"Zebra_Tooltip",css:{opacity:0,display:"block"}}),j=jQuery("<div>",{"class":"Zebra_Tooltip_Message",css:{"max-width":i.settings.max_width,"background-color":i.settings.background_color,color:i.settings.color}}).html(i.settings.content?i.settings.content:c.content).appendTo(h),k=jQuery("<div>",{"class":"Zebra_Tooltip_Arrow"}).appendTo(h),n=jQuery("<div>").appendTo(k);i.settings.keep_visible&&(h.bind("mouseleave"+(i.settings.close_on_click?" click":""),function(){l(b)}),h.bind("mouseenter",function(){m(b)})),h.appendTo("body");var o=h.outerWidth(),p=h.outerHeight(),q=n.outerWidth(),r=n.outerHeight(),s=j.outerWidth(),t=j.outerHeight();c={tooltip:h,tooltip_width:o,tooltip_height:p+r/2,message:j,arrow_container:k,arrow_width:q,arrow_height:r,arrow:n},h.css({width:c.tooltip_width,height:c.tooltip_height}),c.tooltip_width=c.tooltip_width+(j.outerWidth()-s),c.tooltip_height=c.tooltip_height+(j.outerHeight()-t),h.css({width:c.tooltip_width,height:c.tooltip_height,display:"none"}),c=a.extend(b.data("Zebra_Tooltip"),c),b.data("Zebra_Tooltip",c)}if(c.sticky&&!c.close&&(jQuery("<a>",{"class":"Zebra_Tooltip_Close",href:"javascript:void(0)"}).html("x").bind("click",function(a){a.preventDefault();var c=b.data("Zebra_Tooltip");c.sticky=!1,b.data("Zebra_Tooltip",c),l(b)}).appendTo(c.message),c.close=!0,c=a.extend(b.data("Zebra_Tooltip"),c),b.data("Zebra_Tooltip",c)),c.window_resized||c.window_scrolled){var u=a(window);if(c.window_resized){d=u.width(),e=u.height();var v=b.offset();a.extend(c,{element_left:v.left,element_top:v.top,element_width:b.outerWidth(),element_height:b.outerHeight()})}g=u.scrollTop(),f=u.scrollLeft();var w="left"==i.settings.position?c.element_left-c.tooltip_width+c.arrow_width:"right"==i.settings.position?c.element_left+c.element_width-c.arrow_width:c.element_left+(c.element_width-c.tooltip_width)/2,x=c.element_top-c.tooltip_height,y="left"==i.settings.position?c.tooltip_width-c.arrow_width-c.arrow_width/2:"right"==i.settings.position?c.arrow_width/2:(c.tooltip_width-c.arrow_width)/2;w+c.tooltip_width>d+f&&(y-=d+f-(w+c.tooltip_width)-6,w=d+f-c.tooltip_width-6,y+c.arrow_width>c.tooltip_width-6&&(y=c.tooltip_width-6-c.arrow_width),w+y+c.arrow_width/2<c.element_left&&(y=-1e4)),f>w&&(y-=f-w,w=f+2,0>y&&(y=c.arrow_width/2),w+y+c.arrow_width/2>c.element_left+c.element_width&&(y=-1e4)),c.arrow_container.removeClass("Zebra_Tooltip_Arrow_Top"),c.arrow_container.addClass("Zebra_Tooltip_Arrow_Bottom"),c.message.css("margin-top",""),c.arrow.css("borderColor",i.settings.background_color+" transparent transparent"),g>x||"below"==i.settings.default_position&&c.element_top+c.element_height+i.settings.vertical_offset+c.tooltip_height+c.animation_offset<e+g?(x=c.element_top+c.element_height-i.settings.vertical_offset,c.animation_offset=Math.abs(c.animation_offset),c.message.css("margin-top",c.arrow_height/2),c.arrow_container.removeClass("Zebra_Tooltip_Arrow_Bottom"),c.arrow_container.addClass("Zebra_Tooltip_Arrow_Top"),c.arrow.css("borderColor","transparent transparent "+i.settings.background_color)):(c.animation_offset=-Math.abs(c.animation_offset),x+=i.settings.vertical_offset),c.arrow_container.css("left",y),c.tooltip.css({left:w,top:x}),a.extend(c,{tooltip_left:w,tooltip_top:x,arrow_left:y}),c.window_resized=!1,c.window_scrolled=!1,c=a.extend(b.data("Zebra_Tooltip"),c),b.data("Zebra_Tooltip",c)}return c},l=function(b){var c=b.data("Zebra_Tooltip");clearTimeout(c.hide_timeout),c.sticky||(clearTimeout(c.show_timeout),c.hide_timeout=setTimeout(function(){c.tooltip&&(i.settings.onBeforeHide&&"function"==typeof i.settings.onBeforeHide&&i.settings.onBeforeHide(b,c.tooltip),c.close=!1,c.destroy&&(c.muted=!0),b.data("Zebra_Tooltip",c),a("a.Zebra_Tooltip_Close",c.tooltip).remove(),c.tooltip.stop(),c.tooltip.animate({opacity:0,top:c.tooltip_top+c.animation_offset},i.settings.animation_speed,function(){a(this).css("display","none"),i.settings.onHide&&"function"==typeof i.settings.onHide&&i.settings.onHide(b,c.tooltip)}))},i.settings.hide_delay))},m=function(a){var b=a.data("Zebra_Tooltip");clearTimeout(b.show_timeout),b.muted||(clearTimeout(b.hide_timeout),b.show_timeout=setTimeout(function(){b=k(a),i.settings.onBeforeShow&&"function"==typeof i.settings.onBeforeShow&&i.settings.onBeforeShow(a,b.tooltip),"block"!=b.tooltip.css("display")&&b.tooltip.css({top:b.tooltip_top+b.animation_offset}),b.tooltip.css("display","block"),b.tooltip.stop(),b.tooltip.animate({top:b.tooltip_top,opacity:i.settings.opacity},i.settings.animation_speed,function(){i.settings.onShow&&"function"==typeof i.settings.onShow&&i.settings.onShow(a,b.tooltip)})},i.settings.show_delay))};j()}}(jQuery);