var isMozilla = (navigator.userAgent.toLowerCase().indexOf('gecko')!=-1) ? true : false;
var regexp = new RegExp("[\r]","gi");


// Ouverture requete ajax
function getXMLHttpRequest(){
	var xhr = null;

	if(window.XMLHttpRequest || window.ActiveXObject) {
			if(window.ActiveXObject) {
					try {
							xhr = new ActiveXObject("Msxml2.XMLHTTP");
					} catch(e) {
							xhr = new ActiveXObject("Microsoft.XMLHTTP");
					}
			} else {
					xhr = new XMLHttpRequest();
			}
	} else {
			alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
			return null;
	}

	return xhr;
}

// Variable IE
var testie = Math.floor(Math.random() * 1000000000);

// Affichage des liste
function AffListe(){
	var xhr = getXMLHttpRequest();
	if(xhr && xhr.readyState != 0) {xhr.abort();}
	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('ChoixCarteZone').innerHTML = xhr.responseXML.getElementsByTagName('Info01')[0].firstChild.nodeValue;
			testie = testie + 1;
		}
		else if(xhr.readyState == 2 || xhr.readyState == 3) {}
	}
	xhr.open("POST", "AFF_ChoixCarteZone.php", true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xhr.send("ie="+testie);
}
////////////////////////////////
// Choix d'une zone
function ChoixZone(){
	var numZone = 0;
	var numZoneSelect = document.menu.zone.selectedIndex;
	numZone = document.menu.zone.options[numZoneSelect].value;
	var xhr = getXMLHttpRequest();
	if(xhr && xhr.readyState != 0) {xhr.abort();}
	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('ChoixCarteZone').innerHTML = xhr.responseXML.getElementsByTagName('Info01')[0].firstChild.nodeValue;
			testie = testie + 1;
		}
		else if(xhr.readyState == 2 || xhr.readyState == 3) {}
	}
	xhr.open("POST", "AFF_ChoixCarteZone.php", true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xhr.send("numZone="+numZone+"&ie="+testie);
}
////////////////////////////////

// Affichage des informations concernant la carte choisie
function ChoixCarte(){
	var numCarteBis = 0;
	var numCarteSelect = document.menu2.carte.selectedIndex;
	numCarteBis = document.menu2.carte.options[numCarteSelect].value;
	var xhr = getXMLHttpRequest();
	if(xhr && xhr.readyState != 0) {xhr.abort();}
	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('InfoCarte').innerHTML = xhr.responseXML.getElementsByTagName('InfoCarteAff')[0].firstChild.nodeValue;
			document.getElementById('AffCarte').innerHTML = xhr.responseXML.getElementsByTagName('InfoCarteAff')[1].firstChild.nodeValue;
			testie = testie + 1;
		}
		else if(xhr.readyState == 2 || xhr.readyState == 3) {}
	}
	xhr.open("POST", "AFF_InfoCarte.php", true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xhr.send("numCarte="+numCarteBis+"&ie="+testie);
}

// Affichage des informations concernant la carte choisie
function AffInfoCarte(numCarte){
	var xhr = getXMLHttpRequest();
	if(xhr && xhr.readyState != 0) {xhr.abort();}
	xhr.onreadystatechange = function() {
		if(xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			document.getElementById('InfoCarte').innerHTML = xhr.responseXML.getElementsByTagName('InfoCarteAff')[0].firstChild.nodeValue;
			document.getElementById('AffCarte').innerHTML = xhr.responseXML.getElementsByTagName('InfoCarteAff')[1].firstChild.nodeValue;
			testie = testie + 1;
		}
		else if(xhr.readyState == 2 || xhr.readyState == 3) {}
	}
	xhr.open("POST", "AFF_InfoCarte.php", true);
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
	xhr.send("numCarte="+numCarte+"&ie="+testie);
}
////////////////////////////////

