xhr_modification = null;

function getXhr_modification()
{
  if(window.XMLHttpRequest)
    xhr_modification = new XMLHttpRequest();
  else if(window.ActiveXObject)
  {
    try
    {
      xhr_modification = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
      xhr_modification = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  else
  {
    alert("Votre navigateur ne supporte pas les objets XMLHttpRequest...");
    xhr_modification = false;
  }
}

function verif_modif_pass(lang)
{
	getXhr_modification();
	
	xhr_modification.onreadystatechange = function()
  {
  	// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
  	if(xhr_modification.readyState == 4 && xhr_modification.status == 200)
    {
    	document.getElementById('infos_modification_pass').innerHTML = xhr_modification.responseText;
    	//alert(xhr_modification.responseText);
    }
  }
	
	val = document.getElementById('modification_pass').value;
	
	xhr_modification.open("GET","ajax/ajax_modif_profil.php?type=2&val="+val+"&lang="+lang+"",true);
  xhr_modification.send(null);
	
	//document.getElementById('inscription_pass_conf').value = "";
	//verif_passConf();
	//alert("verification du pass");
}

function verif_modif_new_pass(lang)
{
	getXhr_modification();
	
	xhr_modification.onreadystatechange = function()
  {
  	// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
  	if(xhr_modification.readyState == 4 && xhr_modification.status == 200)
    {
    	document.getElementById('infos_modification_new_pass').innerHTML = xhr_modification.responseText;
    }
  }
	
	val = document.getElementById('modification_new_pass').value;
	
	xhr_modification.open("GET","ajax/ajax_modif_profil.php?type=2&val="+val+"&lang="+lang+"",true);
  xhr_modification.send(null);
	
	//document.getElementById('inscription_pass_conf').value = "";
	verif_modif_new_passConf(lang);
	//alert("verification du pass");
}

function verif_modif_new_passConf(lang)
{
	if(document.getElementById('modification_new_pass_conf').value == document.getElementById('modification_new_pass').value)
	{
		document.getElementById('infos_modification_new_pass_conf').innerHTML = "<span style='color: #0d0;'>correct</span>";
	}
	else
	{
		document.getElementById('infos_modification_new_pass_conf').innerHTML = "<span style='color: #d00;'>incorrect</span>";
	}
}

function verif_modif_mail(login, lang)
{
	getXhr_modification();
	
	xhr_modification.onreadystatechange = function()
  {
  	// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
  	if(xhr_modification.readyState == 4 && xhr_modification.status == 200)
    {
    	document.getElementById('infos_modification_mail').innerHTML = xhr_modification.responseText;
    	//alert(xhr_modification.responseText);
    }
  }
	
	val = document.getElementById('modification_mail').value+"|"+login;
	
	xhr_modification.open("GET","ajax/ajax_modif_profil.php?type=3&val="+val+"&lang="+lang+"",true);
  xhr_modification.send(null);
	//alert("verification du mail");
}

function valid_modification(lang)
{
	getXhr_modification();
	
	xhr_modification.onreadystatechange = function()
  {
  	// On ne fait quelque chose que si on a tout reçu et que le serveur est ok
  	if(xhr_modification.readyState == 4 && xhr_modification.status == 200)
    {
    	alert(xhr_modification.responseText);
    }
  }
	
	val = document.getElementById('modification_login').value;
	val += "|"+document.getElementById('modification_pass').value;
	val += "|"+document.getElementById('modification_new_pass').value;
	val += "|"+document.getElementById('modification_new_pass_conf').value;
	val += "|"+document.getElementById('modification_mail').value;
	val += "|"+document.getElementById('modification_nom').value;
	val += "|"+document.getElementById('modification_prenom').value;
	val += "|"+document.getElementById('modification_societe').value;
	val += "|"+document.getElementById('modification_adresse').value;
	val += "|"+document.getElementById('modification_code_postal').value;
	val += "|"+document.getElementById('modification_ville').value;
	val += "|"+document.getElementById('modification_pays').value;
	val += "|"+document.getElementById('modification_telephone').value;
	//alert(val);
	xhr_modification.open("GET","ajax/ajax_modif_profil.php?type=4&val="+val+"&lang="+lang+"",true);
  xhr_modification.send(null);
}
