//fonction de controle

// initialisation des controles et des blocages, 
// et je determine aussi tous les champs et leur controle respectif
function init () {
	
	//if ( document.getElementById("menu") ) initMenu();
	
	formulaire   = document.getElementById("form-devis");

	tabchamps    = new Array();
	//											[types de controle : date-, date+, ouinon, liste, tel, email]
	//														[types de blocage : date, chiffre, texte]
	//																							type			alert			Controle de groupe
	//				nom du champs	requis		controle 		blocage		ligne				coherence		incoherence		sur une ligne
 	tabchamps[0]   = ["sexe1", 		"requis",	"liste",		"", 		"scol1-ligne", 		"", 			"", 			true];
	tabchamps[1]   = ["nom1", 		"requis",	"texte+capAll",	"texte", 	"scol1-ligne",		"",				"", 			true];
	tabchamps[2]   = ["prenom1", 	"requis",	"texte+capAll",	"texte", 	"scol1-ligne",		"",				"", 			true];
	tabchamps[3]   = ["datnai1", 	"requis",	"-25ans",		"date", 	"scol1-ligne", 		"",				"", 			true];
	tabchamps[4]   = ["situation1", "requis",	"liste",		"", 		"scol1-ligne", 		"verif_ligne_scolaire", 	"", true];
	
	tabchamps[5]   = ["sexe2", 		"requis",	"liste",		"", 		"scol2-ligne", 		"", 			"", 			true];
	tabchamps[6]   = ["nom2", 		"requis",	"texte+capAll",	"texte", 	"scol2-ligne",		"",				"", 			true];
	tabchamps[7]   = ["prenom2", 	"requis",	"texte+capAll",	"texte", 	"scol2-ligne",		"",				"", 			true];
	tabchamps[8]   = ["datnai2", 	"requis",	"-25ans",		"date", 	"scol2-ligne", 		"",				"", 			true];
	tabchamps[9]   = ["situation2", "requis",	"liste",		"", 		"scol2-ligne", 		"verif_ligne_scolaire", 	"", true];
	
	tabchamps[10]   = ["sexe3", 		"requis",	"liste",		"", 	"scol3-ligne",	 	"", 			"", 			true];
	tabchamps[11]   = ["nom3", 		"requis",	"texte+capAll",	"texte", 	"scol3-ligne",		"",				"", 			true];
	tabchamps[12]   = ["prenom3", 	"requis",	"texte+capAll",	"texte", 	"scol3-ligne",		"",				"", 			true];
	tabchamps[13]   = ["datnai3", 	"requis",	"-25ans",		"date", 	"scol3-ligne", 		"",				"", 			true];
	tabchamps[14]   = ["situation3", "requis",	"liste",		"", 		"scol3-ligne", 		"verif_ligne_scolaire", 	"", true];
	
	tabchamps[15]   = ["sexe4", 		"requis",	"liste",		"", 	"scol4-ligne", 		"", 			"", 			true];
	tabchamps[16]   = ["nom4", 		"requis",	"texte+capAll",	"texte", 	"scol4-ligne",		"",				"", 			true];
	tabchamps[17]   = ["prenom4", 	"requis",	"texte+capAll",	"texte", 	"scol4-ligne",		"",				"", 			true];
	tabchamps[18]   = ["datnai4", 	"requis",	"-25ans",		"date", 	"scol4-ligne", 		"",				"", 			true];
	tabchamps[19]   = ["situation4", "requis",	"liste",		"", 		"scol4-ligne", 		"verif_ligne_scolaire", 	"", true];
	
	tabchamps[20]   = ["sexe5", 		"requis",	"liste",		"", 	"scol5-ligne", 		"", 			"", 			true];
	tabchamps[21]   = ["nom5", 		"requis",	"texte+capAll",	"texte", 	"scol5-ligne",		"",				"", 			true];
	tabchamps[22]   = ["prenom5", 	"requis",	"texte+capAll",	"texte", 	"scol5-ligne",		"",				"", 			true];
	tabchamps[23]   = ["datnai5", 	"requis",	"-25ans",		"date", 	"scol5-ligne", 		"",				"", 			true];
	tabchamps[24]   = ["situation5", "requis",	"liste",		"", 		"scol5-ligne", 		"verif_ligne_scolaire", 	"", true];
	
	
	if (no_restit != 2 && no_restit != 3 && no_restit != 4 && no_restit != 5) afficher_ou_masquer_un_champ (["sexe2","nom2","prenom2","datnai2","situation2"], ["scol2-ligne","scol2-fieldset"], "masquer");
	if (no_restit != 3 && no_restit != 4 && no_restit != 5) afficher_ou_masquer_un_champ (["sexe3","nom3","prenom3","datnai3","situation3"], ["scol3-ligne","scol3-fieldset"], "masquer");
	if (no_restit != 4 && no_restit != 5) afficher_ou_masquer_un_champ (["sexe4","nom4","prenom4","datnai4","situation4"], ["scol4-ligne","scol4-fieldset"], "masquer");
	if (no_restit != 5) afficher_ou_masquer_un_champ (["sexe5","nom5","prenom5","datnai5","situation5"], ["scol5-ligne","scol5-fieldset"], "masquer");

	
	document.getElementById("btn_enlever").style.display = "none";

	no_courant = 1;
	
	restit()
	
}

