// ===================================
// Scripts de gestion des infos-bulles
// ===================================

// ===================================================================================
// Initialisations globales
var vPosX, vPosY;
var ie = (document.all); // IE 4+
var nn = (document.layers); // NN4
var mz = (!document.all && document.getElementById); // NN6+, MZ (Gecko)
if (nn) ZoneIB = document.InfoBulle;
if (ie) ZoneIB = InfoBulle.style;
if (mz) ZoneIB = document.getElementById("InfoBulle").style;
if (nn) document.captureEvents(Event.MOUSEMOVE);
window.onscroll=HideIB;
vFW_Active=false;
document.onmousedown=FW_Init;
document.onmouseup=Function("vFW_Active=false");
document.onmousemove=CatchMouse;

// ===================================================================================
// Afficher info-bulle
function ShowIB(w_msg,w_title)
{
	var w_content = "<table cellpadding=\"2\" cellspacing=\"0\"><tr><td class=\"ifb_title\">" + w_title + "</td></tr><tr><td class=\"ifb_text\">" + w_msg + "</td></tr></table>";
	if (ie) // IE
	{ 
		document.all("InfoBulle").innerHTML = w_content;
		ZoneIB.visibility = "visible";
	}
	else // Netscape
	{
		if (nn)
		{
			ZoneIB.document.write(w_content);
			ZoneIB.document.close();
			ZoneIB.visibility = "visible";
		}
		else // Moz
		{
			document.getElementById("InfoBulle").innerHTML=w_content;
			document.getElementById("InfoBulle").style.visibility="visible";
		}
	}
}

// ===================================================================================
// Récupération position curseur
function CatchMouse(e) 
{
	try
	{
		// -----------------------------------------------------------------------------------
		// Gestion de la zone Info-Bulle
		var x = (ie) ? event.x+document.body.scrollLeft : e.pageX; 
		var y = (ie) ? event.y+document.documentElement.scrollTop : e.pageY;
		vPosX = x;
		vPosY = y;
		ZoneIB.top = ( (ie) || (nn) ) ? y + 20 : eval(y + 20 - document.body.scrollTop) + "px";
		ZoneIB.left = eval(x - 60) + "px";

		// -----------------------------------------------------------------------------------
		// Gestion de la zone fenêtre flottante
		if (!vFW_Active) return;
		vFW.style.left= (ie) ? nowX+event.clientX-offsetx : eval(nowX + e.clientX - offsetx) + 'px'; 
		vFW.style.top= (ie) ? nowY+event.clientY-offsety : eval(nowY + e.clientY - offsety) + 'px';
	}
	catch(ex){}
	return false;
}

// ===================================================================================
// Masquer info-bulle
function HideIB() 
{
	// Moz
	if (mz) document.getElementById("InfoBulle").style.visibility="hidden";
	// IE et Netscape
	else ZoneIB.visibility = "hidden";
}

// ===================================================================================
// Afficher fenêtre flottante
function HideFW(FW, lien)
{
	if ( (ie) || (mz) ) document.getElementById(FW).style.visibility="hidden";
	if (lien == 1) document.getElementById(FW+"_l").className="ifw_l";
}

// ===================================================================================
// Masquer fenêtre flottante
function ShowFW(FW, lien)
{
	if ( (ie) || (mz) ) document.getElementById(FW).style.visibility="visible";
	if (lien == 1) document.getElementById(FW+"_l").className="afw_l";
}

// ===================================================================================
// Inverser affichage/masquage fenêtre flottante
function SwitchFW(FW, msk, lien)
{
	if (document.getElementById(FW).style.visibility == "visible") HideFW(FW, lien);
	else ShowFW(FW, lien);
}
	
// ===================================================================================
// Analyse situation vis-à-vis d'une fenêtre flottante
vFW_ROv = false;
function FW_Init(e)
{
	vFW_Top = (ie) ? "BODY" : "HTML"; 
	vFW_Src = (ie) ? event.srcElement : e.target;

	while ( (vFW_Src.id.substring(0, 10) != "titleBarFW") && (vFW_Src.tagName!=vFW_Top) && (vFW_Src.tagName!='HTML') ) vFW_Src= (ie) ? vFW_Src.parentElement : vFW_Src.parentNode;

	if ( (vFW_Src.id.substring(0, 10 ) )== "titleBarFW")
	{
		vNoFW = vFW_Src.id.substring(10, 12);
		vFW= document.getElementById("FloatWin" + vNoFW);
		offsetx= (ie) ? event.clientX : e.clientX;
		offsety= (ie) ? event.clientY : e.clientY;
		nowX=parseInt(vFW.style.left);
		nowY=parseInt(vFW.style.top);
		vFW_Active=true;
		document.onmousemove=CatchMouse;
	}	
}