var ns4=(document.layers)? true : false;
var ns6=(document.getElementById)? true : false;
var ie4=(document.all)? true : false;
var ie5=false;
if(ie4){
	if((navigator.userAgent.indexOf('MSIE 5') > 0)||
		(navigator.userAgent.indexOf('MSIE 6')> 0)){
		ie5=true;
	}
	if(ns6){
		ns6=false;
	}
}

var x=0; 
var y=0;
var longueur = 0;
var contenu = "";

if (ns4) { 
	document.captureEvents(Event.MOUSEMOVE); 
}
document.onmousemove = foncAlt;

function showAlt(txt) {
	contenu = "<div>";
	contenu = contenu + unescape(txt) + "</div>"; 
	longueur = getWidthDiv(unescape(txt));
	creaAlt(contenu);
}

function getWidthDiv(txt) {
	var result =0;
	var re = new RegExp ('<br/>', 'gi') ;
	var textetmp= txt.replace(re,'<BR/>');
	var re2 = new RegExp ('&eacute;', 'gi') ;
	var texte= textetmp.replace(re2,'e');
	var lignes = texte.split("<BR/>");
	for (i = 0;i < lignes.length;i++) {
		if (lignes[i].length > result) {
			result = lignes[i].length;
		}
	}
	return result * 5;
}
function creaAlt(contenu) {
	if (ie4 || ie5) {
		window.ALTdHTML.innerHTML = contenu;
//		window.ALTdHTML.style.visibility = 'visible';
	}
        if (ns4) {
                document.layers["ALTdHTML"].document.write(contenu);
                document.layers["ALTdHTML"].document.close();
                document.layers.ALTdHTML.visibility='show';
        }
        if (ns6) {
                document.getElementById("ALTdHTML").innerHTML = contenu;
                document.getElementById("ALTdHTML").style.visibility = 'visible';
        }
}
LIMIT =160;

function foncAlt(evt) {
	if (ie4 || ie5) {
                var bodyScrolltop = 0;
                var bodyScrollleft = 0;
                var bodyClientWidth = 0;
                if (document.body && document.body.scrollTop > 0) {       
                // IE5 or DTD 3.2
                        bodyScrolltop = document.body.scrollTop;
                } else if (document.documentElement && !(document.documentElement.scrollTop > 0)) {
                // IE6 +4.01 but no scrolling going on
                } else if (document.documentElement && document.documentElement.scrollTop > 0) {
                // IE6 +4.01 and user has scrolled
                        bodyScrolltop = document.documentElement.scrollTop;
                }
                if (document.body && document.body.scrollLeft > 0) {       
                // IE5 or DTD 3.2
                        bodyScrollleft = document.body.scrollLeft;
                } else if (document.documentElement && !(document.documentElement.scrollLeft > 0)) {
                // IE6 +4.01 but no scrolling going on
                } else if (document.documentElement && document.documentElement.scrollLeft > 0) {
                // IE6 +4.01 and user has scrolled
                        bodyScrollleft = document.documentElement.scrollLeft;
                }
                bodyClientWidth = document.body.clientWidth;
		y = event.clientY + bodyScrolltop;
		x = event.clientX + bodyScrollleft;
                var lg = x + 10;
//		if (longueur) {
//			x = window.ALTdHTML.style.left.substr(0,window.ALTdHTML.style.left.indexOf("px")) * 1;
//			if (bodyClientWidth > 0) {
//                                if (x  > (bodyClientWidth - longueur)) {
//                                        if ((x - longueur) < 0) {
//                                                window.ALTdHTML.style.left = 0 + "px";
//                                        } else {
//                                                lg = x - longueur;
//                                                window.ALTdHTML.style.left = lg + "px";
//                                        }
//                                } else {
//                                        window.ALTdHTML.style.left = lg + "px";
//                                }
//                        } else {
//                                window.ALTdHTML.style.left = lg + "px";
//                        }
//                } else {
                        window.ALTdHTML.style.left = lg + "px";
//		}
		heightForm = window.ALTdHTML.clientHeight;
		y = bodyScrolltop + event.clientY - (heightForm / 2);
		if (y < (bodyScrolltop + 10)) {
			y = bodyScrolltop + 10;
		}
                var ht = y + 5;
	  	window.ALTdHTML.style.top = ht + "px";
		window.ALTdHTML.style.visibility = 'visible';
	}
	if (ns4) {
		x = (navigator.appName.substring(0,3) == "Net") ? evt.pageX : event.x + document.body.scrollLeft;
		y = (navigator.appName.substring(0,3) == "Net") ? evt.pageY : event.y + document.body.scrollTop;
                var lg = x + 10;
		document.layers.ALTdHTML.left = lg + "px";
                var ht = x + 14;
		document.layers.ALTdHTML.top = ht + "px";
	}
	if (ns6) {
		x = evt.clientX + document.documentElement.scrollLeft; 
		heightForm = document.getElementById("ALTdHTML").clientHeight;
		y = document.documentElement.scrollTop + evt.clientY - (heightForm / 2);
		if (y < (document.documentElement.scrollTop + 10)) {
			y = document.documentElement.scrollTop + 10;
		}
                var lg = x + 10;
	  	document.getElementById("ALTdHTML").style.left = lg + "px";
	  	document.getElementById("ALTdHTML").style.top = y + "px";
	}
}
function hideAlt() {
	if (ie4 || ie5) {
		window.ALTdHTML.style.visibility = 'hidden';
		window.ALTdHTML.innerHTML = "";
		longueur = 0;
	}else if (ns4) {
		document.layers.ALTdHTML.visibility = 'hide';
		document.layers["ALTdHTML"].document.write("");
		document.layers["ALTdHTML"].document.close();
	}else if (ns6) {
		document.getElementById("ALTdHTML").style.visibility = 'hidden';
		document.getElementById("ALTdHTML").innerHTML = "";
		longueur = 0;
	}
}
