function checkonline()
{
	clearTimeout(timer_online);

	var xhr_object=createXHR();
	xhr_object.open("GET", "./ajax/checkonline.php", false);
	xhr_object.send(null);
	
	timer_online=setTimeout("checkonline();",60000);
}
function changestatut(statut)
{
	var xhr_object=createXHR();
	xhr_object.open("GET", "./ajax/changestatut.php?statut="+statut, false);
	xhr_object.send(null);
}
function createXHR()
{
	var xhr_object;
	if(window.XMLHttpRequest)
	xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject)
	xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else {alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");return(false);}
	return xhr_object;
}

function addslashes(txt) {
txt = txt.replace("'","\\'");
return txt
}

/************************************************************************************************************************
 ************************************************************************************************************************
 ************************************************************************************************************************
 ************************************************************************************************************************/

function shout() /*envoi d'un message sur le tchat*/
{
	var txt_shout = elem("txt_shout").value;
	var reg2=new RegExp("[+]", "g");
	var reg1=new RegExp("&", "g");
	txt_shout=txt_shout.replace(reg2,"[plus]");
	txt_shout=txt_shout.replace(reg1,"[et]");
	
	if(txt_shout != "") {
			xhr_object = createXHR();
			var fichier = "./ajax/send.php";
			xhr_object.open("post", fichier, false);
			xhr_object.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			xhr_object.send("txt=" + txt_shout);
			elem("txt_shout").value = "";
			elem('alerte_chat').innerHTML = ''+xhr_object.responseText;
	}
	
	countrefresh=0;refreshtime=3000;
	refresh();
}

/************************************************************************************************************************
 ************************************************************************************************************************
 ************************************************************************************************************************
 ************************************************************************************************************************/

var refreshtime=20000;
var countrefresh=0;
var timerr;

function refresh()
{
	clearTimeout(timerr);
	countrefresh=countrefresh+1;
	var xhr_object1 = createXHR();
	var fichier1 = "./ajax/getlast.php";
	xhr_object1.open("post", fichier1, true);
	xhr_object1.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xhr_object1.send(null);
	// Attente de la reponse
	xhr_object1.onreadystatechange = function() {
		if(xhr_object1.readyState == 4) {
			// Affichage du texte
			var retour =xhr_object1.responseText.split("_");
			if(retour[0]=='<meta http-equiv="pragma" content="no-cache">1'||elem("shoutbox").innerHTML=='') {
			
				var xhr_object = createXHR();
				var fichier = "./ajax/shoutbox.php";
				xhr_object.open("post", fichier, true);
				xhr_object.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
				xhr_object.send(null);
				// Attente de la reponse
				xhr_object.onreadystatechange = function() {
					if(xhr_object.readyState == 4) {
						// Affichage du texte
						elem("shoutbox").innerHTML = xhr_object.responseText;
					}
				}
			}
		}
	}
	
	if (countrefresh==30&&refreshtime==3000) {refreshtime=20000;}
	timerr=setTimeout("refresh();",refreshtime);
}

/************************************************************************************************************************
 ************************************************************************************************************************
 ************************************************************************************************************************
 ************************************************************************************************************************/

