<!--

function selection_champs(champs, champs_affiche)
{
    // on récupère l'endroit sélectionner dans le select source
    selection = champs.selectedIndex;
    if (selection != -1)
	{
        // on cherche la place de notre champ (en fin ou à la place de la sélection)
		place = champs_affiche.length;
		if (champs_affiche.selectedIndex != -1)
		{
			place = champs_affiche.selectedIndex;
		}

        // on déselectionne tous les champs du select de destination où va être placer le(s) champ(s) selectionné(s)
        while (champs_affiche.selectedIndex != -1)
		{
            champs_affiche.options[champs_affiche.selectedIndex].selected = false;
        }

        while (champs.selectedIndex > -1)
		{
            if (champs.options[champs.selectedIndex].value == "Id_type_bien")
			{
                champs.options[champs.selectedIndex] = null;
                champs.form.Id_categorie_bien.options[0].select= true;
            }
			else
			{
                // on décale tous les champs
                for (i=champs_affiche.length; i>place; i--)
				{
                    champs_affiche.options[i] = new Option(champs_affiche.options[(i-1)].text, champs_affiche.options[(i-1)].value);
                }

                // on insère le champ selectionné
                champs_affiche.options[place] = new Option(champs.options[champs.selectedIndex].text, champs.options[champs.selectedIndex].value);
                champs.options[champs.selectedIndex] = null;
                champs_affiche.options[place].selected = true;

				place++;
            }
        }

        if (champs.length > 0)
		{
            if (selection >= champs.length)
			{
				// on met la sélection sur le dernier
                selection = champs.length - 1;
            }
            champs.options[selection].selected = true;
        }
    }
}

function priorite_champ(selection, mode)
{
    if (selection.length < 2)
	{
		return;
	}
    old_place = selection.selectedIndex;
    if (mode == 'up' && old_place > 0)
	{
        new_place = old_place - 1;
    }
	else if (mode == 'down' && old_place < selection.length-1)
	{
        new_place = old_place + 1;
    }
    
    tmp = new Option(selection.options[new_place].text, selection.options[new_place].value);
    selection.options[new_place] = new Option(selection.options[old_place].text, selection.options[old_place].value);
    selection.options[old_place] = new Option(tmp.text, tmp.value);
    selection.options[new_place].selected = true;
}

function select_all(frm)
{
//    for (i=0; i<frm.lstChpsAjouter.length; i++)
//	{
//        frm.lstChpsAjouter.options[i].selected = true;
//    }
//    frm.lstChpsAjouter.name = "lstChpsAjouter[]";

// Ajout de FIND
    if (frm.checkFind.checked == true)
    {
        if (frm.rechercheWeb.options.selectedIndex == 1)
        {
            frm.lstChpsOrdre.options[frm.lstChpsOrdre.length] = new Option("Yahoo", "Yahoo");
        }
        else
        {
            frm.lstChpsOrdre.options[frm.lstChpsOrdre.length] = new Option("Google", "Google");
        }
    }

// tri par défaut
    frm.lstChpsOrdre.options[frm.lstChpsOrdre.length] = new Option("Tri", "Tri");
    // Ville pour distance : on change 'Distance' par la ville
    if (frm.tridefaut.options[frm.tridefaut.options.selectedIndex].value == "Distance")
    {
        frm.lstChpsOrdre.options[frm.lstChpsOrdre.length] = new Option(frm.villeDist.options[frm.villeDist.options.selectedIndex].value, frm.villeDist.options[frm.villeDist.options.selectedIndex].value);
    }
    else
    {
        frm.lstChpsOrdre.options[frm.lstChpsOrdre.length] = new Option(frm.tridefaut.options[frm.tridefaut.options.selectedIndex].value, frm.tridefaut.options[frm.tridefaut.options.selectedIndex].value);
    }
  
// Select
    for (i=0; i<frm.lstChpsOrdre.length; i++)
	{  
        // Ville pour distance : on change 'Distance' par la ville
        if (frm.lstChpsOrdre.options[i].value == "Distance")
        {
            frm.lstChpsOrdre.options[i].value = frm.villeDist.options[frm.villeDist.options.selectedIndex].value;
        }
        frm.lstChpsOrdre.options[i].selected = true;
    }
    frm.lstChpsOrdre.name = "lstChpsOrdre[]";
	return true;
}

