/****************************************************/
/*				FIX MENU DEROULANT IE				*/
/****************************************************/
var showObject;
function initSurvol() {
	// création du conteneur de réception des contenus
	// création du conteneur de zoom
	var conteneurZoom = document.createElement('div');
	conteneurZoom.id = 'trailimageid';
	document.body.appendChild(conteneurZoom);
	 showObject = document.getElementById('trailimageid');
	// récupération de tous les LI
	var tabLi = document.getElementById('conteneur').getElementsByTagName('LI');
	var tabUtil = new Array();
	for(var itli=0; itli<tabLi.length; itli++) {
		// test pour ne conserver que les LI d'arbo (class PAIR ou IMPAIR
		if(tabLi[itli].className.match(/pair/g)) {
			for(var itli2=0; itli2<tabLi[itli].childNodes.length; itli2++) {
				// au survol des strong on doit afficher les div
				if(tabLi[itli].childNodes[itli2].nodeName == 'STRONG') {
					var eltASurvoler = tabLi[itli].childNodes[itli2];
				}
				if((tabLi[itli].childNodes[itli2].nodeName == 'DIV') && (tabLi[itli].childNodes[itli2].className == 'infobulle')) {
					var eltAAfficher = tabLi[itli].childNodes[itli2];
				}
				eltASurvoler.eltAAfficher = eltAAfficher;
				eltASurvoler.onmouseover = function() {
					//showObject = this.eltAAfficher;
					putContent(this.eltAAfficher);
					document.onmousemove=followmouse;
				}
				eltASurvoler.onmouseout = function() {
					//showObject = this.eltAAfficher;
					document.onmousemove=killfollowmouse;
				}
			}
		}
	}
}

var offsetfrommouse=[15,15]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset
var hScreenSecurity = 700;
var vScreenSecurity = 200;

function putContent(elt) {
	showObject.innerHTML = elt.innerHTML;
}

function truebody(){
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function killfollowmouse(e) {
	showObject.style.left = "-999em";
}

function followmouse(e){
	var xcoord=offsetfrommouse[0];
	var ycoord=offsetfrommouse[1]

	var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15;
	var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(window.innerHeight)

	if (typeof e != "undefined"){	// MOZILLA
		if (docwidth - e.pageX < hScreenSecurity){
			xcoord = e.pageX - (xcoord + hScreenSecurity - 350); // Move to the left side of the cursor
		} else {
			xcoord += e.pageX;
		}
		if (docheight - e.pageY < (10 + vScreenSecurity)){
			ycoord += e.pageY - Math.max(0,(vScreenSecurity + 10 + e.pageY - docheight - truebody().scrollTop));
		} else {
			ycoord += e.pageY;
		}
	} else if (typeof window.event != "undefined"){		// IE
		if (docwidth - event.clientX < hScreenSecurity){
			xcoord = event.clientX + truebody().scrollLeft - (xcoord + hScreenSecurity - 350); // Move to the left side of the cursor
		} else {
			xcoord += truebody().scrollLeft+event.clientX
		}
		if (docheight - event.clientY < (10 + vScreenSecurity)){
			ycoord += event.clientY + truebody().scrollTop - Math.max(0,(vScreenSecurity + 10 + event.clientY - docheight));
		} else {
			ycoord += truebody().scrollTop + event.clientY;
		}
	}
	
	showObject.style.left = xcoord+"px";
	showObject.style.top = ycoord+"px";
}



/****************************************************/
/*				INITIALISATION DE LA PAGE			*/
/****************************************************/
function addLoadListenerSurvol(func) {
	if (window.addEventListener) {
		window.addEventListener("load", func, false);
	} else if (document.addEventListener) {
		document.addEventListener("load", func, false);
	} else if (window.attachEvent) {
		window.attachEvent("onload", func);
	}
}

if (document.getElementById && document.createTextNode) {
	addLoadListenerSurvol(function() {
		initSurvol();
	});
}
