// Auteur : Rouches Benoît

function imgTip(container,options)
{
	var container = document.getElementById(container);
	var images = container.getElementsByTagName('img');
	var nb = images.length;
	var options;	
	
	this.init = function()
	{
		for(var i = 0 ; i < nb ; i++)
		{
			create(images[i]);
			images[i].onmouseover = function() { printTip(this) };
			images[i].parentNode.lastChild.onmouseover = function() {  printTip(this) };
			images[i].onmouseout = function() { hideTip(this) };
			images[i].parentNode.lastChild.onmouseout = function() { hideTip(this) };
		}	
	};

	function create(image)
	{
		var span = document.createElement('span');
		span.setAttribute("style","display:block;float:left;position:relative;cursor:pointer");
		if (document.all) /* ie 6 */
		span.style.setAttribute("cssText","display:block;float:left;position:relative;cursor:pointer");
		
		var icon = image.cloneNode(true);
				
		var tip = document.createElement('span');
		tip.appendChild(document.createTextNode(options.tipTxt));
		tip.setAttribute("style","display:none;position:absolute;" + options.tipPosition + "");
		tip.setAttribute("class",options.tipCls);
		
		/* ie 6 */
		if (document.all)
		{
			tip.setAttribute("className",options.tipCls);
			tip.style.setAttribute("cssText","display:none;position:absolute;" + options.tipPosition + "");
		}
		
		span.appendChild(icon);
		span.appendChild(tip);
		
		image.parentNode.replaceChild(span,image);
	}
	
	function printTip(elmt)
	{
		var tip = elmt.parentNode.lastChild;
		tip.style.display = 'block';
	}
	
	function hideTip(elmt)
	{
		var tip = elmt.parentNode.lastChild;
		tip.style.display = 'none';
	}
}
