
function KLOISLoadMenuXml(fichier)
{
	try
	{
		var xmlhttp = false;
		var html = '';
	
		/*@cc_on @*/
		/*@if (@_jscript_version >= 5)
		try
		{
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (E) 
			{
				xmlhttp = false;
			}
		}
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest!='undefined')
		{
			xmlhttp = new XMLHttpRequest();
		}
		xmlhttp.open('GET', fichier, false);
		xmlhttp.send('');
		if (xmlhttp.responseXML.childNodes[0].xml)
			return xmlhttp.responseXML.childNodes[1];
		return xmlhttp.responseXML.childNodes[0];
	
	}catch(e){return false;}
}



var KLOISMenuId = 0;
function KLOISMenu(fichier)
{
	try
	{
	KLOISMenuId++;
	var xml = KLOISLoadMenuXml(fichier);
	xml = xml.childNodes;
	var arbre = new Array();
	//
	// On parcourt le fichier xml
	//
	var a = 0;
	var b = xml.length;
	var x = -1;
	var last;
	while (a != b)
	{
		if (xml[a].nodeName == 'menu')
		{
			x++;
			arbre[x] = new Object();
			arbre[x].ssmenus = Array();
			last = arbre[x];
		}
		else if (x > -1 && xml[a].nodeName == 'sousmenu')
		{
			var y = arbre[x].ssmenus.length;
			arbre[x].ssmenus[y] = new Object();
			last = arbre[x].ssmenus[y];
		}
		else
		{
			a++;
			continue;
		}

		// Le titre
		last.titre = xml[a].childNodes[0].nodeValue;
		// les attributs
		var d = 0;
		var e = xml[a].attributes.length;
		while (d != e)
		{
			switch (xml[a].attributes[d].nodeName)
			{
				case 'page' :
					last.page = xml[a].attributes[d].nodeValue;
					break;
				case 'target' :
					last.target = xml[a].attributes[d].nodeValue;
					break;
			}
			d++;
		}
		a++;
	}

	//
	// On parcourt les infos récupérées pour afficher
	//

	document.write('<table border="0" cellspacing="0" cellpadding="0"><tr>');
	for (var x in arbre)
	{
		document.write('<td class="nav" width="120" id="menu' + KLOISMenuId + '_' + x + '" onmouseover="KLOISMenuOverOut(' + KLOISMenuId + ', ' + x + ', \'over\');" onmouseout="KLOISMenuOverOut(' + KLOISMenuId + ', ' + x + ', \'out\');" style="padding-top: 4px; padding-bottom: 4px;"><a href="' + arbre[x].page + '" class="nav" target="' + (arbre[x].target ? arbre[x].target : '')+ '">' + arbre[x].titre + '</a></td>');
	}


	
	// Les sous menus
	document.write('</tr><tr>');
	for (var x in arbre)
	{
		document.write('<td onmouseover="clearTimeout(KLOISMenuTimeouts[' + x + ']);" onmouseout="KLOISMenuOverOut(' + KLOISMenuId + ', ' + x + ', \'out\');">');
		
		document.write('<div style="position: absolute; display: none;" id="sousMenu' + KLOISMenuId + '_' + x + '"><div style="text-align: center; width: 125px; position: absolute;"><img src="images/arrow.gif"></div><img src="images/clear.gif" style="width: 125px; height: 14px;">');
		
		if (arbre[x].ssmenus.length)
		{
			document.write('<div class="sousnav">');

			for (var y in arbre[x].ssmenus)
				document.write('<a href="' + arbre[x].ssmenus[y].page + '" class="sousmenu" target="' + (arbre[x].ssmenus[y].target ? arbre[x].ssmenus[y].target : '')+ '">' + arbre[x].ssmenus[y].titre + '</a><br>');
	
			document.write('</div>');
		}
		
		document.write('</div></td>');
	}
	document.write('</tr></table>');
	}catch(e)
	{
		document.write('<strong style="color: red">Attention</strong> : Vous devez transferer ce kit chez votre hebergeur pour que le menu fonctionne sous Internet Explorer. (<a href="scripts/menu.lisezmoi.txt">explications</a>)');
	};
}


var KLOISMenuTimeouts = new Array();
function KLOISMenuOverOut(KLOISMenuId, x, oo)
{
	var timeout = '';
	// Le fond en couleur
	var id = 'menu' + KLOISMenuId + '_' + x;
	timeout += "document.getElementById('" + id + "').style.backgroundColor = '" + (oo == 'over' ? '#EAD699' : '') + "';";

	// Le sous menu
	id = 'sousMenu' + KLOISMenuId + '_' + x;
	var d = document.getElementById(id);
	if (d)
	{
		timeout += "document.getElementById(\'" + id + "\').style.display = '" + (oo == 'over' ? '' : 'none') + "'";
	}
	KLOISMenuTimeouts[x] = setTimeout(timeout);
}


