
/*------------------------------------------------------------------------------------------
verifierLogin(mode, data)
	- mode 0, "requete" : demander au serveur la verification d'un login ( data = login )
	- mode 1, "reponse" : afficher un message selon que le login est valide ( data = true )
			ou invalide ( data = false )
------------------------------------------------------------------------------------------*/

var verifierLoginReqHTTP;


/*------------------------------------------------------------------------------------------
verifierLoginReponse() : appelle par le XML Request
------------------------------------------------------------------------------------------*/

function verifierLoginReponse() {
	
	try {
	// seulement si requete terminee et statut OK
	if (verifierLoginReqHTTP.readyState == 4 && verifierLoginReqHTTP.status == 200) {
		
		var responseXML = verifierLoginReqHTTP.responseXML;//verifierLoginReqHTTP.responseText
		
		//alert(verifierLoginReqHTTP.responseText);
		
		var response =responseXML.getElementsByTagName('node')[0].getAttribute("result");
		var login =responseXML.getElementsByTagName('node')[0].getAttribute("login");
		var password =responseXML.getElementsByTagName('node')[0].getAttribute("password");
		
		document.getElementById('messageResponse').innerHTML = response;
		document.getElementById("formLogin").setAttribute("value", login);
		document.getElementById("formpassword").setAttribute("value", password);
		
		if (response == "")
			document.getElementById('registerPartTwo').className = 'visible';
		else
			document.getElementById('registerPartTwo').className = 'hidden';
	}
	} catch (error){ document.getElementById('messageResponse').innerHTML = error; }
}



/*------------------------------------------------------------------------------------------
verifierLogin() : appelle par la page
------------------------------------------------------------------------------------------*/
function verifierLogin(login,password,passwordconfirmation) {
	
	url  = 'ajax_inscription/verifierLoginEtPass.xml.php?'
		+ 'login=' + login 
		+ '&password=' + password 
		+ '&passwordconfirmation=' + passwordconfirmation;
	
	verifierLoginReqHTTP = chargerXMLDoc(url, verifierLoginReponse);
}




