// JavaScript Document

function addidentification(obj) {
				 document.getElementById("identification").innerHTML = "";
				 document.getElementById("identification").innerHTML += obj.responseText;

}
 function resultlogin(obj) {
	document.getElementById("resultlogin").innerHTML = "";
	if ( obj.responseText == "1" )
	{
		 var XHRident = new XHRConnection();
		 XHRident.appendData("timeident", "48545745");
		 XHRident.sendAndLoad("/_include/ident.php", "GET",addidentification);
	} else if ( obj.responseText == "2" )  {
		document.getElementById("resultlogin").innerHTML ="<div align=center  style=\"background-color:#ffffff;color:red;\"><b>Le mot de passe est faux !</b></div>" ;
	} else if ( obj.responseText == "3" )  {
		document.getElementById("resultlogin").innerHTML ="<div align=center style=\"background-color:#ffffff;color:red;\"><b>Le compte est suspendu</b></div>" ;
	} else {
		document.getElementById("resultlogin").innerHTML = obj.responseText;
	}
	cacheloading('connectform');
	return false; // bloque le rechargement de la page
	
}

function ConnectAjax() {
	affloading('connectform');
	 if(document.getElementById('pseud').value == "") {
		document.getElementById('connectform').style.visibility="hidden";
		alert('Indiquez votre Pseudo !!');
		cacheloading('connectform');
		return false; // bloque le rechargement de la page
	} else {
			if(document.getElementById('pass').value == "") {
				document.getElementById('connectform').style.visibility="hidden";
				alert('Indiquez votre password  !!');
				cacheloading('connectform');
				return false; // bloque le rechargement de la page
			} else {
				 // Création de l'objet  XHRConnection
				 var XHR = new XHRConnection();
				 XHR.appendData("pseud", document.getElementById('pseud').value);
				 XHR.appendData("pass", document.getElementById('pass').value);	 
				 if (document.getElementById("permanent").checked == true) {XHR.appendData("permanent", document.getElementById('permanent').value);}
				 document.getElementById("resultlogin").innerHTML = "";
			     XHR.sendAndLoad("/_include/login.php", "POST",resultlogin);
			}
	}
}


function affloading(div){
document.getElementById(div).style.visibility="visible";
}
function cacheloading(div){
document.getElementById(div).style.visibility="hidden";
}

function affloadingsearch(){
document.getElementById('search').className= "searchactive";
}