function restit() {
		
	for (var i=1; i<=no_restit-1; i++){
		
		ajouter_enfant(i);
	}	

}

function ajouter_enfant() {
		var nbre_max = 5;
		
		if ( no_courant < 5 ) {
		
			no_courant++
			afficher_ou_masquer_un_champ (["sexe"+no_courant,"nom"+no_courant,"prenom"+no_courant,"datnai"+no_courant,"situation"+no_courant], ["scol"+no_courant+"-ligne","scol"+no_courant+"-fieldset"], "afficher");
			
			formulaire["nom"+no_courant].value = formulaire["nom"+1].value
			
			document.getElementById("btn_enlever").style.display = "block";
			
		}
		if ( no_courant == 5 ) {
			document.getElementById("btn_ajouter").style.display = "none";
		}
		
	}
	
function enlever_enfant() {

		if ( no_courant > 1 ) {
		
			afficher_ou_masquer_un_champ (["sexe"+no_courant,"nom"+no_courant,"prenom"+no_courant,"datnai"+no_courant,"situation"+no_courant], ["scol"+no_courant+"-ligne","scol"+no_courant+"-fieldset"], "masquer");
			
			no_courant--
			document.getElementById("btn_ajouter").style.display = "block";
		}
		
		if ( no_courant == 1 ) {
			document.getElementById("btn_enlever").style.display = "none";
		}

}


function verif_ligne_scolaire (objet) {
	var message1 = "Nous ne disposons pas de toutes les informations concernant votre 1er enfant !!!"
	var message2 = "Nous ne disposons pas de toutes les informations concernant votre 2e enfant !!!"
	var message3 = "Nous ne disposons pas de toutes les informations concernant votre 3e enfant !!!"
	var message4 = "Nous ne disposons pas de toutes les informations concernant votre 4e enfant !!!"
	var message5 = "Nous ne disposons pas de toutes les informations concernant votre 5e enfant !!!"
	
	var no = objet.name.substring(objet.name.length,objet.name.length-1)
	
	//if (formulaire["situation"+no].value == "ES") {
	//	tabchamps[no*5-1][6] = "Les enfants de niveau sup\u00e9rieur ne sont pas accept\u00e9s";
	//	return false;
	//}
	
	tabchamps[no*5-1][6] 	= eval("message"+no)
	
	if (formulaire["sexe"+no].value != "-1" 
	&& formulaire["nom"+no].value != "" 
	&& formulaire["prenom"+no].value != "" 
	&& formulaire["datnai"+no].value.length == 10 
	&& formulaire["situation"+no].value != "-1" ) {
	return true;
	}else{
	return false;
	}
}


///////////////////////////////////////////////////////////////
/////////////////////////// PREVU POUR ETRE DANS LA PAGE
///////////////////////////////////////////////////////////////

//no_restit = 1; //deplacer sur la page



