// Ce script de tag n?cessite une div d'id "TagStats" dans la page appelante pour fonctionner.
// ex : <div id="TagStats" style="display:none;"></div>
function tagStat(tag){
var maDivStat=document.getElementById("TagStats");
codeStat='<img ALT="" src="http:\/\/e.pagesjaunes.fr\/m\/web\/231031167783?g=226026167793&&p='+tag+'&c=QUIDONC_PJ&st=0&sjs=0" border=0 width=1 height=1>';
	maDivStat.innerHTML = codeStat;				
}
 
// V?rification du t?l?phone
function check_tel(IdObj, IdAlerte, IdAlerteNomVide, IdAlerteNomLong, IdAlertePrenomLong, marqueur) {
	hide(IdAlerteNomVide);
	hide(IdAlerteNomLong);
	hide(IdAlertePrenomLong);
	var obj = document.getElementById(IdObj);
	var tel = obj.numeroTelephone.value;
	var interdit = false;
	var nc = 0;
	var tel2 = "";
	for (var i = 0; i < tel.length && !interdit; i++) {
		var c = tel.charAt( i );
		switch ( c ) {
			case ' ': break;
			case '0': nc++; tel2 += c; break;
			case '1': nc++; tel2 += c; break;
			case '2': nc++; tel2 += c; break;
			case '3': nc++; tel2 += c; break;
			case '4': nc++; tel2 += c; break;
			case '5': nc++; tel2 += c; break;
			case '6': nc++; tel2 += c; break;
			case '7': nc++; tel2 += c; break;
			case '8': nc++; tel2 += c; break;
			case '9': nc++; tel2 += c; break;
			default: interdit = true; break;
		}
	}
	if (interdit || nc != 10) {
		obj.numeroTelephone.blur();
		show(IdAlerte);
		return false;
	}
	obj.numeroTelephone.value = tel2;
	tagStat(marqueur);
	return true;
}

// V?rification du nom
function check_nfr(IdObj, IdAlerteNomVide, IdAlerteNomLong, IdAlertePrenomLong, IdACacher, marqueur) {
	hide(IdACacher);
	var obj = document.getElementById(IdObj);
	var nom = rmallsp(obj.nom.value);
	var prenom = rmallsp(obj.prenom.value);
    var i = 0;
    var correct = true;
    while (i < nom.length && nom.charAt(i)==' ') {
    	i++;
   	}
	if (i == nom.length) {
		obj.nom.blur();
		show(IdAlerteNomVide);
		correct = false;
	}
	if (nom.length > 55) {
		obj.nom.blur();
		show(IdAlerteNomLong);
		correct = false;
	}
	if (prenom.length > 55) {
		obj.nom.blur();
		show(IdAlertePrenomLong);
		correct = false;
	}
	if(correct) {
	tagStat(marqueur);
	}
	return correct;
}

// Suppression des espaces
function rmallsp(x) {
	var i = 0;
	var c='';
	for (i = 0; i<x.length; i++){
		if (x.charAt(i)!=' ')
		c = c + x.charAt(i)
	}
	return c
}

// Activation des formulaires
function change(iddiv, formcourant) {
	var classe = document.getElementById(iddiv).parentNode.className;
	if (classe.indexOf("form_qd_nfe") > 0 && formcourant == "inv") {
		document.getElementById(iddiv).parentNode.className = classe.replace("form_qd_nfe", "form_qd_inv");
	} else if (classe.indexOf("form_qd_inv") > 0 && formcourant == "nfe") {
		document.getElementById(iddiv).parentNode.className = classe.replace("form_qd_inv", "form_qd_nfe");
	}
}

// Validation du formulaire de recherche proxi
function validationRechercheProxi(idForm, idAlerte) {
	var correct = rmallsp(document.getElementById(idForm).quoiqui.value).length > 0;
	if (!correct) {
		document.getElementById(idForm).quoiqui.blur();
		show(idAlerte);
	}
	return correct;
}

// Validation du formulaire notreFamille.com
function validationFormulaireNotreFamille(idForm, idAlerte, url) {
	var form = document.getElementById(idForm);
	var correct = rmallsp(form.nom.value).length > 0;
	if (!correct) {
		document.getElementById(idForm).nom.blur();
		show(idAlerte);
	} else {
	var action = url + form.nom.value;	
	form.action = action;
	}
	
	return correct;
}
//-------------------------------------------

// Initialisation des evts forms
PJ_init_forms();
