function verifValide()
{
	var txtPass1 = document.forms["formIns"].elements["txtPass1"].value;
	var txtPass2 = document.forms["formIns"].elements["txtPass2"].value;
	var txtPse = document.forms["formIns"].elements["txtPse"].value;
	var txtMail = document.forms["formIns"].elements["txtMail"].value;
	var txtMail = document.forms["formIns"].elements["txtMail"].value;
	var txtNameCrea = document.forms["formIns"].elements["txtNameCrea"].value;
	var maCreature = document.forms["formIns"].elements["radMst"];
	var creature = testerRadio(maCreature);
	var test = true;
	var txtsex;
	
	if(txtPse == "")
	{
		document.forms["formIns"].elements["txtPse"].focus();	
		test = false;	
	}
	else if(txtPass1 == "")
	{
		document.forms["formIns"].elements["txtPass1"].focus();
		test = false;	
	}
	else if(txtPass2 == "")
	{
		document.forms["formIns"].elements["txtPass2"].focus();
		test = false;	
	}
	else if(txtMail == "")
	{
		document.forms["formIns"].elements["txtMail"].focus();
		test = false;	
	}
	else if(txtNameCrea == "")
	{
		document.forms["formIns"].elements["txtNameCrea"].focus();
		test = false;	
	}
	else
	{
		if(txtPass1 != txtPass2)
		{
			document.forms["formIns"].elements["txtPass1"].focus();
			document.getElementById("divError").innerHTML = "Tes mots de passe ne sont pas identiques...";
			document.getElementById("divError").style.visibility = 'visible';
			document.getElementById("divError").style.height = '17px;';
			document.getElementById("divError").style.marginBottom = '15px;';
		}
		else
		{
			if(document.forms["formIns"].elements["hidSex"].value == 'h')
				txtsex = "un entraîneur homme";
			else
				txtsex = "une entraîneuse femme";
			if(confirm("Es-tu certain de vouloir créer "+txtsex+" du nom de "+document.forms["formIns"].elements["txtPse"].value+" ?\n\nTu ne pourras plus changer par la suite...\n"))
			{
				if(confirm("Attention, tu ne pourras plus changer de sexe par la suite...\nToujours d'accord ?"))
					document.forms["formIns"].submit();
				//requestInscr(txtPse,txtPass1,txtMail,creature,txtNameCrea);
			}
		}
	}
	
	if(!test)
	{
		document.getElementById("divError").innerHTML = "Tu n'as pas rempli tous les champs...";
		document.getElementById("divError").style.visibility = 'visible';
		document.getElementById("divError").style.height = '17px;';
		document.getElementById("divError").style.marginBottom = '15px;';
	}
}

function testerRadio(radio) 
{
	for (var i=0; i<radio.length;i++) 
	{
	   if (radio[i].checked) 
	   {
	      return radio[i].value;
	   }
	}
}

function verifExist(madiv,data, page, method, div, autre)
{
	var XhrObj = null; 
	
	if(window.XMLHttpRequest) // Firefox 
	   XhrObj = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	   XhrObj = new ActiveXObject("Microsoft.XMLHTTP"); 
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		return; 
	} 
    
    //si on envoie par la méthode GET:
    if(method == "GET")
    {
    	   if(data == 'null')
        {
            //Ouverture du fichier sélectionné:
            XhrObj.open("GET", page);
        }
        else
        {
            //Ouverture du fichier en methode GET
            XhrObj.open("GET", page+"?"+data);
        }
    }
    else if(method == "POST")
    {
    	   //Ouverture du fichier en methode POST
        XhrObj.open("POST", page);
    }
	
    //Ok pour la page cible

    XhrObj.onreadystatechange = function()
    {
	    	if(XhrObj.readyState == 4)
		{	
			if(XhrObj.responseText == "0")
			{
				document.getElementById(madiv).focus();
				document.getElementById("divError").innerHTML = "Ce nom existe déjà, merci d'en trouver un autre...";
				document.getElementById("divError").style.visibility = 'visible';
				document.getElementById("divError").style.height = '17px;';
				document.getElementById("divError").style.marginBottom = '15px;';
				document.getElementById("divError").style.borderColor = 'red;';
				document.getElementById("divError").style.color = 'red;';
				
			}
			else if(XhrObj.responseText == "1")
			{
				document.getElementById(madiv).focus();	
				document.getElementById("divError").innerHTML = "Cet email existe déjà. Merci d'en changer.";
				document.getElementById("divError").style.visibility = 'visible';
				document.getElementById("divError").style.height = '17px;';
				document.getElementById("divError").style.marginBottom = '15px;';
				document.getElementById("divError").style.borderColor = 'red;';
				document.getElementById("divError").style.color = 'red;';
				
			}
			/*else
			{
				document.getElementById("divError").innerHTML = "Entra&icirc;neur cr&eacute;&eacute;";
				document.getElementById("divError").style.visibility = 'visible';
				document.getElementById("divError").style.height = '17px;';
				document.getElementById("divError").style.marginBottom = '15px;';
				document.getElementById("divError").style.borderColor = '#1CA831;';
				document.getElementById("divError").style.color = '#1CA831;';
				document.forms["formIns"].elements["txtMail"].focus();	
			}*/
		}
    }    
    
    if(method == "GET")
    {
        XhrObj.send(null);
    }
    else if(method == "POST")
    {
    	
        XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        XhrObj.send(data);
    }
}

