/*
 * jQuery easy-tooltip plugin
 * Examples and documentation at: http://www.easy-tuts.com/downloads/jquery-plugins/
 * version 1.0 (09-MAR-2011)
 * Requires jQuery v1.4.3 or later
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Author: alexander@easy-tuts.com
 */

(function($){$.fn.tooltip=function(o){if(this.length==0){if(!$.isReady&&this.selector){var s=this.selector,c=this.context;$(function(){$(s,c).tooltip(o);});}return this;}$(document).ready(function(){$('[data-tooltipfor]').each(function(){var height,width,$tip=$(this),$elem;$tip.hide();if($tip.html()==''){$tip.remove();return;}height=$tip.outerHeight();width=$tip.outerWidth();$elem=$('#'+$tip.data('tooltipfor'));$tip.appendTo('body').css('position','absolute');$elem.mousemove(function(e){var documentSize={},left=e.pageX+12,top=e.pageY+12;documentSize.width=parseInt($(window).width()+$(window).scrollLeft());documentSize.height=parseInt($(window).height()+$(window).scrollTop());if(top+height>documentSize.height&&top-12-height>=0){top=top-12-height;}if(left+width>documentSize.width&&left-12-width>=0){left=left-12-width;}$tip.css({top:top,left:left});}).hover(function(e){var documentSize={},left=e.pageX+12,top=e.pageY+12;documentSize.width=parseInt($(window).width()+$(window).scrollLeft());documentSize.height=parseInt($(window).height()+$(window).scrollTop());if(top+height>documentSize.height&&top-12-height>=0){top=top-12-height;}if(left+width>documentSize.width&&left-12-width>=0){left=left-12-width;}$tip.css({top:top,left:left});$tip.fadeIn('medium');},function(){$tip.delay(100).queue(function(){$(this).stop().fadeOut('fast');});});});});return this.each(function(){var $this=$(this),$span=$('<span />'),title=$(this).attr('title'),height,width;if(title!=''){if(o===undefined){o={};}if(o.animation!==undefined&&o.animationIn===undefined&&o.animationOut===undefined){o.animationIn=o.animation;o.animationOut=o.animation;}if(o.duration!==undefined&&o.durationIn===undefined&&o.durationOut===undefined){o.durationIn=o.duration;o.durationOut=o.duration;}if(o.animationIn===undefined){o.animationIn='fade';}if(o.durationIn===undefined){o.durationIn='medium';}if(o.animationOut===undefined){o.animationOut='none';}if(o.durationOut===undefined){o.durationOut='fast';}if(o.delay===undefined){o.delay=0;}$span.appendTo('body');$span.hide();$this.attr('title','');if(o.className!==undefined){$span.addClass(o.className);}else{$span.addClass('easy-tooltip-default');}if(o.separator!==undefined){var indexSep=title.indexOf(o.separator);if(indexSep!=-1&&indexSep!=0&&indexSep!=title.length-indexSep.length){title='<span class="easy-tooltip-title">'+title.substring(0,indexSep)+'</span>'+title.substring(indexSep+o.separator.length);}}$span.css(o).html(title).css('position','absolute');height=$span.outerHeight();width=$span.outerWidth();$this.mousemove(function(e){var documentSize={},left=e.pageX+12,top=e.pageY+12;documentSize.width=parseInt($(window).width()+$(window).scrollLeft());documentSize.height=parseInt($(window).height()+$(window).scrollTop());if(top+height>documentSize.height&&top-12-height>=0){top=top-12-height;}if(left+width>documentSize.width&&left-12-width>=0){left=left-12-width;}$span.css({top:top,left:left});}).hover(function(e){var documentSize={},left=e.pageX+12,top=e.pageY+12;documentSize.width=parseInt($(window).width()+$(window).scrollLeft());documentSize.height=parseInt($(window).height()+$(window).scrollTop());if(top+height>documentSize.height&&top-12-height>=0){top=top-12-height;}if(left+width>documentSize.width&&left-12-width>=0){left=left-12-width;}$span.css({top:top,left:left});if(o.animationIn=='none'){$span.show();}if(o.animationIn=='fade'){$span.stop().fadeIn(o.durationIn);}if(o.animationIn=='slide'){var h=$span.height();if(e.pageY+12+h>documentSize.height&&e.pageY-h>=0){$span.css({height:0,top:top+h}).show().stop().animate({height:h,top:top},o.durationIn);}else{$span.css({height:0}).show().stop().animate({height:h},o.durationIn);}}},function(e){var documentSize={},left=e.pageX+12,top=e.pageY+12;documentSize.width=parseInt($(window).width()+$(window).scrollLeft());documentSize.height=parseInt($(window).height()+$(window).scrollTop());if(o.animationOut=='none'){$span.delay(o.delay).queue(function(){$(this).stop().hide();});}if(o.animationOut=='fade'){$span.delay(o.delay).queue(function(){$(this).stop().fadeOut(o.durationOut);});}if(o.animationOut=='slide'){var h=$span.outerHeight();h2=$span.height();if(e.pageY+12+h>documentSize.height&&e.pageY-h>=0){$span.delay(o.delay).queue(function(){$(this).stop().animate({height:0,top:top+h},o.durationOut,function(){$(this).hide().css({height:h2,top:top});});});}else{$span.delay(o.delay).queue(function(){$(this).stop().animate({height:0},o.durationOut,function(){$(this).hide().css({height:h2});});});}}});}});}})(jQuery);
