/* Javascript du header */
// Modifications:
//
// 30/01/2006 - Fonction qui lance une url directement sans passer par le launcher, 
//	interessant pour que les pages WebContent soit bien indexés par les Robots.
//
//
// 25/05/2005 - Ajout des fonctionnalités de sélection d'entrée 
//				et transmission de l'identifiant de synchronisation à launch.aspx
//
//Url du launcher surchargable


var nav = navigator.userAgent;
if (nav.indexOf("MSIE")>0) {
	JSBrowserType = "IE";
} else if (nav.indexOf("Mozilla")>0 || nav.indexOf("Gecko")>0 || nav.indexOf("Mozilla/5.0")>0) {
	JSBrowserType = "MZ";
} else if (nav.indexOf("Safari")>0) {
	JSBrowserType = "SF";
} else if (nav.indexOf("Opera")>0) {
	JSBrowserType = "OP";
} else {
	JSBrowserType = "OP";
}

var JSisOpera = (JSBrowserType=='OP');
var JSisIE = (JSBrowserType=='IE')||JSisOpera;
var JSisMZ = (JSBrowserType=='MZ');
var JSisSF = (JSBrowserType=='SF');
var JSisNS = false;
var debugConsole=null;

function getElementByIdIE(id) { return document.all[id]; }
function getElementByIdMZ(id) { return document.getElementById(id); }
function getElementByIdOP(id) { return document.getElementById(id); }
eval('getElementById = getElementById'+JSBrowserType);


/* Gestion du menu dynamique */
var g_lastMenuVisible='';
var g_lHideMenuHandler=null;

function showMenu(sID)
{
	window.clearTimeout(g_lHideMenuHandler);	
	var obj=getElementById('td_'+sID);
	var div=getElementById('div_'+sID);
	var x=0,y=0;
	if(div)
	{
		while ((obj!=null)&&(obj!=document.body))
		{
			if(obj.style.position!='absolute')
			{
			x+=obj.offsetLeft;
			y+=obj.offsetTop;
			}
			if (obj.offsetParent==obj) break;
			obj=obj.offsetParent;
		}						
		// récupération de la position du div
		if (JSisSF) {
			div.style.left = (x+4);
		} else {
			div.style.left = x;
		}
		
		if (JSisIE) {
			div.style.top=y+35;
		} else if (JSisSF) {
			div.style.top=y+29;
		} else {
			div.style.top=y+32;
		}
												
		div.style.visibility='visible';								
		if(getElementById(g_lastMenuVisible)) getElementById(g_lastMenuVisible).style.visibility='hidden';
		g_lastMenuVisible=sID;
	}
}
function showMenuLevel2(sParentID,sID,lPos)
{										
	window.clearTimeout(g_lHideMenuHandler);
	var div=getElementById('div_'+sID);
	var tbl=getElementById('table_'+sParentID);
	var divParent=getElementById('div_'+sParentID);

	var x=0,y=0;
	
	if(div && divParent && tbl)
	{	
		div.style.left=parseInt(divParent.style.left.toLowerCase().replace('px',''))+divParent.offsetWidth+1;
		div.style.top=parseInt(divParent.style.top.toLowerCase().replace('px',''))+((lPos-1)*35);		
		div.style.visibility='visible';
		divParent.style.visibility='visible';						
	}
}

function hideMenu(sID)
{		
	try
	{
		var div=getElementById('div_'+sID);					
		if(div)	div.style.visibility='hidden';	
	}
	catch (e)
	{
		if (e != "")
		{
			alert("Erreur : sID="+sID);
		}
	}
}

function hideMenuLevel2(sParentID,sID)
{						
	var div=getElementById('div_'+sID);
	var divParent=getElementById('div_'+sParentID);			
	if(div)	div.style.visibility='hidden';
	if(divParent) divParent.style.visibility='hidden';
	
}	

function writeLevel1(sId,bEvent,bLast,sLabel,sHref,sTarget,sDesc,sSynchroId,bSelected)
{
	/*
	var sHtml='';	
	sHtml = '<td class="header-menu-cell-L0'+(bSelected?'-selected':'')+'"><img id="img_'+sId+'" src="./img/pix.gif" width="5" height="5" alt=""/></td><td style="white-space: nowrap;text-decoration:none" class="header-menu-cell-L0'+(bSelected?'-selected':'')+'" id="td_'+sId+'"';
	sHtml +='><a title="'+(sDesc?sDesc:'')+'" onmouseover="this.style.textDecoration=this.style.textDecoration;hideMenu(g_lastMenuVisible);showMenu(\''+sId+'\');" onmouseout="g_lHideMenuHandler = window.setTimeout(\'hideMenu(\\\''+sId+'\\\')\',1000);" class="header-menu-cell-L0'+(bSelected?'-selected':'')+'"';
	sHtml += ' href="'+sHref+'" target="'+sTarget+'"';
	sHtml += '>'+sLabel+(bLast?'&#160;</a></td>':'</a></td><td style="white-space: nowrap" class="header-menu-cell-L0'+(bSelected?'-selected':'')+'"><img src="./img/pix.gif" width="5" height="5" alt=""/><img src="./img/blank.gif" width="1" height="22" alt=""/></td>');
	document.write(sHtml);
	*/
	var sHtml='';	
	sHtml = '<td style="white-space: nowrap;text-decoration:none" class="header-menu-cell-L0'+(bSelected?'-selected':'')+'" id="td_'+sId+'"';
	sHtml +='><a title="'+(sDesc?sDesc:'')+'" onmouseover="this.style.textDecoration=this.style.textDecoration;hideMenu(g_lastMenuVisible);showMenu(\''+sId+'\');" onmouseout="g_lHideMenuHandler = window.setTimeout(\'hideMenu(\\\''+sId+'\\\')\',1000);" class="header-menu-cell-L0'+(bSelected?'-selected':'')+'"';
	sHtml += ' href="'+sHref+'" target="'+sTarget+'"';
	sHtml += '>'+sLabel+(bLast?'&#160;</a></td>':'</a></td><td style=""><img src="./img/pix.gif" id="img_'+sId+'" width="4" height="4" alt=""/></td>');
	document.write(sHtml);
}

