/**
 * A chaque modification du libellé d'une ville on vide la valeur des champs hidden
 */
var changementville = function(id) {
	$('#f_id_ville_'+id).val('');
	$('#f_code_postal_'+id).val('');

}




/**
* fonction callback réussit par defaut 
*/
var selectionnerVille = function(data) {
	
	/* on retrouve ici le parent dont on va pouvoir récuperer l'ID 
	* afin de regler le champs f_id_ville_n
	*/

	tlId = $(this).attr("v_id");
	
	toolTipSuppression($(this).attr('id'));
	$(this).attr('title','Ville valide');
	$(this).removeClass("classerreur");
	// trouver format generique "normal"
	$(this).css('color','#000000'); 
	$(this).css('font-weight','normal'); 
		
	nomVille = $(this).attr('id');
	nomVoisin = 'f_id_voisin'+tlId;
	nomQuartier = 'f_quartier_'+tlId;
	nomCp = 'f_code_postal_'+tlId;

	// on l'utilise pour régler le hidden correspondant
	$('#f_id_ville_'+tlId).val(data.id);

	// on règle aussi le code postal 
	$('#f_code_postal_'+tlId).val(data.code_postal);

	/* Recherche le nombre de personnes */
	if(typeof(objCampagneCritere)!='undefined') {
		objCampagneCritere.recupereNombrePersonne();
	}

};


/**
* fonction callback en echec par defaut 
*/

var villeInvalide = function(data)
{
	// récuperation de l'id
	tlId = $(this).attr("v_id");
	
	$('#f_id_ville_'+tlId).val('');
	
	// on n'agit que si le nom fait au moins 3 char
	if ($(this).val().length >= 3) {
		$(this).addClass("classerreur");
		$(this).attr('title','Ville non trouvée, merci de retenter');
		toolTip($(this).attr('id'),message_invalide);//

	}
};
