function remplacer(chaine,car,cqr)
{
	var chaine_retourner="";
	tableau_chaine=chaine.split(car);
	for (i=0;i<tableau_chaine.length;i++) {
		chaine_retourner+=tableau_chaine[i];
		if(i<tableau_chaine.length-1) chaine_retourner+=cqr;
	}
	return chaine_retourner;
}


function verifFormulaire(idFormulaire) 
{
	listeChamp = "";
	type = "";
	taille = "";
	variabledecoupe = "";
	variable = "";
	trouve = 0;
	variable_a_tester = eval("document.getElementById('COFormulaire"+idFormulaire+"').value");
	variableAvecAccent = eval("document.getElementById('COFormulaireAccent"+idFormulaire+"').value");
	var ok = 1;
	var liste_variable = variable_a_tester.split(",");
	var listeAvecAccent = variableAvecAccent.split("|");
	for (i = 0; i < liste_variable.length; i++) {
		if (liste_variable[i]) {
			variabledecouper = liste_variable[i].split("|");
			variable = variabledecouper[0];
			type = eval("document.getElementById(\""+variable+"\").type");
			if (type=="text" || type=="textarea" || type=="file") {
				trouve = 0;
				if (eval("document.getElementById(\""+variable+"\").value")) {
					trouve = 1;
				}
			} else if (type=="select-one" || type=="select-multiple") {
				taille = eval("document.getElementById(\""+variable+"\").options.length");
				for (a = 0; a < taille; a++) {
					trouve = 0;
					if (eval("document.getElementById(\""+variable+"\")["+a+"].selected")==true) {
						trouve = 1;
						break;
					}
				}
			}
			else if (type=="radio") {
				taille = eval("document.getElementById('formulaire"+idFormulaire+"')."+variable+".length");
				for(a = 0; a<taille; a++) {
					trouve = 0;
					if(eval("document.getElementById('formulaire"+idFormulaire+"')."+variable+"["+a+"].checked")==true) {
						trouve = 1;
						break;
					}
				}
			} else if(type=="checkbox") {
				trouve = 0;
				if(eval("document.getElementById('formulaire"+idFormulaire+"')."+variable+".checked")==true) {
					trouve = 1;
				} else {
					taille = eval("document.getElementsByName(\""+variable+"[]\").length");
					for (a = 1; a < taille; a++) {
						if (eval("document.getElementById('formulaire"+idFormulaire+"')."+variable+a+".checked")==true) {
							trouve = 1;
							break;
						}
					}
				}
			}


			if (!trouve) {
				ok = 0;							
				if (listeChamp) listeChamp+= ", ";
				listeChamp+=listeAvecAccent[i];
			}
		}
	}
	if (!ok) {
		listeChamp = remplacer(listeChamp,"_"," ");
		listeChamp = remplacer(listeChamp,"<br />","\n");
		alert(eval("document.getElementById('messageAlerte"+idFormulaire+"').value")+listeChamp);
		return false;
	} else return true;
}
