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

