var RichTooltip =
{
	init: function()
	{
		var descs = Core.getElementsByClass("hoverTitle");
		
		for (var i=0; i < descs.length; i++)
		{
			var title =  descs[i].title;
			
			if (title && title.length > 0)
			{
				Core.addEventListener(descs[i], "mouseover", RichTooltip.showTipListener);
				Core.addEventListener(descs[i], "mouseout", RichTooltip.hideTipListener);
				Core.addEventListener(descs[i], "focus", RichTooltip.showTipListener);
				Core.addEventListener(descs[i], "blur", RichTooltip.hideTipListener);
			}
		}
	},
	
	showTipListener: function(event)
	{
		RichTooltip.showTip(this);
		Core.preventDefault(event);
	},
	
	hideTipListener: function(event)
	{
		RichTooltip.hideTip(this);
	},
	
	showTip: function(link)
	{
		RichTooltip.hideTip(link);
		var tip = document.createElement("span");
		tip.className = "tooltip";
		var tipText = document.createTextNode(link.title);
		tip.appendChild(tipText);
		link.appendChild(tip);
		
		link._tooltip = tip;
		link.title = "";
		
		//Fix for Safari2/Opera9 repaint issue
		document.documentElement.style.position = "relative";
	},
	
	hideTip: function(link)
	{
		if (link._tooltip)
		{
			link.title = link._tooltip.childNodes[0].nodeValue;
			link.removeChild(link._tooltip);
			link._tooltip = null;
			
			//Fix for Safari2/Opera9 repaint issue
			document.documentElement.style.position = "static";
		}
	}
}
Core.start(RichTooltip);
