function checkApos(a){
 if (a.indexOf("'",0)!=-1) return true;
 return false;
}
function checkPointVirgule(a){
 if (a.indexOf(";",0)!=-1) return true;
 return false;
}
function wrongemail(email){ 
 if (email == '') return false;
 var atpl = email.indexOf("@",0)
 if (atpl < 1 ) return true;
 if (atpl == email.length - 1) return true;
 if (email.indexOf(".",atpl) < atpl + 2) return true;
 return false;
}
function checkInscription(){  
  var error="";  	
	
	if (document.mini_form.NOM.value=='')
		error = error + "Merci de renseigner votre nom.<br>";
  
  if (document.mini_form.PRENOM.value=='')
  	error = error + "Merci de renseigner votre prénom.<br>";
  
  if (document.mini_form.EMAIL.value=='')
    error = error + "Merci de renseigner votre email<br>";
	
	if (checkApos(document.mini_form.EMAIL.value))
    error +=  "Vous ne pouvez pas utiliser l'apostrophe dans votre adresse email<br>";
	
	if (wrongemail(document.mini_form.EMAIL.value))
		error = error + "Votre adresse email est erronée, merci de la resaisir.<br>";	    				
	
	// Check des telephones
	
	if (document.mini_form.TEL_PORT.value !=''){
		if(checkphone(document.mini_form.TEL_PORT.value) == false){	
			error = error + "Le format de votre numéro n'est pas valide.<br>";
		}
	}	
				
	if (document.mini_form.CODE_POSTAL.value !=''){
		if(isNaN(document.mini_form.CODE_POSTAL.value) || document.mini_form.CODE_POSTAL.value.length != 5){
			error = error + "Merci de renseigner un code postal valide.<br>";
		}
	}else{
		error = error + "Merci de renseigner votre code postal.<br>";
	}						
	
	if(document.mini_form.compteur.value == 0 && document.mini_form.TEL_PORT.value ==""){
		if (error == "") {			
			document.mini_form.compteur.value = 1;
		}
		error = error + "Merci de renseigner votre numéro de téléphone.<br>";
	}
															
  if (error != ''){  
	  var span = document.getElementById("Champ_erreur");
		span.innerHTML=error + "<br><input name=' Ok ' value='Ok' onClick=javascript:montre('') type='button' style=width:80px>";
		montre('smenu6');
  }
  else{
     document.mini_form.submit();
  }
}


function checkphone(phone){ 
 var retour, trouve;
 var typephone = new Array("01","02","03","04","05","06","08");
 trouve = 0;
 retour = false;
 //isNaN(document.form_inscription.PHONE.value)
 if (phone != ''){ 	 
 	phone = nettoie_phone(phone);
 	if(phone.length == 12 && phone.substring(0,3) == "+33"){
	 	phone = "0"+phone.substring(3,13) 		
	}
 	if(!isNaN(phone)){	 	
	 	if((phone.length == 10 && phone.substring(0,1) == "0")){
	 		// le numero est on bon format 		
	 		for(i=0;i<typephone.length;i++){ 				
	 				if(phone.substring(0,2) == typephone[i]){
	 					trouve = 1.
	 				}
	 		} 			 			
	 		if(trouve == 1){
	 			retour=true;
	 		}
	 	}
	 }
 }
 return retour; 
}

function nettoie_phone(phone){ 
	var separateurs = new Array(" ",".","-","/");
	for(i=0;i<separateurs.length;i++){ 
		while(phone.indexOf(separateurs[i])!= -1){
 	 		phone = phone.replace(separateurs[i],"");
 	 	}
	}
	return phone;
}
	