var liste_div_criteres = new Array("crit_texte_interdit");

function verifieRecherche()
{
	//var formulaire = document.getElementById('form_recherche');
	//alert (formulaire);
	var elementList = Form.getElements("form_recherche");
	var critere = false;

	for (i=0; i < elementList.length; i++)
	{
		//On élimine les champs de type hidden, checkbox et button
		if ( (elementList[i].type == 'hidden')
				|| (elementList[i].type == 'button')
				|| (elementList[i].type == 'checkbox'))
		{
			if (elementList[i].name == 'organisation' && elementList[i].checked == true)
			{
				//alert(elementList[i].name + '--> '+elementList[i].checked);
				//alert('evite : ' + elementList[i].type + '--> ' + elementList[i].value);
				critere = true;
			}
		}
		else
		{
			if (elementList[i].value != '' && elementList[i].name != 'liste_1_formacode')
			{
				//alert('selectioné : ' + elementList[i].type + '--> ' + elementList[i].value);
				critere = true;
			}
		}
	}
	if (critere == false)
	{
		alert('Vous devez utiliser au moins un critère pour lancer la recherche.');
	}
	else
	{
		document.recherche.operation.value = 'RECHERCHE';
		document.recherche.submit();
	}

}

function gereDivAff()
{
	var d = document.getElementsByClassName('critere_aff2');
	var a = $('href_crit');

	if (d[0].style.display == 'none')
	{
		$('aff').value = 2;
		for (i=0; i < d.length; i++)
		{
			Element.show(d[i]);
		}
		Element.update(a, 'Moins de critères')
	}
	else
	{
		$('aff').value = 1;
		for (i=0; i < d.length; i++)
		{
			Element.hide(d[i]);
		}
		Element.update(a, 'Plus de critères')
	}
}

function afficheDiv(theDivId) {
	var d = document.getElementById(theDivId);
	if (d.style.display == 'none')
		d.style.display = "inline";
}
function masqueDiv(theDivId){
	var d = document.getElementById(theDivId);
	if (d.style.display == 'inline')
		d.style.display = "none";
}


function effectue_operation(operation) {

	//var index_formacode1 = $("formacode_crit");
	var index_formacode = document.getElementById("formacode_crit").value.length;
	var index_formacode2 = document.getElementById("liste_1_formacode").value;
	var index_formacode3 = document.getElementById("liste_2_formacode").value;
	//var index_formacode3 = document.forms.recherche.formacode.value;

//alert(index_formacode);
	//alert(index_formacode2 + " " + index_formacode3);

	if (((index_formacode > 1) && (index_formacode < 11) && (index_formacode != "")) || (index_formacode2 == index_formacode3) ) {
		alert("Attention, vous devez préciser un deuxième domaine de formation pour pouvoir lancer la recherche.");
	} else {

		verifieRecherche();
	}

}