// ===========================================================================
// Gestion des statistiques
// ===========================================================================
function compteur() {
	// Affichage du compteur
	document.getElementById('compteur').innerHTML = convCarAccent(HttpRequest('UniD.Stat/compteur.php', ''));
};


// ===========================================================================
// Fonctions Ajax
// ===========================================================================

function HttpRequest(pPage, pParam) {
	// Lecture synchrone d'une page sur le serveur

	if (navigator.appName == 'Microsoft Internet Explorer') 
		{ xhr = new ActiveXObject('Microsoft.XMLHTTP') }
	else 
		{ xhr = new XMLHttpRequest() };

	xhr.open('POST', pPage, false);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send(pParam);

	resultat = xhr.responseText;
		
	// Renvoi du résultat
	return resultat;
};


function convCarAccent(txt) {
	var i = 0;			  
	var t = txt;
								 
	// Conversion de #e1# en é					
	i = t.indexOf('#e1#');
	while (i >= 0) { 
		t = t.substring(0,i) + 'é' + t.substring(i+4, t.length+1); 
		i = t.indexOf('#e1#');
	};

	// Conversion de #e2# en è
	i = t.indexOf('#e2#');
	while (i >= 0) { 
		t = t.substring(0,i) + 'è' + t.substring(i+4, t.length+1); 
		i = t.indexOf('#e2#');
	};

	// Conversion de #e3# en ê
	i = t.indexOf('#e3#');
	while (i >= 0) { 
		t = t.substring(0,i) + 'ê' + t.substring(i+4, t.length+1); 
		i = t.indexOf('#e3#');
	};
	
	// Conversion de #c1# en ç
	i = t.indexOf('#c1#');
	while (i >= 0) { 
		t = t.substring(0,i) + 'ç' + t.substring(i+4, t.length+1); 
		i = t.indexOf('#c1#');
	};							 
	
	// Conversion de #a1# en à
	i = t.indexOf('#a1#');
	while (i >= 0) { 
		t = t.substring(0,i) + 'à' + t.substring(i+4, t.length+1); 
		i = t.indexOf('#a1#');
	};

	// Conversion de #a2# en â
	i = t.indexOf('#a2#');
	while (i >= 0) {
		t = t.substring(0,i) + 'â' + t.substring(i+4, t.length+1);
		i = t.indexOf('#a2#');
	};

	// Conversion de #i1# en ï
	i = t.indexOf('#i1#');
	while (i >= 0) {
		t = t.substring(0,i) + 'ï' + t.substring(i+4, t.length+1);
		i = t.indexOf('#i1#');
	};

	resultat = t;
	return resultat;
};