	/**
	* 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 j = 0;
		var strOld = "" ;
		var basePriceIndex=0;
		var basePrice=0;

		for(var i = 0; i < disposArray.length; i++) {
			if (disposArray[i].depCityCode == selectedDepCityCode) {
				if (strOld!=disposArray[i].stringInValue()) {
					document.getElementById(dispoSelectBoxName).options[j] = new Option(disposArray[i].toString(), disposArray[i].stringInValue());
					if(j==0){
					basePrice=disposArray[i].price;
					}
					else if( parseInt(basePrice)> parseInt(disposArray[i].price)){
					basePrice=disposArray[i].price;
					basePriceIndex=j;
					}
					j++;
					strOld = disposArray[i].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');
	}
	
	/**
	* 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;
	}
	
	/**
	* 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 j = 0;
		var strOld = "" ;
		var basePriceIndex=0;
		var basePrice=0;

		for(var i = 0; i < disposArray.length; i++) {
			if (disposArray[i].depCityCode == selectedDepCityCode) {
				if (strOld!=disposArray[i].stringInValue()) {
					document.getElementById(dispoSelectBoxName).options[j] = new Option(disposArray[i].toString(), disposArray[i].stringInValue());
					if(j==0){
					basePrice=disposArray[i].price;
					}
					else if( parseInt(basePrice)> parseInt(disposArray[i].price)){
					basePrice=disposArray[i].price;
					basePriceIndex=j;
					}
					j++;
					strOld = disposArray[i].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", '');}
	}

	/******************************************/
	/** Classe representant une disponibilité */
	/******************************************/
	/**
	* Constructeur
	*/
	function Dispo(depCityCode, depCityLabel ,depDate, depDate2, 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.nbDays = nbDays;
		this.nbNigths = nbNigths;
		this.brochurePrice=brochurePrice;

	}
	/**
	* Methode toString
	*/
	Dispo.prototype.toString = function() {
		var str = "";
		if(this.brochurePrice != 'null'&&parseFloat(this.brochurePrice)>parseFloat(this.price)){
			str +=  ' au lieu de '+ this.brochurePrice +'\u20AC';
		}
		str += ' - ' + this.nbDays + 'j / ' + this.nbNigths + 'n';
		return  'le ' + this.depDate + ' - ' + this.price  + '\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=660,height=640,left=100,top=100,dependent=no,scrollbars=yes");

	}