function writeMenu_start()
{
	document.write('<table cellpadding="0" cellspacing="0" class="header-menu-cell-L0-Border"><tr>');
}
function writeLevel1_start(sId)
{
	var sHtml='';
	sHtml='<div style="border:none;padding:0;position:absolute;visibility:hidden;z-index:667;background:transparent;" id="div_'+sId+'" onmouseover="showMenu(\''+sId+'\');" onmouseout="g_lHideMenuHandler = window.setTimeout(\'hideMenu(\\\''+sId+'\\\')\',1000);">';
	sHtml+='<table cellpadding="0" cellspacing="0" border="0"  bordercolor=lime" class="header-menu-cell-L1-Border" id="table_'+sId+'" width="155">';
	document.write(sHtml);
	document.getElementById('maskIFrame').style.top = document.getElementById('div_M1').style.top;
	document.getElementById('maskIFrame').style.left = document.getElementById('div_M1').style.left;
	document.getElementById('maskIFrame').style.width = document.getElementById('div_M1').style.width;
	document.getElementById('maskIFrame').style.height = document.getElementById('div_M1').style.height;
	//document.getElementById('maskIFrame').style.display='';

}
function writeMenu_end()
{
	document.write('<td style="width:155px; background-color:#229BD2"><img src="./img/pix.gif" width="1" height="1" alt=""/></td></tr></table>');
}
function writeLevel2(lPos,sId,sParentId,bEvent,sLabel,sHref,sTarget,sDesc,sSynchroId,bSelected)
{
	writeLevel2Ex(lPos,sId,sParentId,bEvent,sLabel,sHref,sTarget,sDesc,"",false);
}
// 25/05/2005 - Nouvelle méthode avec passage de l'identifiant de synchronisation et l'état de sélection
function writeLevel2Ex(lPos,sId,sParentId,bEvent,sLabel,sHref,sTarget,sDesc,sSynchroId,bSelected)
{
	var sHtml='';
	sHtml = '<tr><td style="white-space: nowrap" class="header-menu-cell-L1" onmouseover="this.className=\'header-menu-cell-L1-over\';showMenuLevel2(\''+sParentId+'\',\''+sId+'\','+lPos+')" onmouseout="this.className=\'header-menu-cell-L1\';hideMenu(\''+sId+'\');"';
	sHtml += '><a title="'+(sDesc?sDesc:'')+'" class="header-menu-cell-L1-href'+(bSelected?'-selected':'')+'"';
	sHtml += ' href="'+sHref+'" target="'+sTarget+'"';	
	sHtml += '>'+sLabel+'&#160;</a></td></tr>';
	document.write(sHtml);
}
function writeLevel1_end()
{
	var sHtml='</table></div>';
	document.write(sHtml);
}

function writeLevel2_start(lPos,sId,sParentId)
{
	var sHtml='';		   
	sHtml='<div style="border:none;padding:0;position:absolute;visibility:hidden;z-index:668;background:transparent;" id="div_'+sId+'" onmouseover="showMenuLevel2(\''+sParentId+'\',\''+sId+'\','+lPos+');" onmouseout="hideMenuLevel2(\''+sParentId+'\',\''+sId+'\');">';
	//sHtml='<div style="border:none;padding:0;position:absolute;visibility:hidden;z-index:668;background:transparent;" id="div_'+sId+'" onmouseover="showMenuLevel2(\''+sParentId+'\',\''+sId+'\','+lPos+');" onmouseout="window.setTimeout(\'hideMenu(\\\''+sParentId+'\\\',\\\''+sId+'\\\')\',1000);">';
	sHtml+='<table cellpadding="0" cellspacing="0" border="0" bordercolor="lime" class="header-menu-cell-L2-Border" id="table_'+sId+'">';
	document.write(sHtml);
}
function writeLevel3(lPos,sId,sParentId,bEvent,sLabel,sHref,sTarget,sDesc)
{
	writeLevel3Ex(lPos,sId,sParentId,bEvent,sLabel,sHref,sTarget,sDesc,"",false);
}
// 25/05/2005 - Nouvelle méthode avec passage de l'identifiant de synchronisation et l'état de sélection
function writeLevel3Ex(lPos,sId,sParentId,bEvent,sLabel,sHref,sTarget,sDesc,sSynchroId,bSelected)
{
	var sHtml='';	
	sHtml += '<tr><td style="white-space: nowrap" class="header-menu-cell-L2" onmouseover="this.className=\'header-menu-cell-L2-over\';" onmouseout="this.className=\'header-menu-cell-L2\';"';
	sHtml += '><a title="'+(sDesc?sDesc:'')+'" class="header-menu-cell-L2-href'+(bSelected?'-selected':'')+'"';
	sHtml += ' href="'+sHref+'" target="'+sTarget+'"';
	sHtml += '>'+sLabel+'&#160;</a></td></tr>';
	document.write(sHtml);													
}		
function writeLevel2_end()
{
	var sHtml='</table></div>';
	document.write(sHtml);
}													

