//Coping with server session expiry
					
		
			function openCofinogaPopUp(){
				openPopUp('http://www.cofinoga.fr/ouvrir-carte-cofinoga-opodo.do?idgroupe=WOPOD','Cofinoga','height=500,width=700,resizable=yes,scrollbars=yes');
			}
			
			function openDatePriceDetailPopUp(pAnchor){
				openPopUp(pAnchor.href,'DatePriceDetail','height=900,width=800,resizable=yes,scrollbars=yes');
				return false;
			}
			
			function openWindowOhMyGlobe(url){
				var windowOhMyGlobe = window.open(url);
				windowOhMyGlobe.focus();
				return false;
			}
			
			function openPopUp(url, pageName, pageOptions)
			{
				newwindow=window.open(url,pageName,pageOptions);
				if (window.focus){
					newwindow.focus()
				}
				return false;
			}
			
				    
		
			function resetFlexibility(){
				document.getElementById("flexibility").value=4;
				if(document.getElementById("departureDay").value == "")
					document.getElementById("flexibility").value ="";
			}
			
			function resetAllSelects(){
				document.getElementById("departurecity").selectedIndex=0;
				document.getElementById("destinationcountry").selectedIndex=0;
				document.getElementById("destinationcity").selectedIndex=0;
				document.getElementById("departuremonth").selectedIndex=0;
				document.getElementById("departureDay").selectedIndex=0;
				//document.getElementById("flexibility").selectedIndex=0;
				document.getElementById("duration").selectedIndex=0;
				document.getElementById("budget").selectedIndex=0;
				// document.getElementById("categories").selectedIndex=0;
				document.getElementById("pension").selectedIndex=0;
				document.getElementById("formula").selectedIndex=0;
				document.getElementById("theme").value="";
				
			}
			
			function assignSearchOptionsToSelect(searchOptions){
			
				//reset ALL the selects.
				resetAllSelects();
				productIds != null && productIds.length > 0
				
				if(searchOptions.depCity != null && searchOptions.depCity.length>0)
					document.getElementById("departurecity").value = searchOptions.depCity[0];

				if(searchOptions.destCountry != null && searchOptions.destCountry.length>0)
					document.getElementById("destinationcountry").value = searchOptions.destCountry[0];
				
				if(searchOptions.destCity != null && searchOptions.destCity.length>0)
					document.getElementById("destinationcity").value = searchOptions.destCity[0];
				
				if(searchOptions.depMonth != null)
					document.getElementById("departuremonth").value = searchOptions.depMonth;

				if(searchOptions.depDay != null)
					document.getElementById("departureDay").value = searchOptions.depDay;

				if(searchOptions.flexibility != null)
					document.getElementById("flexibility").value = searchOptions.flexibility;
				
				if(searchOptions.duration != null)
					document.getElementById("duration").value = searchOptions.duration;
				
				if(searchOptions.budget != null)
					document.getElementById("budget").value = searchOptions.budget;
				
				//if(searchOptions.category != null && searchOptions.category.length>0)
				//	document.getElementById("categories").value = searchOptions.category[0];				
				
				if(searchOptions.pension != null && searchOptions.pension.length>0)
					document.getElementById("pension").value = searchOptions.pension[0];
				
				if(searchOptions.formula != null && searchOptions.formula.length>0)
					document.getElementById("formula").value = searchOptions.formula[0];
			
				if(searchOptions.theme != null && searchOptions.theme.length>0)
					document.getElementById("theme").value = searchOptions.theme[0];
				
			}
			
			function selectActiveSpans(){
				selectSpan("departurecity");
				selectSpan("destinationcountry");
				selectSpan("destinationcity");
				selectSpan("departuremonth");
				selectSpan("departureDay");
				selectSpan("flexibility");
				selectSpan("duration");
				selectSpan("budget");
				//selectSpan("categories");
				selectSpan("pension");
				selectSpan("formula");
				
			}
			
			function selectSpan(id){
				var selectValue = document.getElementById(id).value;
				if (selectValue != "")
					document.getElementById(id+"Span").className ="selected";
				else
					document.getElementById(id+"Span").className ="";
			}
			
			/*
			* Constructs the object that modelises the search options. The values are the codes from the selects.
			*/
			function getSearchOptions(){
			 
				var SearchOptions ={	depCity: new Array( document.getElementById("departurecity").value ),
										destCountry: new Array( document.getElementById("destinationcountry").value ),
										destCity: new Array( document.getElementById("destinationcity").value ),
										depMonth: document.getElementById("departuremonth").value,
										depDay: document.getElementById("departureDay").value,
										flexibility: document.getElementById("flexibility").value,
										duration: document.getElementById("duration").value,
										budget: document.getElementById("budget").value,
										//category: new Array( document.getElementById("categories").value ),
										pension: new Array( document.getElementById("pension").value ),
										formula: new Array( document.getElementById("formula").value ),
										theme : new Array( document.getElementById("theme").value ),
										pageNumber: lastPage,
										lastFilter: lastFilter,
										orderBy: actualOrder
				};
				
				return SearchOptions;
			
			}
			
			var FRENCH_MONTHS = new Array("Janvier","F\351vrier","Mars","Avril","Mai","Juin","Juillet","Ao\373t","Septembre","Octobre","Novembre","D\351cembre");
			var FRENCH_MONTHS_SHORT = new Array("JAN", "FEV", "MAR", "AVR", "MAI", "JUN", "JUL", "AOU", "SEP", "OCT", "NOV", "DEC");
			var FRENCH_DAYS = new Array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi");
			
			/*
			* gets a date in format YYYY-MM-DD Ex: 2008-01-15
			* returns the french month. Ex: Janvier
			*/
			function getFrenchMonth(dateString){
				var splitDate = dateString.split("-");
				var myDate = new Date(splitDate[0],splitDate[1]-1,splitDate[2])
				return FRENCH_MONTHS[myDate.getMonth()];
			}
			
			/*
			* gets a date in format YYYY-MM-DD Ex: 2008-01-15
			* returns the french date. Ex: Mardi 15 janvier 2008
			*/
			function getFrenchDate(dateString){
				var splitDate = dateString.split("-");
				var myDate = new Date(splitDate[0],splitDate[1]-1,splitDate[2])
				
				var textDate = FRENCH_DAYS[myDate.getDay()]+" "+ myDate.getDate()+ " " + FRENCH_MONTHS[myDate.getMonth()]+ " " + myDate.getFullYear();
				return textDate;
			}
			
			
			function manageCustomLink(label, mySelect){
				
				if (mySelect.value != "" ){
					var s=s_gi(s_account);
					var myText = mySelect.options[mySelect.selectedIndex].text
					
					s.prop10='PKG:SearchEngineResults-'+label+'-'+myText;
					s.tl(mySelect,'o','PKG:SearchEngineResults-'+label+'-'+myText);
				}
			}
		
		    
		     function showMessageProductNotFound(){
		    	var message = "<img src='/img_opodo/v2/picto_alerte.jpg' alt='Attention !' />";
	    		
				message += "<p class='p_alert'>Le produit que vous venez de sélectionner n'est plus disponible.</p><br/>";
				message += "<p>Pour trouver le séjour correspondant à vos envies, vous pouvez utiliser les menus déroulants sur la gauche de l'écran ou contacter l'un de nos conseillers voyages au numéro : 0 899 653 656 (1,35&euro; par appel puis 0,34&euro;/min TTC).</p>\n";
				
				document.getElementById("dv_erreur").innerHTML = message;
				document.getElementById("dv_erreur").style.display="block";
		    }
		    
		    function showMessageProductNotAvailable(){
		   		var message = "<img src='/img_opodo/v2/picto_alerte.jpg' alt='Attention !' />";
	    		
				message += "<p class='p_alert'>Le séjour « <s:property value='productName'/> » n'est plus disponible.<br/>Vous trouverez ci-dessous les séjours disponibles pour la même destination.</p><br/>";
				message += "<p>Pour trouver le séjour correspondant à vos envies, affinez ou modifiez votre recherche en utilisant les menus déroulants à gauche.</p>\n";
				
				document.getElementById("dv_erreur").innerHTML = message;
				document.getElementById("dv_erreur").style.display="block";
		    }
		    
		    function showAlternativeResults(wihoutLastFilter){
		    	var message = "<img src='/img_opodo/v2/picto_alerte.jpg' alt='Attention !' />";
		    	
		    	if(wihoutLastFilter)
			    	message += "<p class='p_alert'>Nous n'avons pas trouv&eacute; de s&eacute;jours correspondant &agrave; votre dernier crit&egrave;re de recherche.</p>\n";
				else
				    message += "<p class='p_alert'>Nous n'avons pas trouv&eacute; de s&eacute;jours correspondant &agrave; tous vos crit&egrave;res de recherche.</p>\n";
			    
				message += "<p class='p_alert'>Nous vous proposons ci-dessous des <strong>r&eacute;sultats alternatifs</strong> pour les crit&egrave;res suivants :</p>\n";
				
				var searchOptions = getSearchOptions();
								
				message += "<ul>\n";

				if(searchOptions.depCity != "" )
					message += "<li>Ville de d&eacute;part : <strong>"+document.getElementById("departurecity").options[document.getElementById("departurecity").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.destCountry != "" )
					message += "<li>Pays de destination : <strong>"+document.getElementById("destinationcountry").options[document.getElementById("destinationcountry").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.destCity != "" )
					message += "<li>Ville de destination : <strong>"+document.getElementById("destinationcity").options[document.getElementById("destinationcity").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.depMonth != "" )
					message += "<li>Mois de d&eacute;part : <strong>"+document.getElementById("departuremonth").options[document.getElementById("departuremonth").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.depDay != "" )
					message += "<li>Jour de d&eacute;part : <strong>"+document.getElementById("departureDay").options[document.getElementById("departureDay").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.flexibility != "" && searchOptions.depDay != "")
					message += "<li>Flexibilit&eacute; : <strong>"+document.getElementById("flexibility").options[document.getElementById("flexibility").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.duration != "" )
					message += "<li>Dur&eacute;e du s&eacute;jour : <strong>"+document.getElementById("duration").options[document.getElementById("duration").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.budget != "" )
					message += "<li>Budget : <strong>"+document.getElementById("budget").options[document.getElementById("budget").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.formula != "" )
					message += "<li>formule : <strong>"+document.getElementById("formula").options[document.getElementById("formula").selectedIndex].text+"</strong></li>\n";
				
				if(searchOptions.pension != "" )
					message += "<li>Type de pension : <strong>"+document.getElementById("pension").options[document.getElementById("pension").selectedIndex].text+"</strong></li>\n";
				
				message += "</ul>";
				
				message += "<p>Pour trouver le séjour correspondant à vos envies, affinez ou modifiez votre recherche en utilisant les menus déroulants à gauche.</p>\n";
				
				document.getElementById("dv_erreur").innerHTML = message;
				document.getElementById("dv_erreur").style.display="block";
		    }
		    
		    function hideAlternativeResults(){
		    	document.getElementById("dv_erreur").style.display="none";
		    	document.getElementById("dv_erreur").innerHTML = "";
		    }
		    
		
		
			var productIds = new Array();	//list of products id that are in the actual page
			var maxProductsChecked = 3;
			var numProductsChecked = 0;		// = productIdsChecked.lenght	TODO change in the code numProductsChecked for productIdsChecked.lenght
			var productIdsChecked = new Array();	//list of the SELECTED product id. They can be in different pages !!
			
			// help to keep the state. We keep that values apart because like that we can contruct at any moment a searchOption object with all the parameters.
			var lastPage = 1;
			var lastFilter = "";
			var actualOrder ="QUALITY_PRICE";	//default order. The possible values are QUALITY_PRICE and PRICE
			
			
		   function initProductId(productId){
		    	if(productId != null ){
		    		productIds[productIds.length] = productId;
		    	}
		    }
	
		    function prepareSearch(){
		    	window.focus();	//lose the focus from the select.
		    	
		    	removeContentOfWrapResults();
		    	hideAlternativeResults();
		    }
			
			/* AJAX CALLS */
			
			function getSearchPage(){
		    	//prepareSearch();
		    	
		    	lastPage = 1;
		    	var searchOptions = getSearchOptions();
		    	
				numProductsChecked = 0;
				productIdsChecked = new Array();
		    	
		    	addUrlToHistory(searchOptions);	//it will launch the search when the page state is saved in the navigator history
		    	
		    	//ServiceSearchProducts.getSearchPage(searchOptions, fillProductTable );
			}
		    
		    function goToPage(pageNumger){
		    	//prepareSearch();
		    	
		    	lastPage = pageNumger;
		    	var searchOptions = getSearchOptions();
		    	
		    	addUrlToHistory(searchOptions);	//it will launch the search when the page state is saved in the navigator history
		    	
		    	//ServiceSearchProducts.getSearchPage(searchOptions, fillProductTable );
		    }
		    
		    function changeOrder(newOrder){
		    	
		    	if (actualOrder != newOrder){
		    		actualOrder = newOrder;
					lastFilter = "";
					
					if(actualOrder=='PRICE'){
						$j('#label_price').addClass('lbl_bold');
						$j('#label_qualityPrice').removeClass('lbl_bold');
					}else{
						$j('#label_qualityPrice').addClass('lbl_bold');
						$j('#label_price').removeClass('lbl_bold');
					}
		    		getSearchPage();
		    	}
		    }
		    
		    /* END AJAX CALLS */
		 
	    /* JQUERY HISTORY FUNCITONS */
		    
		    function addUrlToHistory(searchOptions){
				//Save map view parameters to the URL
				var hash = constructUrl(searchOptions);
				var currentHash = $j.historyCurrentHash.replace(/^#/, '');
				if (hash != currentHash) $j.historyLoad(hash);	//save the url in the navigator history
		    }
		    
		    function constructUrl(searchOptions){
		    	var url = "";
		    	
				for (var i=0; i<searchOptions.depCity.length; i++ ){
					if (searchOptions.depCity[i] != "" )
						url += "depCity="+searchOptions.depCity[i]+"&";
				}
				
				for (var i=0; i<searchOptions.destCountry.length; i++ ){
					if (searchOptions.destCountry[i] != "" )
						url += "destCountry="+searchOptions.destCountry[i]+"&";
				}
				
				for (var i=0; i<searchOptions.destCity.length; i++ ){
					if (searchOptions.destCity[i] != "" )
						url += "destCity="+searchOptions.destCity[i]+"&";
				}
				
				if(searchOptions.depMonth != "")
					url += "depMonth="+searchOptions.depMonth+"&";

				if(searchOptions.depDay != "")
					url += "depDay="+searchOptions.depDay+"&";

				if(searchOptions.flexibility != "")
					url += "flexibility="+searchOptions.flexibility+"&";
				
				if(searchOptions.duration != "")
					url += "duration="+searchOptions.duration+"&";
				
				if(searchOptions.budget != "")
					url += "budget="+searchOptions.budget+"&";
				
				for (var i=0; i<searchOptions.pension.length; i++ ){
					if (searchOptions.pension[i] != "" )
						url += "pension="+searchOptions.pension[i]+"&";
				}
				
				for (var i=0; i<searchOptions.formula.length; i++ ){
					if (searchOptions.formula[i] != "" )
						url += "formula="+searchOptions.formula[i]+"&";
				}
				
				for (var i=0; i<searchOptions.theme.length; i++ ){
					if (searchOptions.theme[i] != "" )
						url += "theme="+searchOptions.theme[i]+"&";
				}
				
				if(searchOptions.pageNumber != "")
					url += "pageNumber="+searchOptions.pageNumber+"&";
				
				if(searchOptions.lastFilter != "")
					url += "lastFilter="+searchOptions.lastFilter+"&";
				
				if(searchOptions.orderBy != "")
					url += "orderBy="+searchOptions.orderBy+"&";
				
				
				//other parameters that keep the page state:
				for (var i=0; i<productIdsChecked.length; i++ ){
					if (productIdsChecked[i] != "" )
						url += "productIdsChecked="+productIdsChecked[i]+"&";
				}
				
				
				//remove the last "&"
				if(url.length >0)
					url = url.substring(0, url.length-1);
				
		    	return url;
		    }
		    
		    function recoverSearchOptionsFromUrl(newLocation){
		    	
		    	//recover the parameters:
		    	
				var depCity = new Array();
				var destCountry = new Array();
				var destCity = new Array();
				var depMonth = "";
				var depDay = "";
				var flexibility = "";
				var duration = "";
				var budget = "";
				// var category = new Array();
				var pension = new Array();
				var housing = new Array();
				var formula = new Array();
				var theme = new Array();
				
		    	//clean the productIdsChecked array:
		    	productIdsChecked = new Array();
		    	numProductsChecked = 0;
		    	
		    	var urlParamValuePair = newLocation.split("&");
		    	
		    	for (var i=0; i<urlParamValuePair.length; i++){
		    	
		    		//urlParamValuePair has the form: param=value
		    		var paramValue = urlParamValuePair[i].split("=");
		    		
		    		if(paramValue.length == 2){
		    		
		    			var param = paramValue[0];
		    			var value = paramValue[1];
		    		
		    			if( param == "depCity" )
		    				depCity[depCity.length] = value;
		    			else if (param == "destCountry")
		    				destCountry[destCountry.length] = value;
		    			else if (param == "destCity")
		    				destCity[destCity.length] = value;
		    			else if (param == "depMonth")
		    				depMonth = value;
		    			else if (param == "depDay")
		    				depDay = value;
		    			else if (param == "flexibility")
		    				flexibility = value;
		    			else if (param == "duration")
		    				duration = value;
		    			else if (param == "budget")
		    				budget = value;
		    			else if( param == "pension" )
		    				pension[pension.length] = value;
		    			else if( param == "housing" )
		    				housing[housing.length] = value;
		    			else if( param == "formula" )
		    				formula[formula.length] = value;
		    			else if( param == "theme" )
		    				theme[theme.length] = value;
		    			else if (param == "pageNumber")
		    				lastPage = value;	//the page number is save apart
		    			else if (param == "lastFilter")
		    				lastFilter = value;	//the last filter is save apart
		    			else if (param == "orderBy")
		    				actualOrder = value;	//the actual order is save apart
		    			else if (param == "productIdsChecked"){	//other parameters that keep the page state
		    				productIdsChecked[productIdsChecked.length] = value;
		    			}
		    		}
		    	
		    	
		    	}
		    	
		    	numProductsChecked = productIdsChecked.length;
		    	
				var SearchOptions ={	depCity: depCity,
										destCountry: destCountry,
										destCity: destCity,
										depMonth: depMonth,
										depDay: depDay,
										flexibility: flexibility,
										duration: duration,
										budget: budget,
										pension: pension,
										housing: housing,
										formula: formula,
										theme: theme,
										pageNumber: lastPage,
										lastFilter: lastFilter,
										orderBy: actualOrder
				};
				
				return SearchOptions;
		    
		    }
		    
		    function historyManager(newLocation){
		    	//recovers the information from the url and launches a new search
		    	var searchOptions = recoverSearchOptionsFromUrl(newLocation);
		    	
		    	// we will not do an AJAX load when:
		    	//1) it's not the first page load
		    	//AND
		    	//2) there are no saved parameters in the URL.
		    	if ( newLocation != "" || !isFirstLoad ){
		    		prepareSearch();
			    	ServiceSearchProducts.getSearchPage(searchOptions, fillProductTable );
			    }
			    
			    isFirstLoad = false;
		    }
		    
		    var isFirstLoad = true;
		    
		    /* END JQUERY HISTORY FUNCITONS */   
		    
			 /* function liens_js() {
				$j('.dv_offres').each(function() {
					var url = $j(this).find('.p_submit a').attr('href');
					$j(this).find('.img_vignetPhoto').wrap('<a href="'+url+'"></a>');
					$j(this).find('h3').wrapInner('<a href="'+url+'"></a>');
					$j(this).find('.p_descriptif').wrapInner('<a href="'+url+'"></a>');
				});
			  }
		    */
			function lienFormPageDetail(){
					$j('.p_submit a').click(function() {
					$j(this).parents('form').submit(); 
					return false;
				});
			}
			
			function liens_js(){
				$j('.dv_offres').each(function() {
								
					$j(this).find('.img_vignetPhoto').click(function() {
							
							$j(this).parent().find('form').submit(); 
							return false;
			
						});
			
					$j(this).find('h3').click(function() {
							$j(this).parent().find('form').submit(); 
							return false;
				
						});
							

					});
			}
			
			
			
		     
			function removeContentOfWrapResults(){
			
				$j('.dv_offres').remove();
				
				$j('#dv_filtrebas').before("<div class='white_content' id='loader'></div>");
				
				productIds = new Array();
				
				
			}
			
		    function fillProductTable(pageSearch){
		    	
		    	if (pageSearch == null){	//no new products
		    		goToGenericErrorPage();
		    	}
		    
				$j('#loader').remove();
				
				$j('.spn_nbOffres').html(pageSearch.totalNumProducts + " séjours");
				
				$j('#arianeCountry').html(pageSearch.destinationCountry);

				//pagination:
				var numPages = pageSearch.numShowPages;	//will be an array
				var forwardNumPage= pageSearch.forwardNumPage;
				var backNumPage = pageSearch.backNumPage;
				var actualNumPage = pageSearch.actualNumPage;
				var lastNumPage = pageSearch.totalNumPage
				
				var paginationHtml ="Pages : ";
				
				if (backNumPage > 0)
					paginationHtml+="<a href='' onclick='goToPage("+backNumPage+");return false;'>&laquo;</a>&nbsp;"
				
				for(var i = 0; i < numPages.length; i++) {
					var pageNumber = numPages[i];
					if ( pageNumber == actualNumPage )
						paginationHtml+="<a href='' onclick='goToPage("+pageNumber+");return false;' class='page_active' >"+pageNumber+"</a>&nbsp;";
					else if( pageNumber <= lastNumPage )
						paginationHtml+="<a href='' onclick='goToPage("+pageNumber+");return false;' >"+pageNumber+"</a>&nbsp;";
				}
				
				if(lastNumPage >= forwardNumPage)
					paginationHtml+="<a href='' onclick='goToPage("+forwardNumPage+");return false;'>&raquo;</a>"

				
				
				$j('#dv_pagehaut').html(paginationHtml);
				$j('#dv_pagebas').html(paginationHtml);
			
				// Create a new set cloned from the pattern div
				var productList = pageSearch.products;
				
			
				var strRedirection = "";
				if(pageSearch.searchOptions.depCity!=null && pageSearch.searchOptions.depCity !="")
					strRedirection ="&departureCity=" + pageSearch.searchOptions.depCity;
				if(pageSearch.searchOptions.depMonth!=null && pageSearch.searchOptions.depMonth !="")
					strRedirection +="&departureDate=" + pageSearch.searchOptions.depMonth;
					
				for(var i = 0; i < productList.length; i++) {
					var product = productList[i];
					id = product.productId;
					
					var myDestinationCity = product.destinationCity;
					if(myDestinationCity != null && myDestinationCity !="" )
						myDestinationCity= " - " + myDestinationCity;
					
					var myPproductMealPlan = product.mealPlan;
					if(myPproductMealPlan != null && myPproductMealPlan !="" )
						myPproductMealPlan = " - "+myPproductMealPlan;
			
					var productDurations =  product.durations;
					var prodDurationHTML = "";
					var durationSelected=''
					for(var j = 0; j < productDurations.length; j++) {
						var duration = productDurations[j];
						prodDurationHTML += duration.days+"j/"+duration.nights+"n,"
						durationSelected = duration.days+':'+duration.nights;
					}
					//remove the last","
					if (prodDurationHTML.length > 0)
						prodDurationHTML = prodDurationHTML.substring(0,prodDurationHTML.length -1);
				
					var strHtml = '<div class="dv_offres" id="pattern'+id+'" >';
						if(product.pushings != null && product.pushings.length > 0 )
							strHtml += '<img src="/img_opodo/v2/logo_selectionOO.jpg" alt="Sélection Opodo" />';
						if(product.inPromotion == "oui" && product.discount ==null)
							strHtml +='<img class="img_promo" alt="Promo" src="/img_opodo/promoResult.jpg"/>';
					
					
					
					strHtml +=  '<div class="dv_tetiere">';
					strHtml +=  '<p><img src="/img_opodo/v2/picto_palmier_offre.jpg" alt="Offre Séjour" />&nbsp;' + product.destinationCountry + myDestinationCity +'</p>';
					strHtml +=  '</div>';
					strHtml +=  '<div class="dv_contenuOffre">';
					strHtml +=  '	<img src="'+ product.imageURL +'" class="img_vignetPhoto" />';
					strHtml +=  '	<h3>'+ product.title +'</h3>';	
					strHtml +=  '	<p class="p_descriptif">' + product.formule + '&nbsp;-&nbsp;' + prodDurationHTML +  myPproductMealPlan + '<br/>' + product.subTitle + '</p>';
					
					
					strHtml +=  '	<p class="p_prix"><span class="spn_annotation">A partir de</span> <span class="spn_offre"><span class="spn_prix">' + product.minPrice + '</span><span class="spn_monnaie">&euro;</span><sup>TTC</sup><br/>par personne</span></p>';
					
					if(product.discount != null)
						strHtml +=  '	<p class="p_discount"><span class="spn_annotation">jusqu à</span><br/><span class="spn_offre"><span class="spn_reduc">-'+product.discount+'%</span><br/>soit '+product.economie+'&euro; économisés</span></p>';
					
					strHtml +=  '	<p class="p_calendar">Prochain départ à ce tarif :<br/><strong>' + product.basePriceDepartureCity + ', ' + product.basePriceDate + '</strong></p>';
					
					strHtml +=  '	<p class="p_calendar border"><img src="/img_opodo/v2/picto_calendar.jpg" alt="" /><a href="/Packagio/DatePriceDetail.do?productId='+ id +'" onClick="openDatePriceDetailPopUp(this);return false;">Voir le calendrier des prix par ville et date de départ &#187;</a></p>';
					
					strHtml += 	'<div style="clear:both;padding-top: 5px">';
					strHtml += 	'<form name ="formPageDetail" method="post" action="ProductDetail.do?productId='+id + strRedirection +'">';
					strHtml +=  '<input type="hidden"  name="productPrice"  value="'+ product.minPrice+'"	/>'
					strHtml +=	'<input type="hidden"  name="productDepartureDate" value="'+product.basePriceDateFormatPdetail +'"/>';
					strHtml +=	'<input type="hidden"  name="productDepartureMonth" value="'+product.basePriceDepartureMonth +'"/>';
					strHtml +=	'<input type="hidden"  name="productDepartureCity" value="'+product.basePriceDepartureCity +'"/>';
					strHtml +=	'<input type="hidden"  name="productDepartureCityCode" value="'+product.basePriceDepartureCityCode +'"/>';
					strHtml +=	'<input type="hidden"  name="productDuration" value="'+durationSelected+'"/>';
					strHtml +=	'<input type="hidden"  name="productDiscount" value="'+product.discount +'"/>';
					strHtml +=	'<input type="hidden"  name="productEconomie" value="'+product.economie +'"/>';
					strHtml +=	'<input type="hidden"  name="inPromotion" value="'+product.inPromotion  +'"/>';
					
					strHtml +=	'<div class="p_submit"><a href="#">Détail du séjour</a></div>'
					strHtml +=	'</form>';
					strHtml +=  '	<a class="cofinoga" onclick="window.open(\'http://www.cofinoga.fr/ouvrir-carte-cofinoga-opodo.do?idgroupe=WOPOD\',\'Cofinoga\',\'height=500,width=700,resizable=yes,scrollbars=yes\'); return false;" href="#">Payez ce séjour en plusieurs fois</a>';
					strHtml += 	'	</div>';
					strHtml +=  '</div>';
					strHtml +=	'</div>';
					
					$j("#dv_filtrebas").before(strHtml);
					
							
					productIds[i] = id;
				
			    }
				
				liens_js();
				
			    //take care of the dynamic filters
				manageDestinationCityFilter(pageSearch.destinationCities);
				
				manageDepartureDayFilter(pageSearch.searchOptions.depMonth, pageSearch.searchOptions.depDay);
				
				manageFlexibilityFilter(pageSearch.searchOptions.depDay);
				
				  
								    
			    //recover the selected options. 
			    var searchOptions = pageSearch.searchOptions;
			    assignSearchOptionsToSelect(searchOptions);
			    selectActiveSpans();
			    
		    	//check if alternative results
		    	if(pageSearch.searchOptions.wihoutLastFilter){
		    		showAlternativeResults(true);
		    	}
		    	else if(pageSearch.searchOptions.alternativeResult){
		    		showAlternativeResults(false);
		    	}
			    
			    //write transversal content:
			    writeTransversalContent(pageSearch.countryTransversalContent);
			   
			   // listners formulaires 
				liens_js();
				lienFormPageDetail();
		    }
		   
		    function manageDestinationCityFilter(destinationCities){
		    	
		    	if(destinationCities == null || destinationCities.length == 0){ //clean the filter and hidde it
			    	cleanSelect("destinationcity")	//clean the Select
			    	document.getElementById("destinationcitySpan").style.display = "none";
			    }
		    	else{	//fill the options
			    	
					cleanSelect("destinationcity")	//clean the Select
			    	
			    	var destinationCountrySelect = document.getElementById("destinationcity");
			    	//add the first option:
			    	var firstOption = new Option("Indiff\351rent" ,"");
			    	destinationCountrySelect.options[0] = firstOption;
			    	
			    	for(var i = 0; i < destinationCities.length; i++){
			    		var destinationCity = destinationCities[i];
						var myOption = new Option(destinationCity.label ,destinationCity.code);
						destinationCountrySelect.options[i+1] = myOption;
			    	}
			    	
			    	document.getElementById("destinationcitySpan").style.display = "block";	//show the filter
			    	
			    }
		    }
		    
		    function manageDepartureDayFilter(depMonthString, depDayString){ //the depMonth format is YYYY-MM and the depDay format is YYYY-MM-DD
		    	
		    	if(depMonthString == null || depMonthString == "" ){	//clean the filter and hidde it
		    		cleanSelect("departureDay");
		    		document.getElementById("departureDaySpan").style.display = "none";
		    	}
		    	else{	//create the options
		    	
					cleanSelect("departureDay")	//clean the Select
			    	
			    	var departureDaySelect = document.getElementById("departureDay");
			    	//add the first option:
			    	var firstOption = new Option("Indiff\351rent" ,"");
			    	departureDaySelect.options[0] = firstOption;
			    	
			    	//create the options like Mardi 1, Mercredi 2, etc.
					var splitDate = depMonthString.split("-");
					var depMonth = new Date(splitDate[0],splitDate[1]-1,1);
			    	
			    	//we will not show past days
			    	var today = new Date();
			    	if(today > depMonth )
			    		depMonth = today;
			    	
			    	var actualMonth = depMonth.getMonth();
			    	var selectIndex = 1;
			    	
			    	while(actualMonth == depMonth.getMonth() && selectIndex < 32){	//selectIndex<32 is there just in case something goes wrong.
			    		
			    		var monthString = depMonth.getMonth()+1
			    		if (monthString<10)
			    			monthString ="0"+monthString;
			    		
			    		var dateString = depMonth.getFullYear()+"-"+monthString+"-"+depMonth.getDate();
						var myOption = new Option(getFrenchDate(dateString), dateString);
						
						if(depDayString == dateString )
							myOption.selected = true;
						
						departureDaySelect.options[selectIndex] = myOption;
						selectIndex++;
			    		depMonth.setDate(depMonth.getDate()+1);
			    	}
			    	
			    	document.getElementById("departureDaySpan").style.display = "block";	//show the filter
			    	
		    	}
		    
		    }
		    
		    function manageFlexibilityFilter(depDay){
		    	if(depDay != null && depDay != "" )
		    		document.getElementById("flexibilitySpan").style.display = "block"; //show the filter
		    	else
		    		document.getElementById("flexibilitySpan").style.display = "none"; //hide the filter
		    }
		    
		    function writeTransversalContent(transContent){
		    
		    	var transContentDiv = document.getElementById("dv_introDesti");
		    	var myHTML = "";
		    	transContentDiv.style.display = "none";	//hide the div
		    	
		    	if(transContent != null){
		    		myHTML = ""
		    		
		    		if(transContent.mainPicture !="")
		    			myHTML += '<img id="countryImg" src="'+transContent.mainPicture +'" alt="" width="275" height="185"/>\n';
		    		
						myHTML += '<h2><img alt="" src="/img_opodo/v2/picto_palmier.jpg"/>' + transContent.title + '</h2>';
					
		    		if(transContent.descriptionContent != "")
		    			myHTML += '<p>'+transContent.descriptionContent+'</p>\n'
		    		
		    		if(transContent.whenToGoTitle !="" && transContent.whenToGoPicture !=""){
		    			myHTML += '<table cellspacing="0">\n';
		    			myHTML += '\t<caption>'+transContent.whenToGoTitle+'</caption>\n';
		    			myHTML += '\t<tr>\n';
		    			myHTML += '\t\t<th scope="col">'+transContent.whenToGoContent+'</th>\n';
		    			myHTML += '\t</tr>\n';
		    			myHTML += '\t<tr>\n';
		    			myHTML += '\t\t<td>\n';
		    			myHTML += '\t\t\t<img id="" src="'+transContent.whenToGoPicture+'" alt="" />\n';
		    			myHTML += '\t\t</td>\n';
		    			myHTML += '\t</tr>\n';
		    			myHTML += '</table>\n';
		    		}
		    		
		    		if(transContent.ohMyGlobeLink != "" && transContent.ohMyGlobeTitle != "")
		    			myHTML += '<p class="omg"><a href="'+transContent.ohMyGlobeLink+'" onclick="return openWindowOhMyGlobe('+transContent.ohMyGlobeLink+');" title="Voir la fiche OhMyGlobe.com">'+transContent.ohMyGlobeTitle+'</a></p>';
		    			
						myHTML +='<div style="clear:both"></div>';
						
		    		transContentDiv.style.display = "block";	//show the div
		    		
		    	}
		    	
		    	transContentDiv.innerHTML= myHTML;
		    		
		    }
		    
		    function cleanSelect(selectId){
		    
				var mySelect = document.getElementById(selectId);
		    	 
		    	while(mySelect.options.length>0)
		    		mySelect.options[mySelect.options.length-1] = null;
		    }