function Val()
{
	var tabNChps = new Array("sociéte","nom","adresse","code postal","commune","téléphone","votre email"); // intitulés des champs
	var tabChps  = new Array("soc","nom","adr","cod","vil","tel","ema"); // noms des champs
	var tabTyps	 = new Array("","","","5","","10","E"); // types => 0:pas de restriction, T:texte, 5:valeur numérique de 5 carac , E:email
	var form	 = document.inscription;
	var alerte	 = "";
	
	for(n=0; n < tabChps.length; n++){
		var champs = eval("form."+tabChps[n]+".value"); // expression		
		if(champs == "") alerte += "- "+tabNChps[n]+"\n"; // champs vide		
		else{ // champs complété : vérifation saisie
			switch(tabTyps[n]){
				case 'T': // texte
					if(!isNaN(champs)) alerte += "- "+tabNChps[n]+" est incorrect\n";
					break;
				case 'E': // email
					var modele = /^[a-zA-Z0-9\.\-_]+@[a-zA-Z0-9]+\.[a-zA-Z]{2,5}$/i;
					if(!modele.test(champs)) alerte += "- "+tabNChps[n]+" n'est pas valide\n";
					break;
				case '':				
					break;
				default : // numerique
					if(isNaN(champs)) alerte += "- "+tabNChps[n]+" est incorrect\n";
					else{if(champs.length != tabTyps[n]) alerte += "- "+tabNChps[n]+" n'est pas valide\n";}
					break;
			}
		}
	}	
	
	if(alerte != ""){ // erreur
		var alerte = "Veuillez compléter les informations suivantes :\n"+alerte;
		alert(alerte);
	}	
	else
		{
			if(form.mention.checked==false){alert("Vous devez accepter les conditions générales d'utilisation");}
			else {form.submit();}
		}
}

function sendData(data,page,cible){
	if(document.all){var XhrObj = new ActiveXObject("Microsoft.XMLHTTP");}else{var XhrObj = new XMLHttpRequest();}
	var content = document.getElementById(cible);
	XhrObj.open("POST", page, true);
	XhrObj.onreadystatechange = function(){if(XhrObj.readyState == 4 && XhrObj.status == 200)content.innerHTML = XhrObj.responseText;}
	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	XhrObj.send(data);}

function IsNum(evt){
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57)){return false;}else{return true;}}
	 
function GetVille(what)
{
	if(what.length == 5){
		data = "cp="+what;
		sendData(data,"inc/getville.php","action");
	}
	else
	{
		document.inscription.vil.disabled = true; 
		document.inscription.vil.length = 0;
	}
}
