/**
 *	@author		gregory
 *	@description	contrôle du formulaire pour le bulletin d'inscription des entreprises
 *	@info		on peut se servir de prototype
 */

function controleBulletinInscription(nombre_input) {
	var tableau_champ_a_controler = new Array(
						"nom_intervenant_" , 
						"prenom_intervenant_", 
						"fonction_intervenant_",
						"arrivee_",
						"horaire_arrivee_",
						"depart_",
						"horaire_depart_"
					);
	for(var i = 1; i <= nombre_input ; i++) {
		var ligne_ok = true;
		for (var j = 0 ; j < tableau_champ_a_controler.length ; j++) {
			if ($(tableau_champ_a_controler[j] + i).value == '') {
				Element.show('non_statut_intervenant_' + i);
				Element.hide('oui_statut_intervenant_' + i);
				ligne_ok = false;
			}
		}
		if (ligne_ok == true) {
			Element.hide('non_statut_intervenant_' + i);
			Element.show('oui_statut_intervenant_' + i);
		}
	}
}


function affichageParticipants(nombre_participants_theoriques, max_participants) {
	if (nombre_participants_theoriques != '') {
		Element.show('tableau_participants_reels');
		for (var i = 1 ; i <= nombre_participants_theoriques ; i++) {
			Element.show('ligne_participant_' + i);
		}
		if (nombre_participants_theoriques < max_participants) {
			var j = parseInt(nombre_participants_theoriques) + 1;
			for (var i = j ; i <= max_participants ; i++) {
				Element.hide('ligne_participant_' + i);
			}
		}
	} else {
		Element.hide('tableau_participants_reels');
	}
}


function verifierToutLeBulletin() {
	if ($('nombre_intervenants_theorique').value == '') 
	{
		alert('Vous devez spécifier un nombre d\'intervenants théoriques');
		return false;
	} else {
		// on demande si le fait de ne pas remplir les participants effectifs est une erreur ou pas 
		for (var i = 1 ; i <= $('nombre_intervenants_theorique').value ; i++)
		{
			if ($('oui_statut_intervenant_' + i).style.display == "none") 
			{
				if (!confirm('Vous avez ' + $('nombre_intervenants_theorique').value  + ' intervenant(s) théorique(s), mais l\'intervenant effectif ' + i + ' n\'est pas valide. Il sera donc ignoré. Continuer ?')) 
				{
					alert('Formulaire non envoyé, nous vous invitons à le compléter');
					return false;
				} 
			}
		}
	}
	if ($('choix_standiste').value == '')
	{
		alert('Vous devez choisir un standiste');
		return false;
	}
	if ($('veut_mobilier_scolaire').checked == true)
	{
		if ($('nombre_chaises').value=="") 
		{
			alert('Vous désirez du mobilier scolaire mais vous n\'avez pas indiqué le nombre de chaises');
			return false;
		}
		if ($('nombre_tables').value=="") 
		{
			alert('Vous désirez du mobilier scolaire mais vous n\'avez pas indiqué le nombre de tables');
			return false;
		}
	}
	return true;
}
