(function(n){n.fn.tipTip=function(t){var e={activation:"hover",keepAlive:!1,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:"",enter:function(){},exit:function(){}},i=n.extend(e,t);if(n("#tiptip_holder").length<=0){var r=n('<div id="tiptip_holder" style="max-width:'+i.maxWidth+';"><\/div>'),f=n('<div id="tiptip_content"><\/div>'),u=n('<div id="tiptip_arrow"><\/div>');n("body").append(r.html(f).prepend(u.html('<div id="tiptip_arrow_inner"><\/div>')))}else var r=n("#tiptip_holder"),f=n("#tiptip_content"),u=n("#tiptip_arrow");return this.each(function(){var t=n(this),s,e;if(s=i.content?i.content:t.attr(i.attribute),s!=""&&t.attr(i.attribute)!=undefined){i.content||t.removeAttr(i.attribute),e=!1,i.activation=="hover"?(t.hover(function(){h()},function(){i.keepAlive||o()}),i.keepAlive&&r.hover(function(){},function(){o()})):i.activation=="focus"?t.focus(function(){h()}).blur(function(){o()}):i.activation=="click"&&(t.click(function(){return h(),!1}).hover(function(){},function(){i.keepAlive||o()}),i.keepAlive&&r.hover(function(){},function(){o()}));function h(){var nt,tt,k,d;i.enter.call(this),f.html(s),r.hide().removeAttr("class").css("margin","0"),u.removeAttr("style");var c=parseInt(t.offset().top),a=parseInt(t.offset().left),it=parseInt(t.outerWidth()),y=parseInt(t.outerHeight()),v=r.outerWidth(),l=r.outerHeight(),b=Math.round((it-v)/2),rt=Math.round((y-l)/2),p=Math.round(a+b),h=Math.round(c+y+i.edgeOffset),o="",w="",g=Math.round(v-12)/2;i.defaultPosition=="bottom"?o="_bottom":i.defaultPosition=="top"?o="_top":i.defaultPosition=="left"?o="_left":i.defaultPosition=="right"&&(o="_right"),nt=b+a<parseInt(n(window).scrollLeft()),tt=v+a>parseInt(n(window).width()),nt&&b<0||o=="_right"&&!tt||o=="_left"&&a<v+i.edgeOffset+5?(o="_right",w=Math.round(l-13)/2,g=-12,p=Math.round(a+it+i.edgeOffset),h=Math.round(c+rt)):(tt&&b<0||o=="_left"&&!nt)&&(o="_left",w=Math.round(l-13)/2,g=Math.round(v),p=Math.round(a-(v+i.edgeOffset+5)),h=Math.round(c+rt)),k=c+y+i.edgeOffset+l+8>parseInt(n(window).height()+n(window).scrollTop()),d=c+y-(i.edgeOffset+l+8)<0,k||o=="_bottom"&&k||o=="_top"&&!d?(o=o=="_top"||o=="_bottom"?"_top":o+"_top",w=l,h=Math.round(c-(l+5+i.edgeOffset))):(d|(o=="_top"&&d)||o=="_bottom"&&!k)&&(o=o=="_top"||o=="_bottom"?"_bottom":o+"_bottom",w=-12,h=Math.round(c+y+i.edgeOffset)),o=="_right_top"||o=="_left_top"?h=h+5:(o=="_right_bottom"||o=="_left_bottom")&&(h=h-5),(o=="_left_top"||o=="_left_bottom")&&(p=p+5),u.css({"margin-left":g+"px","margin-top":w+"px"}),r.css({"margin-left":p+"px","margin-top":h+"px"}).attr("class","tip"+o),e&&clearTimeout(e),e=setTimeout(function(){r.stop(!0,!0).fadeIn(i.fadeIn)},i.delay)}function o(){i.exit.call(this),e&&clearTimeout(e),r.fadeOut(i.fadeOut)}}})}})(jQuery);