// ************************************
// *** Code appartenant à evoweb.fr ***
// ************************************
function xhr_call() {
	// Création de l'objet Ajax
	try {
		// Autres que IE 7 et Opera, FF, Kmeleon, Safari etc ...
		xhr = new XMLHttpRequest;
	}
	catch (e) {
		try {
			// IE
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			// IE
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	// Controle des réponses de XHR
	xhr.onreadystatechange = function() {
		if (this.xhr) {
			var theXhr = this.xhr;
		} else {
			var theXhr = this;
		}
		if (theXhr.readyState == 4) {
			if (theXhr.status == 200) {
				var xml = theXhr.responseXML.documentElement;
				// Si c'est une erreur on l'affiche pour le débug
				if (!xml || !xml.childNodes[0].firstChild) {
					if (xml.responseText)
						alert ("XML non valide : "+xml.responseText);
					else if (xml.textContent)
						alert ("XML non valide : "+xml.textContent);
					return;
				}
				for (var i=0;i<xml.childNodes.length;i++) {
					if (xml.childNodes[i].firstChild) {
						var data = xml.childNodes[i].firstChild.data;
					}
					for (var j=0;j<xml.childNodes[i].attributes.length;j++) {
						if (xml.childNodes[i].attributes[j].name == "type") {
							var type = xml.childNodes[i].attributes[j].value;
						} else if (xml.childNodes[i].attributes[j].name == "id") {
							var id = xml.childNodes[i].attributes[j].value;
						}
					}
					switch (type) {
						case 'assign':
							var assignation = document.getElementById(id);
							if (assignation) assignation.innerHTML = data;
							break;
						case 'script':
							eval(data);
							break;
					}
				}
			} else {
				if (theXhr.responseText.length != 0) alert ('Réponse non valide : '+theXhr.responseText);
			}
		}
	}

	xhr_uri = 'xhr_ws.php?xhr_func=' + encodeURIComponent(arguments[0]);
	for (var i=1; i<arguments.length;i++) {
		xhr_uri += '&xhr_args[]=' + encodeURIComponent(arguments[i]);
	}
	xhr.open ('GET', xhr_uri, true);
	xhr.send(null);
}