﻿function xmlFromString(body) { 
	// code for IE 
	if (window.ActiveXObject) { 
		var doc=new ActiveXObject("Microsoft.XMLDOM"); 
		doc.async="false"; 
		doc.loadXML(body); 
	} 
		// code for Mozilla, Firefox, Opera, etc. 
		else { 
			var parser=new DOMParser(); 
			var doc=parser.parseFromString(body,"text/xml"); 
		}
	return doc;     
} 
function rappel(noeud) {
	node=node.splice(0, docXS.firstChild.childNodes.length);
	if(noeud != null) {
		if(noeud.getAttribute("isOpen") == "1") noeud.setAttribute("isOpen", "0");
			else noeud.setAttribute("isOpen", "1");
	}
	var tt='<nobr><img src="'+sdistant+'rien.gif" border="0">&nbsp;<a class="menu2" href="./">accueil</a></nobr><br>';
	var n=0;
	var doc=docXS.firstChild.firstChild;
	while(doc.nodeName != "root") {
		//if(doc.hasChildNodes() == false) {
		if(doc.getAttribute("isOpen") == null) {
			var tabul=0;
			for(i=0; i<n; i++) tabul+=15;
			//if(doc.getAttribute("nom").indexOf("-cf-") == -1) {
				if(doc.getAttribute("url") == null) var url="article?"+doc.getAttribute("cip").split(" ").join("-").split('"').join("%22")+langUrl3;	//+".php"
					else {
						if(doc.getAttribute("url").indexOf("http://") == -1) var url="http://"+doc.getAttribute("url");
							else var url=doc.getAttribute("url");
					}
			/*}		
				else var url=doc.getAttribute("nom").substring(0, doc.getAttribute("nom").indexOf("-cf-"))+".php";*/
			if(doc.getAttribute("nomAffich") == undefined) nomAffich=Premiere(doc.getAttribute("nom").split("-").join("&nbsp;"));
				else nomAffich=Premiere(doc.getAttribute("nomAffich"));
			if(doc.getAttribute("nom").indexOf("-taille-") != -1) nomAffich=doc.getAttribute("nom").substring(doc.getAttribute("nom").indexOf("-taille-")+1).split("taille-").join("taille&nbsp;");
			nomAffich=nomAffich.split(" ").join("&nbsp;").split("<br>").join('<br>=>');
			tt+='<div style="padding-left: '+(tabul+9+5)+'px;display: inline-block;"><nobr><a class="menu2" href="'+url+'">'+rechapXML(nomAffich)+'</a></nobr></div><br>';
			if(doc.nextSibling != null) {
				doc=doc.nextSibling;
			}
				else {
					while(doc.parentNode.nextSibling == null && doc.parentNode.nodeName != "root") {
						doc=doc.parentNode;
						n-=1;
					}
					if(doc.parentNode.nodeName != "root") {
						doc=doc.parentNode.nextSibling;
						n-=1;
					}
						else doc=doc.parentNode;
				}
		}
			else {
				var isOpen = doc.getAttribute("isOpen");
				if(isOpen == "1") {
					if(doc.nodeName != "base") {
						node.push(doc);
						var tabul=0;
						for(i=0; i<n; i++) tabul+=15;
						if(doc.getAttribute("nomAffich") == undefined) nomAffich=Premiere(doc.getAttribute("nom").split("-").join("&nbsp;"));
							else nomAffich=Premiere(doc.getAttribute("nomAffich"));
						nomAffich=nomAffich.split("<br>").join('<br>=>');
						tt+='<div style="padding-left: '+tabul+'px;display: inline-block;"><nobr><a href="javascript:rappel(node['+(node.length-1)+'])"><img src="'+sdistant+'moins.jpg" border="0"></a><img src="'+sdistant+'rien2.gif" border="0"><a class="menu2" href="rubrique?'+doc.getAttribute("nom").split(" ").join("-").split('"').join("%22")+langUrl3+'">'+rechapXML(nomAffich).split(" ").join("&nbsp;")+'</a></nobr></div><br>';
					}
						else {
							if(doc.getAttribute("nomAffich") == undefined) nomAffich=Premiere(doc.getAttribute("nom").split("-").join("&nbsp;"));
								else nomAffich=Premiere(doc.getAttribute("nomAffich"));
							tt+='<nobr><a href="javascript:rappel(node['+Number(doc.getAttribute("num"))+'])"><img src="'+sdistant+'moins.jpg" border="0"></a><img src="'+sdistant+'rien2.gif" border="0"><a class="menu2" href="rubrique?'+doc.getAttribute("nom").split(" ").join("-").split('"').join("%22")+langUrl3+'">'+rechapXML(nomAffich).split(" ").join("&nbsp;")+'</a></nobr><br>';
						}
					doc=doc.firstChild;
					n+=1;
				}
				if(isOpen == "0") {
					if(doc.nodeName != "base") {
						node.push(doc);
						var tabul=0;
						for(i=0; i<n; i++) tabul+=15;
						if(doc.getAttribute("nomAffich") == undefined) nomAffich=Premiere(doc.getAttribute("nom").split("-").join("&nbsp;"));
							else nomAffich=Premiere(doc.getAttribute("nomAffich"));
						nomAffich=nomAffich.split("<br>").join('<br>=>');
						tt+='<div style="padding-left: '+tabul+'px;display: inline-block;"><nobr><a href="javascript:rappel(node['+(node.length-1)+'])"><img src="'+sdistant+'plus.jpg" border="0"></a><img src="'+sdistant+'rien2.gif" border="0"><a class="menu2" href="rubrique?'+doc.getAttribute("nom").split(" ").join("-").split('"').join("%22")+langUrl3+'">'+rechapXML(nomAffich).split(" ").join("&nbsp;")+'</a></nobr></div><br>';
					}
						else {
							if(doc.getAttribute("nomAffich") == undefined) nomAffich=Premiere(doc.getAttribute("nom").split("-").join("&nbsp;"));
								else nomAffich=Premiere(doc.getAttribute("nomAffich"));
							tt+='<nobr><a href="javascript:rappel(node['+Number(doc.getAttribute("num"))+'])"><img src="'+sdistant+'plus.jpg" border="0"></a><img src="'+sdistant+'rien2.gif" border="0"><a class="menu2" href="rubrique?'+doc.getAttribute("nom").split(" ").join("-").split('"').join("%22")+langUrl3+'">'+rechapXML(nomAffich).split(" ").join("&nbsp;")+'</a></nobr><br>';
						}
					if(doc.nextSibling != null) {
						doc=doc.nextSibling;
					}
						else {
							while(doc.parentNode.nextSibling == null && doc.parentNode.nodeName != "root") {
								doc=doc.parentNode;
								n-=1;
							}
							if(doc.parentNode.nodeName != "root") {
								doc=doc.parentNode.nextSibling;
								n-=1;
							}
								else doc=doc.parentNode;
						}
				}
			}
	}
	document.getElementById("labos").innerHTML = tt.substring(0, tt.length-4);
}
function att(tout) {
	var doc=docXS.getElementsByTagName("base");
	for(i=0; i<doc.length; i++) {
		if(doc[i].getAttribute("isOpen") != null) doc[i].setAttribute("isOpen", String(tout));
	}
	var doc=docXS.getElementsByTagName("noeud");
	for(i=0; i<doc.length; i++) {
		if(doc[i].getAttribute("isOpen") != null) doc[i].setAttribute("isOpen", String(tout));
	}
	rappel();
	if(tout == 1) document.getElementById("tout").innerHTML = '<nobr><a class="menu2" href="javascript:att(0)">Réduire</a></nobr>';
		else document.getElementById("tout").innerHTML = '<nobr><a class="menu2" href="javascript:att(1)">Tout&nbsp;dérouler</a></nobr>';
}
function rap(url) {
	var doc=docXS.getElementsByTagName("noeud");
	var urlTuc=url.toUpperCase();
	var urlTlc=url.toLowerCase();
	for(i=0; i<doc.length; i++) {
		if(doc[i].getAttribute("nom") == url || doc[i].getAttribute("nom") == urlTuc || doc[i].getAttribute("nom") == urlTlc) {
			doc=doc[i];
			if(doc.getAttribute("isOpen") != null) doc.setAttribute("isOpen", 1);
			while(doc.parentNode.nodeName != "root") {
				doc=doc.parentNode;
				doc.setAttribute("isOpen", 1);
			}
			break;
		}
	}
	var doc=docXS.getElementsByTagName("base");
	for(i=0; i<doc.length; i++) {
		if(doc[i].getAttribute("nom") == url || doc[i].getAttribute("nom") == urlTuc || doc[i].getAttribute("nom") == urlTlc) {
			doc=doc[i];
			if(doc.getAttribute("isOpen") != null) doc.setAttribute("isOpen", 1);
			break;
		}
	}
	rappel();
}
