var offsetxpoint=-25 //Customize x offset of tooltip
var offsetypoint=10 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false

	// PARAMETRES MODIFIABLES
var delaiAffBull=0
var delaiEffBull=100
var autoEffBull =10000
var razBull     =0

var textBull    =''
var Vitess      =100
var Opac        =100
var Opac_2      =1

var AffichBull=setTimeout('document.getElementById("infoBull").style.visibility="visible";',delaiAffBull);
clearTimeout(AffichBull);
var EffacBull=setTimeout('Vt=2;effacem()',delaiEffBull);
clearTimeout(EffacBull);
var EffacAutoBull=setTimeout('Vt=1;effacem()',autoEffBull);
clearTimeout(EffacAutoBull);
var tempo=setTimeout('if (Vt==1)Opac=Opac-9;if (Vt==2)Opac=Opac-24;effacem()',Vitess/10);
clearTimeout(tempo);

function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body
}

function infBul(thetext){
	if (thetext=='') { // Test de la présence du texte
		clearTimeout(AffichBull);
		clearTimeout(EffacBull);
		clearTimeout(EffacAutoBull);
		clearTimeout(tempo);
		EffacBull=setTimeout('Vt=2;effacem()',delaiEffBull);
	}
	if (thetext!='' && razBull==1) {
		razBull=0
	}
	if (thetext!='' && razBull==0) {
		Opac=100; Opac_2=1; razBull=1;
		AffichBull=setTimeout('document.getElementById("infoBull").style.visibility="visible";',delaiAffBull);
		EffacAutoBull=setTimeout('Vt=1;effacem()',autoEffBull);
		clearTimeout(EffacBull);
		if (ns6||ie){
			// Cadre de la bulle
			var filter=((ie)?'filter: alpha(opacity='+Opac+');':'opacity: '+Opac_2+';');
			document.getElementById("infoBull").innerHTML='<table cellpadding="0" cellspacing="0" style="border-collapse: collapse; '+filter+'">'+
			'<tr><td><div style="height:15px; width:100%; '+filter+'"><div style="position: relative; top: 15px;"><img src="images/null.gif" align="bottom" height="1px" width="100%" style="background: #FFFFFF;" border="0" alt="" /></div><div id="languette_haut" style="position:relative; height: 15px; width: 15px; top: 0px; left: 0px; z-index: 1001;" class="bulle_haut_gauche"></div></div></td></tr>'+
			'<tr><td class="normal" id="texte_bull" style="border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF; padding: 5px;"><nobr>'+thetext+'</nobr></td></tr>'+
			'<tr><td><div style="height:15px; width:100%; '+filter+'"><div style="position: relative; top: 0px;"><img src="images/null.gif" align="top" height="1px" width="100%" style="background: #FFFFFF;" border="0" alt="" /></div><div id="languette_bas" style="position:relative; height: 15px; width: 15px; top: -1px; left: 0px; z-index: 1010;" class="bulle_bas_gauche"></div></div></td></tr>'+
			'</table>';
			enabletip=true;
			afftext(thetext);
			//return false;
		}
	}
}