function valider(div,val,typ)
{
	if(typ == 0)
		verifExist(div,"Pse="+val, "inscription3.php?id=0", "POST", "divError","");
	else
		verifExist(div,"Mail="+val, "inscription3.php?id=1", "POST", "divError","");
	bord(document.getElementById(div),1);
}

function requestInscr(pse,pass,mail,crea,nomcrea) 
{			
	var xhr_object = null; 
	var monurl;
	var mySex;
	
	if(window.XMLHttpRequest) // Firefox 
	   xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	   xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else 
	{ // XMLHttpRequest non supporté par le navigateur 
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); 
		return; 
	}
	
	if(document.forms["formIns"].elements["hidSex"].value == 'f')
		mySex = 'f';
	else
		mySex = 'h';
		
	//monurl = "inscription2.php?pse="+pse+"&pass="+pass+"&mail="+mail+"&crea="+crea+"&nomcrea="+nomcrea+"&sex="+mySex;
	XhrObj.open("POST", "inscription2.php");
	data = "pse="+pse+"&pass="+pass+"&mail="+mail+"&crea="+crea+"&nomcrea="+nomcrea+"&sex="+mySex;
	//xhr_object.open("GET",monurl, true);
	//Ouverture du fichier en methode POST
     
	
	xhr_object.onreadystatechange = function() 
	{ 
		if(xhr_object.readyState == 4)
		{	
			if(xhr_object.responseText == "0")
			{
				document.getElementById("divError").innerHTML = "Ce nom existe déjà, merci d'en trouver un autre...";
				document.getElementById("divError").style.visibility = 'visible';
				document.getElementById("divError").style.height = '17px;';
				document.getElementById("divError").style.marginBottom = '15px;';
				document.getElementById("divError").style.borderColor = 'red;';
				document.getElementById("divError").style.color = 'red;';
				document.forms["formIns"].elements["txtPse"].focus();	
			}
			else if(xhr_object.responseText == "1")
			{
				document.getElementById("divError").innerHTML = "Cet email existe déjà. Merci d'en changer.";
				document.getElementById("divError").style.visibility = 'visible';
				document.getElementById("divError").style.height = '17px;';
				document.getElementById("divError").style.marginBottom = '15px;';
				document.getElementById("divError").style.borderColor = 'red;';
				document.getElementById("divError").style.color = 'red;';
				document.forms["formIns"].elements["txtMail"].focus();	
			}
			else
			{
				document.getElementById("divError").innerHTML = "Entra&icirc;neur cr&eacute;&eacute;";
				document.getElementById("divError").style.visibility = 'visible';
				document.getElementById("divError").style.height = '17px;';
				document.getElementById("divError").style.marginBottom = '15px;';
				document.getElementById("divError").style.borderColor = '#1CA831;';
				document.getElementById("divError").style.color = '#1CA831;';
				document.forms["formIns"].elements["txtMail"].focus();	
			}
		} 
	} 	 
	
	//xhr_object.send(null); 
	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
     XhrObj.send(data);
}