 /*
 * TipTip
 * Copyright 2010 Drew Wilson
 * www.drewwilson.com
 * code.drewwilson.com/entry/tiptip-jquery-plugin
 *
 * Version 1.3   -   Updated: Mar. 23, 2010
 *
 * This Plug-In will create a custom tooltip to replace the default
 * browser tooltip. It is extremely lightweight and very smart in
 * that it detects the edges of the browser window and will make sure
 * the tooltip stays within the current window size. As a result the
 * tooltip will adjust itself to be displayed above, below, to the left 
 * or to the right depending on what is necessary to stay within the
 * browser window. It is completely customizable as well via CSS.
 *
 * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */

(function($){$.fn.tipTip=function(_1){var _2={activation:"hover",keepAlive:false,maxWidth:"200px",edgeOffset:3,defaultPosition:"bottom",delay:400,fadeIn:200,fadeOut:200,attribute:"title",content:false,enter:function(){},exit:function(){}};var _3=$.extend(_2,_1);if($("#tiptip_holder").length<=0){var _4=$("<div id=\"tiptip_holder\" style=\"max-width:"+_3.maxWidth+";\"></div>");var _5=$("<div id=\"tiptip_content\"></div>");var _6=$("<div id=\"tiptip_arrow\"></div>");$("body").append(_4.html(_5).prepend(_6.html("<div id=\"tiptip_arrow_inner\"></div>")));}else{var _4=$("#tiptip_holder");var _5=$("#tiptip_content");var _6=$("#tiptip_arrow");}return this.each(function(){var _7=$(this);if(_3.content){var _8=_3.content;}else{var _8=_7.attr(_3.attribute);}if(_8!=""){if(!_3.content){_7.removeAttr(_3.attribute);}var _9=false;if(_3.activation=="hover"){_7.hover(function(){_a();},function(){if(!_3.keepAlive){_b();}});if(_3.keepAlive){_4.hover(function(){},function(){_b();});}}else{if(_3.activation=="focus"){_7.focus(function(){_a();}).blur(function(){_b();});}else{if(_3.activation=="click"){_7.click(function(){_a();return false;}).hover(function(){},function(){if(!_3.keepAlive){_b();}});if(_3.keepAlive){_4.hover(function(){},function(){_b();});}}}}function _a(){_3.enter.call(this);_5.html(_8);_4.hide().removeAttr("class").css("margin","0");_6.removeAttr("style");var _c=parseInt(_7.offset()["top"]);var _d=parseInt(_7.offset()["left"]);var _e=parseInt(_7.outerWidth());var _f=parseInt(_7.outerHeight());var _10=_4.outerWidth();var _11=_4.outerHeight();var _12=Math.round((_e-_10)/2);var _13=Math.round((_f-_11)/2);var _14=Math.round(_d+_12);var _15=Math.round(_c+_f+_3.edgeOffset);var _16="";var _17="";var _18=Math.round(_10-12)/2;if(_3.defaultPosition=="bottom"){_16="_bottom";}else{if(_3.defaultPosition=="top"){_16="_top";}else{if(_3.defaultPosition=="left"){_16="_left";}else{if(_3.defaultPosition=="right"){_16="_right";}}}}var _19=(_12+_d)<parseInt($(window).scrollLeft());var _1a=(_10+_d)>parseInt($(window).width());if((_19&&_12<0)||(_16=="_right"&&!_1a)||(_16=="_left"&&_d<(_10+_3.edgeOffset+5))){_16="_right";_17=Math.round(_11-13)/2;_18=-12;_14=Math.round(_d+_e+_3.edgeOffset);_15=Math.round(_c+_13);}else{if((_1a&&_12<0)||(_16=="_left"&&!_19)){_16="_left";_17=Math.round(_11-13)/2;_18=Math.round(_10);_14=Math.round(_d-(_10+_3.edgeOffset+5));_15=Math.round(_c+_13);}}var _1b=(_c+_f+_3.edgeOffset+_11+8)>parseInt($(window).height()+$(window).scrollTop());var _1c=((_c+_f)-(_3.edgeOffset+_11+8))<0;if(_1b||(_16=="_bottom"&&_1b)||(_16=="_top"&&!_1c)){if(_16=="_top"||_16=="_bottom"){_16="_top";}else{_16=_16+"_top";}_17=_11;_15=Math.round(_c-(_11+5+_3.edgeOffset));}else{if(_1c|(_16=="_top"&&_1c)||(_16=="_bottom"&&!_1b)){if(_16=="_top"||_16=="_bottom"){_16="_bottom";}else{_16=_16+"_bottom";}_17=-12;_15=Math.round(_c+_f+_3.edgeOffset);}}if(_16=="_right_top"||_16=="_left_top"){_15=_15+5;}else{if(_16=="_right_bottom"||_16=="_left_bottom"){_15=_15-5;}}if(_16=="_left_top"||_16=="_left_bottom"){_14=_14+5;}_6.css({"margin-left":_18+"px","margin-top":_17+"px"});_4.css({"margin-left":_14+"px","margin-top":_15+"px"}).attr("class","tip"+_16);if(_9){clearTimeout(_9);}_9=setTimeout(function(){_4.stop(true,true).fadeIn(_3.fadeIn);},_3.delay);};function _b(){_3.exit.call(this);if(_9){clearTimeout(_9);}_4.fadeOut(_3.fadeOut);};}});};})(jQuery);