function positiontip(e){
	if (enabletip){
		var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
		var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
		//Find out how close the mouse is to the corner of the window
		var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
		var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;
		
		var leftedge=(offsetxpoint<0) ? offsetxpoint*(-1) : -1000 ;
		
		//if the horizontal distance isn't enough to accomodate the width of the context menu
		if (rightedge<document.getElementById("infoBull").offsetWidth)
			//move the horizontal position of the menu to the left by it's width
			document.getElementById("infoBull").style.left=ie ? ietruebody().scrollLeft+event.clientX-document.getElementById("infoBull").offsetWidth+"px" : window.pageXOffset+e.clientX-document.getElementById("infoBull").offsetWidth+"px";
		else if (curX<leftedge)
			document.getElementById("infoBull").style.left="5px";
		else
			//position the horizontal position of the menu where the mouse is positioned
			document.getElementById("infoBull").style.left=curX+offsetxpoint+"px";
		
		//same concept with the vertical position
		if (bottomedge<document.getElementById("infoBull").offsetHeight) {
			document.getElementById("infoBull").style.top=ie? ietruebody().scrollTop+event.clientY-document.getElementById("infoBull").offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-document.getElementById("infoBull").offsetHeight-offsetypoint+"px";
			if (document.getElementById("languette_haut")!=null) document.getElementById("languette_haut").className="bulle_vide";
			if (document.getElementById("languette_bas")!=null) {
				document.getElementById("languette_bas").className="bulle_bas";
				if (rightedge<document.getElementById("infoBull").offsetWidth) {
					document.getElementById("languette_bas").style.left=(document.getElementById("infoBull").offsetWidth-25)+"px";
				} else {
					document.getElementById("languette_bas").style.left="5px";
				}
			}
		} else {
			document.getElementById("infoBull").style.top=curY+offsetypoint+"px";
			if (document.getElementById("infoBull").innerHTML!="") {
				if (document.getElementById("languette_bas")!=null) document.getElementById("languette_haut").className="bulle_haut";
				if (document.getElementById("languette_haut")!=null) {
					document.getElementById("languette_bas").className="bulle_vide";
					if (rightedge<document.getElementById("infoBull").offsetWidth) {
						document.getElementById("languette_haut").style.left=(document.getElementById("infoBull").offsetWidth-25)+"px";
					} else {
						document.getElementById("languette_haut").style.left="5px";
					}
				}
			}
		}
		document.getElementById("infoBull").style.visibility="visible";
	}
}

function afftext(text) {
	if (text!='') {
		textBull=text
	}
}

function effacem() {
	// Cadre de la bulle
	var filter=((ie)?'filter: alpha(opacity='+Opac+');':'opacity: '+Opac_2+';');
	var cadreBull=(( document.getElementById("languette_haut")!=null && document.getElementById("languette_bas")!=null )?
		'<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; '+filter+'">'+
		'<tr><td><div style="height:15px; width:100%; '+filter+'"><div style="position: relative; top: 15px;"><img src="images/null.gif" align="bottom" height="1px" width="100%" style="background: #FFFFFF;" border="0" alt="" /></div><div id="languette_haut" style="position:relative; height: 15px; width: 15px; top: 0px; left: '+document.getElementById("languette_haut").style.left+'px; z-index: 1001;" class="'+document.getElementById("languette_haut").className+'"></div></div></td></tr>'+
		'<tr><td class="normal" style="border-left: 1px solid #FFFFFF; border-right: 1px solid #FFFFFF; padding: 5px;"><nobr>'+textBull+'</nobr></td></tr>'+
		'<tr><td><div style="height:15px; width:100%; '+filter+'"><div style="position: relative; top: 0px;"><img src="images/null.gif" align="top" height="1px" width="100%" style="background: #FFFFFF;" border="0" alt="" /></div><div id="languette_bas" style="position:relative; height: 15px; width: 15px; top: -1px; left: '+document.getElementById("languette_bas").style.left+'px; z-index: 1010;" class="'+document.getElementById("languette_bas").className+'"></div></div></td></tr>'+
		'</table>'
		:''
	);
	document.getElementById("infoBull").innerHTML=cadreBull;
	if (ie) tempo=setTimeout('if (Vt==1)Opac=Opac-9;if (Vt==2)Opac=Opac-24;effacem()',Vitess/10)
	else tempo=setTimeout('if (Vt==1)Opac_2=Opac_2-0.1;if (Vt==2)Opac_2=Opac_2-0.2;effacem()',Vitess/10)
	if (Opac <= 0 || Opac_2 <= 0) {
		clearTimeout(AffichBull);
		clearTimeout(EffacBull);
		clearTimeout(EffacAutoBull);
		clearTimeout(tempo)
		document.getElementById("infoBull").innerHTML="";
		enabletip=false;
		razBull=0;
		textBull='';
		Opac=100;
		Opac_2=1;
	}
}

document.onmousemove=positiontip;

