    /**
    * Remplissage de la select box des dispos sur la fiche produit.
    * @param dispoSelectBoxName dispo select box name
    * @param citySelectBoxName city select box name
    * @param disposArray array of all js dispos objects
    * @param selectedDispo option dispo to select (from salesprocess)
    */
    function fillSelectBoxDispo(dispoSelectBoxName, citySelectBoxName, disposArray, selectedDispo) {

        // On recupere le code de la ville selectionnée
        var selectedDepCityCode = document.getElementById(citySelectBoxName).options[document.getElementById(citySelectBoxName).selectedIndex].value;


        // Suppression des anciennes Options
        document.getElementById(dispoSelectBoxName).length = 0;

        // Ajout des nouvelles Options
        var optionIndex = 0;
        var strOld = "" ;
        var basePriceIndex=0;
        var basePrice=0;
        var dispoFromUrl = retrieveAvailibilityCodeFromUrl();
        var cityFromUrl = retrieveCityCodeFromUrl();
        var dateFromUrl = retrieveDepartureDateFromUrl();
        if (dispoFromUrl !== null && dispoFromUrl !== "" && cityFromUrl === selectedDepCityCode) {
            for (var i = 0; i < disposArray.length; i++) {
                 if (disposArray[i].depCityCode == selectedDepCityCode) {
                     if (strOld != disposArray[i].stringInValue()) {
                        document.getElementById(dispoSelectBoxName).options[optionIndex] = new Option(disposArray[i].toString(), disposArray[i].stringInValue());
                        if (disposArray[i].stringInValue() === dispoFromUrl) {
                            basePriceIndex = optionIndex;
                        }
                        optionIndex++;
                        strOld = disposArray[i].stringInValue();
                    }
                 }
            }
        } else {
            var hasDispoByDefault = false;
            for (var j = 0; j < disposArray.length; j++) {
                if (disposArray[j].depCityCode == selectedDepCityCode) {
                    if (strOld != disposArray[j].stringInValue()) {
                        document.getElementById(dispoSelectBoxName).options[optionIndex] = new Option(disposArray[j].toString(), disposArray[j].stringInValue());
                        if (!hasDispoByDefault) {
                            if (dispoFromUrl !== null && dispoFromUrl !== "" && dateFromUrl !== null && disposArray[j].stringInValue() === dispoFromUrl) {
                                basePriceIndex = optionIndex;
                                hasDispoByDefault = true;
                            }
                            else {
                                if (optionIndex === 0) {
                                    basePrice = disposArray[j].price;
                                }
                                else {
                                    var currentPrice = disposArray[j].price;
                                    if (parseInt(basePrice, 10) > parseInt(currentPrice, 10)) {
                                        basePrice = disposArray[j].price;
                                        basePriceIndex = optionIndex;
                                    }
                                }
                            }
                        }
                        optionIndex++;
                        strOld = disposArray[j].stringInValue();
                    }
                }
            }
        }
        document.getElementById(dispoSelectBoxName).selectedIndex=basePriceIndex;
        if( document.getElementById(dispoSelectBoxName).length === 0){
            document.getElementById(dispoSelectBoxName).options[0] = new Option("Choisissez votre date de départ", '');
        }
    }


    function updateDateSelectBox(id) {
        if(id=='1'){
       document.getElementById('dateDepContent2').value=document.getElementById('dateDepContent1').value;
       document.getElementById('disponibility1').value=document.getElementById('dateDepContent2').value;
       document.getElementById('disponibility2').value=document.getElementById('dateDepContent2').value;}
       else{
       document.getElementById('dateDepContent1').value=document.getElementById('dateDepContent2').value;
       document.getElementById('disponibility2').value=document.getElementById('dateDepContent2').value;
       document.getElementById('disponibility1').value=document.getElementById('dateDepContent2').value;}
    }

    /**
    * mise en relation des select box des modules de reservation
    * @param source  identificator of the source select box
    * @param dest  identificator of the destination select box
    * @param id	identificator of the module of reservation
    */

    function updateSelectBox(source,dest){
        document.getElementById(dest).value = document.getElementById(source).value;
    }

    function showparagraph(id) {
        if(document.getElementById(id).style.display!='block') {
            document.getElementById(id).style.display = 'block';
        } else {
            document.getElementById(id).style.display = 'none';
        }
    }

    function notInList(aList,s) {
        var joined="";
        for (var e in aList) {
            joined+=aList[e];
        }
        if (joined.indexOf(s) == -1) {
            return true;
        } else {
            return false;
        }
    }


    function renderCountryList(aList) {
        var buffer = "";
        aList.sort();
        for (var e in aList) {
            var s = aList[e];
            var code = s.split("|")[1];
            var label = s.split("|")[0];
            buffer += "<div id='guide'>"
                + "<a href='javascript:popupFiche(\"popup-fiche-pays.jsp?dest=\""
                + ", \""+code+"\");'>"
                + label + "</a></div>";

        }
        document.write(buffer);
    }

    /**
    * Si la select box contenant la ville de depart du premier module de reservation change,
    * la select box de la ville de depart de la deuxieme reservation change. On peut inverser les  r�les.
    * @param id  identificator the first module of reservation
    * @param idof  identificator the second module of reservation
    * @param dispoArray array of all js dispos objects
    */

    function updateDispo(id,idof,disposArray){
        document.getElementById('depCityCode'+idof).value = document.getElementById('depCityCode'+id).value;
        fillSelectBoxDispo('dateDepContent'+idof,'depCityCode'+idof, disposArray, 'null');
    }


    /******************************************/
    /** Classe representant une disponibilité */
    /******************************************/
    /**
    * Constructeur
    */
    function Dispo(depCityCode, depCityLabel ,depDate, depDate2, formattedPrice, price, nbDays, nbNigths,brochurePrice) {
        this.depCityCode = depCityCode;
        this.depCityLabel = depCityLabel;
        // Pour l'affichage dans la combobox
        var date = depDate.split("-");
        var day = date[2];
        var month = date[1];
        var monthFr = monthArray[Number(month)];
        var year = date[0];
        this.depDate = new Array(day+" "+monthFr+" "+year);
        this.depDate2 = new Array(day+"-"+month+"-"+year);
        this.price = price;
        this.formattedPrice = formattedPrice;
        this.nbDays = nbDays;
        this.nbNigths = nbNigths;
        this.brochurePrice=brochurePrice;

    }
    /**
    * Methode toString
    */
    Dispo.prototype.toString = function() {
        var str = "";
        var bPriceNotFormatted =  "" + this.brochurePrice.replace(' ', '').replace(/\s/g,'');
        if (this.brochurePrice != 'null' && parseFloat(bPriceNotFormatted) > parseFloat(this.price)) {
            str +=  ' au lieu de '+ this.brochurePrice +'\u20AC';
        }
        str += ' - ' + this.nbDays + 'j / ' + this.nbNigths + 'n';
        return  'le ' + this.depDate + ' - ' + this.formattedPrice  + '\u20AC'+str;
    };
    /**
    * Methode stringInValue
    */
    Dispo.prototype.stringInValue = function() {
        return  this.depDate2 + '-' + this.nbDays + '-' + this.nbNigths;
    };


    // general popup function
    function popupSized(prefix,id,width,height,wind) {
        popup = window.open(prefix+id,
                            wind,
                            "resizable=yes,width="+width+",height="+height+",left=100,top=100,dependent=no,scrollbars=yes");
    }

    // popup For the printable product description.
    function popupPrint(prefix,id) {
        popup = window.open(prefix+id,
                            "print",
                            "resizable=yes,width=825,height=640,left=100,top=100,dependent=no,scrollbars=yes");

    }

    // popup For the fiches
    function popupFiche(prefix,id) {
        popup = window.open(prefix+id,
                            "print",
                            "resizable=yes,width=810,height=640,left=100,top=100,dependent=no,scrollbars=yes");

    }

    function retrieveCityCodeFromUrl() {
        var url =  document.location.href;
        if (url.match("#") !== null) {
            var reg = new RegExp(".+fiche-produit\.jsp\?.+#.+&dispoCity=(.+)", "g");
            var cityCode = url.replace(reg,"$1");
            return cityCode;
        }
    }

    function retrieveAvailibilityCodeFromUrl() {
        var url =  document.location.href;
        if (url.match("#") !== null) {
            var reg = new RegExp(".+fiche-produit\.jsp\?.+#.*&?dispo=(.+)&dispoCity=.+", "g");
            var cityCode = url.replace(reg,"$1");
            return cityCode;
        }
    }

    function retrieveDepartureDateFromUrl() {
        var url =  document.location.href;
        if (url.match("#") !== null) {
            var reg = new RegExp(".+fiche-produit\.jsp\?.+#.+&dateDepart=([^&]+).+", "g");
            var date = unescape(url.replace(reg,"$1"));
            return date.match("^[0-9][0-9]/[0-9][0-9]/[0-9][0-9][0-9][0-9]$");
        }
    }