function testerLeSiteItineraire(strLaVille, strLeCodePostal, iIndex)
{
    if (strLaVille == "" && strLeCodePostal == "")
    {
        alert('Veuillez renseigner le champ \'Ville de départ de l\'itinéraire\' !');
    }
    else
    {
        // Au moins un des 2 champs est rempli
        if (iIndex == 0)
        {
            // Par Via Michelin
            // %20 pour les espace
            strMerge = strLaVille;
            if (strMerge == "")
                strMerge = strLeCodePostal;
            else if (strLeCodePostal != "")
                strMerge += '%20' + strLeCodePostal;
            window.open('http://www.viamichelin.fr/viamichelin/fra/dyn/controller/mapPerformPage?strCountry=1424&strMerged='+ strMerge);
        }
        else
        {
            // Par Google Maps
            strMerge = strLaVille;
            if (strMerge == "")
                strMerge = strLeCodePostal;
            else if (strLeCodePostal != "")
                strMerge += ',' + strLeCodePostal;
            window.open('http://maps.google.fr/maps?f=q&hl=fr&q=' + strMerge);
        }
    }
}

function VerifieChpTexte(check, val, chp)
{
	if (check.checked == true && val.value == "")
	{
		alert('Le champ ' + chp + ' est vide !');
		val.focus();
		return false;
	}
	return true;
}

function VerifieChpNombre(check, val, chp)
{
	if (check.checked == true)
	{
		if (val.value=="")
		{
			alert('Le champ ' + chp + ' est vide !');
			val.focus();
			return false;
		}
		else
		{
			for (i=0;i<val.value.length;++i)
			{
			   if (val.value.charAt(i) < "0" || val.value.charAt(i) > "9")
			   {
					alert('Le champ ' + chp + ' n\'est pas un nombre entier !');
					val.focus();
					return false;
			   }
			}
		}
	}
	return true;
}

function testrecherche(iTypeFind, theForm)
{
    if (iTypeFind == 1)
    {
        // Recherche par mot clé
        if (theForm.valFullText.value=="")
        {
            alert("Le champ 'MOT CLE' est vide !");
        }
        else if (theForm.valFullText.value.length < 4)
        {
            alert("Le champ 'MOT CLE' est trop court !");
        }
        else
        {
            theForm.submit();
            return true;
        }
    }
    else if (iTypeFind == 99)
    {
        if (theForm.checkNom.checked == true || theForm.checkVille.checked == true || theForm.checkRegion.checked == true || theForm.checkDepartement.checked == true || theForm.checkMassif.checked == true || theForm.checkAltMax.checked == true || theForm.checkDenivele.checked == true || theForm.checkLongueur.checked == true || theForm.checkTpsApproche.checked == true || theForm.checkTpsVia.checked == true || theForm.checkTpsRetour.checked == true || theForm.checkPrix.checked == true || theForm.checkEnfants.checked == true || theForm.checkCoteClassique.checked == true || theForm.checkClassification.checked == true || theForm.checkPasserelle.checked == true || theForm.checkPontNepalais.checked == true || theForm.checkPontSinge.checked == true || theForm.checkPoutre.checked == true || theForm.checkEchelle.checked == true || theForm.checkFilet.checked == true || theForm.checkTyrolienne.checked == true || theForm.checkCochon.checked == true || theForm.checkDistance.checked == true)
        {
			if (VerifieChpTexte(theForm.checkNom,theForm.valNom,"'Nom'") == false)
				return false;
			if (VerifieChpTexte(theForm.checkVille,theForm.valVille,"'Ville'") == false)
				return false;
			if (VerifieChpTexte(theForm.checkMassif,theForm.valMassif,"'Massif'") == false)
				return false;
			if (VerifieChpNombre(theForm.checkAltMax,theForm.valAltMax,"'Altitude max.'") == false)
				return false;
			if (VerifieChpNombre(theForm.checkDenivele,theForm.valDenivele,"'Dénivelé'") == false)
				return false;
			if (VerifieChpNombre(theForm.checkLongueur,theForm.valLongueur,"'Longueur'") == false)
				return false;
			if (VerifieChpNombre(theForm.checkTpsApproche,theForm.valTpsApproche,"'Temps d'approche'") == false)
				return false;
			if (VerifieChpNombre(theForm.checkTpsVia,theForm.valTpsVia,"'Temps Via'") == false)
				return false;
			if (VerifieChpNombre(theForm.checkTpsRetour,theForm.valTpsRetour,"'Temps du retour'") == false)
				return false;
			if (VerifieChpNombre(theForm.checkDistance,theForm.valDistance,"'Distance'") == false)
				return false;
            
			theForm.submit();
			return true;
        }
        else
        {
            alert('Choisissez au moins un critère de recherche !');
        }
    }
    return false;
}

-->
