// JavaScript Document

function afficheEvt(elt, message) {
	var contenu =  message;

	document.getElementById(elt).innerHTML = contenu;
	document.getElementById(elt).style.display = "block";
}
function masqueEvt(elt) {
	document.getElementById(elt).style.display = "none";
}

function capture_souris(e) {
	var x = document.all ? event.clientX : e.pageX;
	var y = document.all ? event.clientY : e.pageY;	
	var pos = (document.body.scrollTop)?document.body.scrollTop:document.documentElement.scrollTop;
	var pos2 =document.all ? pos : 0;
	
	document.getElementById('aideForm').style.left = parseInt(x - 150) +  "px";
	document.getElementById('aideForm').style.top = parseInt(y + 20) + parseInt(pos2)+ "px";
}

function initAide(formulaire) {
	var evtAgenda = document.createElement('div');
	evtAgenda.id = "aideForm";
	evtAgenda.style.position = "absolute";
	evtAgenda.style.display = "none";
	document.body.appendChild(evtAgenda);
	
	var listeEvtsTemp = document.getElementById(formulaire).getElementsByTagName('a');
	var listeEvts = new Array();
	
	for(var iLE = 0; iLE<listeEvtsTemp.length; iLE++) {
		if(listeEvtsTemp[iLE].className == 'aide')
			listeEvts.push(listeEvtsTemp[iLE]);
	}
	for(var iLE2 = 0; iLE2<listeEvts.length; iLE2++) {
		var evtsLI = listeEvts[iLE2].getAttribute('title').split('\n');
		var htmlListe = '<ul>';
		for(var iLE3 = 0; iLE3<evtsLI.length; iLE3++) {
			htmlListe += '<li>'+evtsLI[iLE3]+'</li>';
		}
		htmlListe += '</ul>';
		listeEvts[iLE2].setAttribute('title','');
		listeEvts[iLE2].textHtml = htmlListe;
		listeEvts[iLE2].onmouseover = function() {
			afficheEvt('aideForm', this.textHtml);
		}
		listeEvts[iLE2].onmouseout = function() {
			masqueEvt('aideForm');
		}
	}
	
	if (document.layers || document.all) {					// récup des evt dans IE
		document.onmousemove = capture_souris;
	}
	if (document.addEventListener) {						// récup des evt dans Firefox
		document.addEventListener('mousemove', capture_souris, true);
	}
	window.onscroll=function(){
		masqueEvt('aideForm');
	}
}