// Raffraichissement de la liste des codes postaux
function afficherListeVille(){ 	
	$.ajax({ 
		url: "/index.php/souscrire/comboville?cp="+$("#prefon_souscription_coordonnee_code_postal").val(), 
		cache: false, 
		success:function(html){afficher(html,"#ville");},
		error:function(XMLHttpRequest, textStatus, errorThrows){ 
			//alert('Une erreur est survenue lors de la recherche de votre ville.');
		}
	});		
}
function afficherListeDepartement(){ 	
	$.ajax({ 
		url: "/index.php/souscription_coordonnees/combodepartement?ville="+$("#prefon_souscription_coordonnee_lieu_de_naissance").val(), 
		cache: false, 
		success:function(html){afficher(html,"#departement");},
		error:function(XMLHttpRequest, textStatus, errorThrows){ 
			alert('Une erreur est survenue durant l\'éxécution de la requête ajax.');
			}
	});		
}

//Affiche le champ nom de jeune fille
$(document).ready(function() {
	elt10 = $("#prefon_souscription_coordonnee_civilite_0");
	elt11 = $("#prefon_souscription_coordonnee_civilite_1");
	elt12 = $("#prefon_souscription_coordonnee_civilite_2");
	elt2 = $("#nom_jeune_fille");
	if(elt10.is(':checked'))
		elt2.show();
	else elt2.hide();
	$(elt10).click(function(){
		if(elt10.is(':checked'))
			elt2.show();	   
	});
	$(elt11).click(function(){
		if(elt11.is(':checked'))
			elt2.hide();	   
	});
	$(elt12).click(function(){
		if(elt12.is(':checked'))
			elt2.hide();	   
	});
});


function VerifFormulaire(){ 	
	 if(document.form.civilite.value =="0")
		 alert("mme");

		
}

function afficherAideContextuelleM($val){ 	
	$.ajax({ 
		url: "aide?saisie="+$val, 
		cache: false, 
		success:function(html){afficher(html,"#aide".$val);},
		error:function(XMLHttpRequest, textStatus, errorThrows){ 
			alert('Une erreur est survenue durant l\'éxécution de la requête ajax.');
			}
	});		
}

var gk=window.Event?1:0;
var toucheDesac=255;
var focusSuivant = $('#prefon_souscription_coordonnee_ville');
function toucheenter(e) {
	var touche=gk?e.which:window.event.keyCode; //pour compatibilité FF IE
	if (touche == toucheDesac){
		document.getElementById(focusSuivant).focus();
		return false;
	}
}
document.onkeydown = toucheenter;


function afficher(donnees,template){ 	
	$(template).empty(); 
	$(template).append(donnees);
}
