﻿function changePays(a) {
    var b = $$(".liste_region");
    for (i = 0; i < b.length; i++) {
        b[i].style.display = "none";
    }
    if (dgbi("liste_region_" + a)) {
        dgbi("liste_region_" + a).style.display = "inline";
        region = dgbi("liste_region_" + a).value;
    }
    else {
        region = "";
    }
    pays = a;

    var c = $$(".liste_dept");
    for (j = 0; j < c.length; j++) {
        c[j].style.display = "none";
    }
    dept = "";
}

function changeRegion(a) {
    region = a;

    var b = $$(".liste_dept");
    for (i = 0; i < b.length; i++) {
        b[i].style.display = "none";
    }
    if (dgbi("liste_dept_" + a)) {
        dgbi("liste_dept_" + a).style.display = "inline";
    }
    region = a;
    if (dgbi("liste_dept_" + a)) {
        dept = dgbi("liste_dept_" + a).value;
    }
    else {
        dept = "";
    }
}
function changeDept(a) {
    dept = a;
}

var searchForm;
function init() {

    var trad_camping_search = tradPage.GetTrad('camping_name');

    searchForm = new SearchForm(url_result);
    searchForm.SetPopup(false);

    Event.observe('tb_nom_camping', 'focus', function (e) {
        if (this.value == trad_camping_search) { this.value = ''; this.className = 'active'; };
    });
    Event.observe('tb_nom_camping', 'blur', function (e) {
        if (this.value == "") { this.value = trad_camping_search; this.className = 'inactive'; };
    });

    //searchForm.SetMode1(id_hf_territoire, id_tb_lieux, 'tb_lat', 'tb_lon', 'VarRetour', 'div_detail_all', url_detail_lieux);
    selectSejour = new SelectSejour("", "cal1Date1", "cal1Date2");

    //searchForm.ActiverRechercheCamping('tb_nom_camping', 'autocomplete_container', 'id_etablissements', url_detail_lieux, 'tb_lat', 'tb_lon');
    

    searchForm.tab_panel_checkbox.push(new PanelCheckbox("h_sub_type", "cbSubType", false, false, "sous type"));
    addPanelCheckBox("cbService", "h_categories", false, false, " service");
}

function eraseDate(b, a) {
    dgbi(b).value = "";
    dgbi(a).value = "";
}
function resetList(a) {
    dgbi(a).value = "";
}
function changePrix(a) {
    dgbi("tb_price_max").value = a;
    if (a == "5000") {
        dgbi("tb_price_min").value = "800";
    }
}
function checkFormQuickSearch(g) {
    if (dgbi("tb_nom_camping").value != "" && dgbi("tb_nom_camping").value != trad_pres_qs) {
        sendRequest(g);
    }
}
function checkForm(g) {
    if ($('cal2Date1')) {
        if ($('cal2Date1').value != '') $('cal2Date1').value = '';
        if ($('cal2Date2').value != '') $('cal2Date2').value = '';
    }
    var e = dgbi("productTypes");
    e.value = "";
    var b = $$(".cbProductType");
    for (c = 0; c < b.length; c++) {
        if (b[c].checked) {
            e.value += b[c].value + "|";
        }
    }
    if (dgbi("territories") != "" && dgbi("territories") != null) {
        var d = dgbi("territories");
        if (pays != "") {
            d.value = pays;
        }
        if (region != "") {
            d.value = region;
        }
        if (dept != "") {
            d.value = dept;
        }

        if (pays == "" && region == "" && dept == "") {
            return false;
        }
        if (pays == "FR" && region == "" && dept == "") {
            return false;
        }
    }
    var a = searchForm.tab_panel_checkbox.length;
    for (var c = 0; c < a; c++) {
        if (!searchForm.tab_panel_checkbox[c].EcireDansHiddenField()) {
            return false;
        }
    }
    codeError = selectSejour.VerifDate();
    if (codeError > 0) {
        var f = "";
        switch (codeError) {
            case 1: f = tradPage.GetTrad("erreur_date1"); break;
            case 2: f = tradPage.GetTrad("erreur_date2"); break;
            case 3: f = tradPage.GetTrad("erreur_date3"); break;
            case 4: f = tradPage.GetTrad("erreur_date4"); break;
            case 5: f = tradPage.GetTrad("erreur_date5"); break;
            case 6: f = tradPage.GetTrad("erreur_date6"); break;
            case 7: f = tradPage.GetTrad("erreur_date7"); break
        }
        if (f != "") {
            return false;
        }
    }
    tabSearchFieldPI = getElementsByClassName("searchFieldPI");
    for (c = 0; c < tabSearchFieldPI.length; c++) {
        tabSearchFieldPI[c].name = "";
    }

    $('tb_nom_camping').value = "";
    sendRequest(g);
}

function checkFormBulle(c) {
    selectSejour = new SelectSejour("", "cal1Date1", "cal1Date2");
    var a = selectSejour.VerifDate();
    if (a > 0) {
        var b = "";
        switch (a) {
            case 1: b = tradPage.GetTrad("erreur_date1");
                break;
            case 2: b = tradPage.GetTrad("erreur_date2");
                break;
            case 3: b = tradPage.GetTrad("erreur_date3");
                break;
            case 4: b = tradPage.GetTrad("erreur_date4");
                break;
            case 5: b = tradPage.GetTrad("erreur_date5");
                break;
            case 6: b = tradPage.GetTrad("erreur_date6");
                break;
            case 7: b = tradPage.GetTrad("erreur_date7");
                break;
        }
        if (b != "") {
            open_bulle(b)
        }
        return false;
    }
}
document.write('<div id="bulle" class="infos_bulle"></div>');
document.onmousemove = move_bulle;
var isVisible = false;
function ElementId(a) {
    return document.getElementById(a)
}
function move_bulle(a) {
    if (isVisible) {
        if (navigator.appName != "Microsoft Internet Explorer") {
            ElementId("bulle").style.left = 5 + a.pageX + "px"; ElementId("bulle").style.top = 15 + a.pageY + "px";
        }
        else {
            ElementId("bulle").style.left = 5 + event.x + document.documentElement.scrollLeft + "px";
            ElementId("bulle").style.top = 15 + event.y + document.documentElement.scrollTop + "px";
        }
    }
}
function open_bulle(a) {
    if (isVisible == false) {
        ElementId("bulle").style.visibility = "visible";
        ElementId("bulle").innerHTML = a;
        move_bulle(ElementId("bulle"));
        isVisible = true;
    }
}
function close_bulle() {
    if (isVisible == true) {
        ElementId("bulle").style.visibility = "hidden";
        isVisible = false;
    }
};


//Recherche par nom de camping a l'appuie sur entrée
function goCampsitePageWhenPressEnter(e) {


    var mesObjets = $$('.autocomplete_item_highlighted');

    //si la touche est la touche entrée
    if (e.keyCode == 13 && mesObjets != 'undefined') {
        var onclickFunction = mesObjets[0].onclick;
        onclickFunction();

    }
}



