/*
 * jQuery ToolTip pour les InfoStratèges.
 * Script original :
 * Sam Collett (http://www.texotela.co.uk)
 */
$.fn.ToolTip = function()
{
	this.mouseover(
		function(e)
		{
			//if(!this.tooltipset) return;
			// get mouse coordinates
			// based on code from http://www.quirksmode.org/js/events_properties.html
			var mouseX = e.pageX || (e.clientX ? e.clientX + document.body.scrollLeft : 0);
			var mouseY = e.pageY || (e.clientY ? e.clientY + document.body.scrollTop : 0);
			mouseX += 10;
			mouseY += 10;
			// if there is no div containing the tooltip
			if(!this.tooltipdiv)
			{
				// create a div and style it
				var div = document.createElement("div");
				this.tooltipdiv = div;
				
				var texte = "";
				if(!this.title) texte = "Lien vers la définition de ce mot<br>et les articles associés.";
				else texte = this.title;
				
				var titre = "";
				if(!this.rel) titre = "Hypertag :";
				else titre = this.rel;
				
				$(div).html("<b>"+titre+"</b><br><span>"+texte+"</span>");
				$(div).addClass("htagtip");
				$("body").append(div);
				this.tooltipset = true;
			}
			$(this.tooltipdiv).show().css({left: mouseX + "px", top: mouseY + 3 + "px"});
		}
	).mouseout(
		function()
		{
			if(this.tooltipdiv)
			{
				$(this.tooltipdiv).hide();
			}
		}
	);
	return this;
}