﻿var typeRecherche = 2;

function selectByPays(pays, geonameid, nbDispo) 
{
    // PoseDebug();
    typeRecherche = 2;
    selectedPays2 = pays;
    nbResult2 = nbDispo;
    selectedCountry_code2 = geonameid;
    afficheResultat2();
    var RsltElem = document.getElementById("results");
    RsltElem.innerHTML = "";
    RsltElem = document.getElementById("bonPlansStyle");
    RsltElem.innerHTML = "";
}

function selectByCheminDeFer(pays, geonameid, nbDispo) 
{
    if (block2 == false) 
    {
        if (typeRecherche == 1) 
        {
            selectedCodeRegion1 = "";
            selectedServices1 = "all";
            selectedEtoiles1 = "";
            selectedTypeHebSpe1 = "";
            selectedRegion1 = "";
            selectedPays1 = pays;
            nbResult1 = nbDispo;
            selectedCountry_code1 = geonameid;
            afficheResultat1();
        }
        else
        {
            selectedPays2 = pays;
            nbResult2 = nbDispo;
            selectedServices2 = "all";
            selectedEtoiles2 = "";
            selectedTypeHebSpe2 = "";
            selectedRegion2 = "";
            selectedCountry_code2 = geonameid;
            afficheResultat2();
        }

        var RsltElem = document.getElementById("results");
        RsltElem.innerHTML = "";
        RsltElem = document.getElementById("bonPlansStyle");
        RsltElem.innerHTML = "";
    }
}

function selectByRegion(codeRegion, region)
{
    if (block2 == false)
    {
        var reg = new RegExp("( \\( [0-9]+ [a-zéèêëùûüãàäâ]+ \\))", "i");
        if (typeRecherche == 1) 
        {
            selectedCodeRegion1 = codeRegion;
            selectedRegion1 = region.replace(reg, "");
        }
        else 
        {
            selectedCodeRegion2 = codeRegion;
            selectedRegion2 = region.replace(reg, "");
        }
        afficheResultatStrict();
    }
}

function selectByTag(codeRegion, region) 
{

        var reg = new RegExp("( \\( [0-9]+ [a-zéèêëùûüãàäâ]+ \\))", "i");
        typeRecherche = 2;
        selectedPays2 = "FR";
        selectedCountry_code2 = "FR";
        selectedSemaine2 = "toutLeTemps";
        selectedCodeRegion2 = codeRegion;
        selectedRegion2 = region.replace(reg, "");
        var codeCheminDefer = "FR-France|" + codeRegion + "-" + region;
        afficheResultatStrict();

}


function selectByCritere() 
{
    document.getElementById("voile2").style.display = "block";
    if (block == false) 
    {

        // PoseDebug();
        var reg = new RegExp("( \\( [0-9]+ [a-zéèêëùûüãàäâ]+ \\))", "i");

        selectedServices = "";
        if (document.Form1.Service != null) 
        {
            for (i = 0; i < document.Form1.Service.length; i++) 
            {
                if (document.Form1.Service[i].checked == true)
                    selectedServices += document.Form1.Service[i].value.replace(reg, "") + ",";
            }
        }

        selectedEtoiles = "";

        if (document.Form1.Etoiles != null) 
        {
            for (i = 0; i < document.Form1.Etoiles.length; i++) 
            {
                if (document.Form1.Etoiles.options[i].selected == true)
                    selectedEtoiles += document.Form1.Etoiles.options[i].value;
            }
        }

        tri = 0;
        if (document.Form1.tricourant != null)
        {
            for (i = 0; i < document.Form1.tricourant.length; i++) {
                if (document.Form1.tricourant.options[i].selected == true)
                    tri += document.Form1.tricourant.options[i].value;
            }
        }
        if ((!(selectedHeb1 == 2) && typeRecherche == 1) || typeRecherche == 2) 
        {
            selectedTypeHebSpe = "";
            if (document.Form1.TypeHebSpe != null)
            {
                for (i = 0; i < document.Form1.TypeHebSpe.length; i++)
                 {
                    if (document.Form1.TypeHebSpe.options[i].selected == true)
                        selectedTypeHebSpe += document.Form1.TypeHebSpe.options[i].value;
                }
            }
        }

        if (typeRecherche == 1)
        { selectedServices1 = selectedServices; selectedTypeHebSpe1 = selectedTypeHebSpe; selectedEtoiles1 = selectedEtoiles; triCourant1 = tri;}
        else
        { selectedServices2 = selectedServices; selectedTypeHebSpe2 = selectedTypeHebSpe; selectedEtoiles2 = selectedEtoiles; triCourant2 = tri; }

        afficheResultatStrict();
    }
}

function afficheCheminDeFer(code) {
    var tableau = code.split('|');

    // PoseDebug();
    var RsltElem = document.getElementById("cheminDeFer");
    var chaine = "";

    if (tableau.length == 2) {
        var pays = tableau[0].split('@');
        nomPays = pays[1];
        codePays = pays[0];
        nbResultPays = pays[2];
        var region = tableau[1].split('@');
        nomRegion = region[1];
        codeRegion = region[0];
        chaine = "<a href=\"Default.aspx?lang=" + langCourante + "\">" + accueilRs + "</a> > <a href=\"javascript:selectByPays('" + nomPays + "','" + codePays + "','" + nbResultPays + "')\"> Camping " + nomPays + "</a> > Camping " + nomRegion;
    }
    else {
        var pays = tableau[0].split('@');
        nomPays = pays[1];
        codePays = pays[0];
        nbResultPays = pays[2];
        chaine = "<a href=\"Default.aspx?lang=" + langCourante + "\">" + accueilRs + "</a> > Camping " + nomPays;
    }

    RsltElem.innerHTML = chaine;
}