//HCF.member = {}; 
HCF.sejour  = {
	
	
	initialize : function(){
		
		this.nbItemListPerPage = 10;
		this.nbItemPhotoPerPage = 10;
		this.starImg = '';
		this.urlAlias = '';
		this.current = '';
		

		$('.btn-carte', '#carteFiltreForm').click(function (){
			$('#TypeSearch', '#carteFiltreForm').val('carte');
			getSejours();
			$('.btn-liste', '#carteFiltreForm').removeClass('current');
			$('.btn-photos', '#carteFiltreForm').removeClass('current');
			$(this).addClass('current');
			$('#recherche-carte').show();
	        $('#recherche-liste').hide();
	        $('#recherche-photos').hide();
	        $('#Pagination').hide();
	        
	        
	    });
	    
	    $('.btn-liste').click(function (){
	    	$('#TypeSearch', '#carteFiltreForm').val('liste');
	    	
	    	$('#NbItemParPageMax', '#carteFiltreForm').val(HCF.sejour.nbItemListPerPage);
	    	getSejoursTotal();
	    	initPagination($('#TotalEntries', '#carteFiltreForm').val());
	    	$('.btn-carte', '#carteFiltreForm').removeClass('current');
			$('.btn-photos', '#carteFiltreForm').removeClass('current');
			$(this).addClass('current');
	        $('#recherche-carte').hide();
	        $('#recherche-liste').show();
	        $('#recherche-photos').hide();
	        $('#Pagination').show();
	       
	    });
	
	   	$('.btn-photos').click(function (){
	   		$('#TypeSearch', '#carteFiltreForm').val('photos');
	   		$('#NbItemParPageMax', '#carteFiltreForm').val(HCF.sejour.nbItemPhotoPerPage);
	    	getSejoursTotal();
	    	initPagination($('#TotalEntries', '#carteFiltreForm').val());
	   		$('.btn-carte', '#carteFiltreForm').removeClass('current');
			$('.btn-liste', '#carteFiltreForm').removeClass('current');
			$(this).addClass('current');
	        $('#recherche-carte').hide();
	        $('#recherche-liste').hide();
	        $('#recherche-photos').show();
	        $('#Pagination').show();
	    });
   		
   		
	},
	
	
	search : function(viewParamters){
		
		
		
		var optionsInit = {
				action:'',
			 	sejour:-1,
			 	destination:-1,
			 	duree:-1,
			 	budget:-1,
			 	periode:-1,
			 	hebergement:-1
			 };
		
		var optionsCurrent = optionsInit;
		var link = '';
		
		
		$('#destination' , '#carteFiltreForm').change(function () {
			getSejoursTotal();
			link+='/(destination)/' + $("#destination option:selected").val();
			initPagination($('#TotalEntries').val());
			applyFiltre('t2',$("#destination option:selected").text(),$("#destination option:selected").val());
		}); 
		
		
		$('input[name=radioSejour]', '#carteFiltreForm').click(function () {
			
			link+='/(sejour)/' + $(this).val();
			var ssType = 'ssType-' + $(this).val();
			
			if($('.ssType').attr('name')!=ssType)
			{
				getSejoursTotal();
				initPagination($('#TotalEntries').val());
			}else{
				$('#' + ssType).val(-1);
				$('.ssType' , '#carteFiltreForm').change(function () {
					getSejoursTotal();
					initPagination($('#TotalEntries').val());
				});
			}
				
			var texte = $("#id_t1_" + $(this).val()).text() ;
			applyFiltre('t1',texte,$(this).val());
			
			
		}); 
		
		
		$('#SearchMois' , '#carteFiltreForm').focusin(function () {
			$("input[name=radioPeriode]", '#carteFiltreForm').filter("[value='mois']").attr("checked","checked");
			var texte = $("#id_t5_" + $("input[name=radioPeriode]", '#carteFiltreForm').filter("[value='mois']").val()).text() ;
			applyFiltre('t5',texte,$("input[name=radioPeriode]", '#carteFiltreForm').filter("[value='mois']").val());
		}); 
		
		
		$('#SearchMois', '#carteFiltreForm').change(function () {
			getSejoursTotal();
			initPagination($('#TotalEntries', '#carteFiltreForm').val());
		});
		
		
		$('input[name=radioPeriode]', '#carteFiltreForm').click(function () {
			if($(this).val()!='mois')
			{
				getSejoursTotal();
				initPagination($('#TotalEntries', '#carteFiltreForm').val());
			}
			
			link+='/(periode)/' + $(this).val();
			
			var texte = $("#id_t5_" + $(this).val()).text() ;
			applyFiltre('t5',texte,$(this).val());
			
		});
		
		
		$('input[name=radioDuree], input[name=radioBudget], input[name=radioHebergement]', '#carteFiltreForm').click(function () {
			var type='';
			
			getSejoursTotal();
			initPagination($('#TotalEntries', '#carteFiltreForm').val());
			//console.log('TotalEntries :' + $('#TotalEntries').val());			
			switch($(this).attr('name'))
			{
				case 'radioDuree':
					link+='/(duree)/' + $(this).val();
					type='t3';
				break;
				case 'radioBudget':
					link+='/(budget)/' + $(this).val();
					type='t4';
				break;
				case 'radioHebergement':
					link+='/(hebergement)/' + $(this).val();
					type='t6';
				break;
				
			}	
			
			var id = "#id_" + type + "_" + $(this).val();		
			var texte = $(id).text() ;
			applyFiltre(type,texte,$(this).val());
		}); 
		
		
		$('#shareResult', '.filtre').click(function () {
			//console.log('link :' + link);
			//link = $(location).attr('href') + link;
			$('#ShareLink', '#carteFiltreForm').val(link);
			Lightbox.open('/layout/set/lightbox/tools/share-result/');
			
			return false;
		});
		
		
		$('#resetForm', '.filtre').click(function () {
			optionsInit.action = 'reload';
			setInitForm(optionsInit);
			return false;
		}); 
		
		
		var preset = false;
		
		
		if(viewParamters.sejour)
		{	
			optionsCurrent.sejour = viewParamters.sejour;
			preset = true;
		}
		
		if(viewParamters.destination)
		{	
			optionsCurrent.destination = viewParamters.destination;
			preset = true;
		}
		
		if(viewParamters.duree)
		{	
			optionsCurrent.duree = viewParamters.duree;
			preset = true;
		}		
		
		if(viewParamters.budget)
		{	
			optionsCurrent.budget = viewParamters.budget;
			preset = true;
		}
		
		if(viewParamters.periode)
		{	
			optionsCurrent.periode = viewParamters.periode;
			preset = true;
		}
		
		if(viewParamters.hebergement)
		{	
			optionsCurrent.hebergement = viewParamters.hebergement;
			preset = true;
		}
		
		
			
		if(preset)
		{	
			optionsCurrent.action = 'preset';
		}
		
		
		//initialisation
		setInitForm(optionsCurrent);
		
		if(HCF.sejour.current=='liste')
		{	
			$('#recherche-carte').hide(); 
			$('#recherche-photos').hide();
			$('.btn-liste', '#carteFiltreForm').trigger('click');
		}
		else if(HCF.sejour.current=='photos')
		{
			$('#recherche-liste').hide(); 
			$('#recherche-carte').hide();
			$('.btn-photos', '#carteFiltreForm').trigger('click');
		}
		else
		{	
			$('#recherche-liste').hide(); 
			$('#recherche-photos').hide();
			$('.btn-carte', '#carteFiltreForm').trigger('click');
		}	
			
			
	},
	
	
	
	
	share : function(){
		
		$('#ShareLinkResult', '#shareResultForm').val($('#ShareLink', '#carteFiltreForm').val());

		
		$('#shareResultForm').validate({
			errorElement: "span",
			submitHandler: function(form) {
					$.ajax({
			          url: '/layout/set/ajax/tools/action',
			          dataType: 'html',
			          async: false,
			          data: 'ope=setShare&' + $('#shareResultForm').serialize(),
			          type: 'post',
			          success: function (j) {		          
					      if(j)
					      {
					    	  $("#shareResult").html(' votre recommandation a bien été envoyé.<input type="button" name="CancelButton" id="CancelButton" value="Fermer"/>');
					    	  HCF.sejour.share();
					      }
					    	  
			          }
			        });
			},			
			rules: {
				myEmail:{
					required: true,
					email:true
				},
				myName:{
					required: true
				},
				hisEmail:{
					required: true,
					email:true
				}
			},
			messages: {
				myEmail: {
					required: 'Champ obligatoire',
					email: 'email invalide'
				},
				myName: {
					required: 'Champ obligatoire'
				},
				hisEmail: {
					required: 'Champ obligatoire',
					email: 'email invalide'
				}
			}
		});
		
		$('#shareResultAnnuler','#shareResultForm').click(function () {
			Lightbox.close();
		});
		
		
		$('#shareResultEnvoyer','#shareResultForm').click(function () {
			$('#shareResultForm').submit();
		});
		
		
		
		 // Putting round on buttons
	    $(".button").each(function() {
	        if($(this).hasClass("button-bullet")) {
	            $(this).prepend("<span class='button-icon'></span>");
	        }

	        $(this).prepend("<span class='button-left'></span><span class='button-right'></span>");
			/*       
	 		var width = parseInt($(this).width());
	        width += 12;
	        $(this).css("display", "block").css("width", width + "px");
			*/
	    });
		
		
		
		
	}
	
	
	
	
}
	    
	    
	    
function getSejours(page_index)
{
	var locations = [];
	var star = HCF.sejour.starImg ;
	
	if($('#TypeSearch', '#carteFiltreForm').val()=='liste')
	{
		showLoader();
	}else if($('#TypeSearch', '#carteFiltreForm').val()=='photos'){
		showLoader();
	}	
	
	var total_sejour=0;

	var data_send = 'ope=getSejourFiltre&' + $('#carteFiltreForm').serialize();
	if($('#TypeSearch', '#carteFiltreForm').val()=='liste' || $('#TypeSearch', '#carteFiltreForm').val()=='photos')
	{
		if(page_index!=undefined)
			data_send += '&pageindex='+ page_index;
	}
	
	$.ajax({
          url: '/layout/set/ajax/reservation/action',
          dataType: 'json',
          async: true,
          data: data_send,
          type: 'post',
          success: function (j) {
          	
	          if($('#TypeSearch', '#carteFiltreForm').val()=='carte')
	          {
	          	total_sejour = 0;
	         	if(j.length>0)
				{
				      for (var i = 0; i < j.length; i++) 
				      {
				      	total_sejour+=j[i].nb_sejour;
				      	
				      	var loc = new Object();
				      	loc.titre = j[i].titre;
				      	loc.content = j[i].content;
				      	loc.js = j[i].js;
				      	loc.lng = j[i].lng;
				      	loc.lat = j[i].lat;
				      	locations.push(loc);
				      	
	                  }
	             }
			      
	         	var sejour_texte = ' séjour';
                if($('#TotalEntries', '#carteFiltreForm').val()>1) sejour_texte += 's';
                $('#filtre_titre').html($('#TotalEntries', '#carteFiltreForm').val() + sejour_texte);
			    //$('#filtre_titre').html((total_sejour) + ' séjours');
			      initialize(locations);

			      
			  }
			  else if($('#TypeSearch', '#carteFiltreForm').val()=='liste')
	          {
	          	
	          	total_sejour = 0;
			  	if(j.length>0)
    			{
    				var str='';
    				var etoiles='';
    				var dates='';
    				
					for (var i = 0; i < j.length; i++) 
				    {
				    	var promo = new Array();
				    	promo['style'] ='';
				    	promo['type'] ='';
				    	prix_str = '<div class="place-price">A partir de <b>' + j[i].prix + ' €TTC / pers.</b></div>';
   	
				/*
				      	if(j[i].nb_etoiles > 0)
				      	{
				      		for(var c = 0; c < j[i].nb_etoiles; c++)
				      		{ 
				      			etoiles+='<img src="'+ star + '" alt="etoiles"/>';
				      		}	
				      	}
				*/      	
				      	
				      	
				      	if(j[i].date_arrivee!=undefined && j[i].date_arrivee!='')
				      	{
				      		dates='Arrivée le ' + j[i].date_arrivee + ' - Départ le ' + j[i].date_depart + '<br/>';
				      		bouton_titre ='Je réserve le séjour';
				      		bouton_lien = j[i].resa;
				      	}
				      	else if(j[i].periode_pro!=undefined)
				      	{
				      		dates=j[i].periode_pro + '<br/>';
				      		bouton_titre ='Demande de cotation';
				      		bouton_lien = j[i].cota;
				      	}
				      	
				      	if (typeof j[i].promo_titre != "undefined")
				      	{
				      		promo['style'] = '<div class="place-newly"><span class="' + j[i].promo_style + ' corner corner-fff corner-2">' + j[i].promo_titre + '</span></div>';
				      		promo['type'] =  '&nbsp; <strong class="pink">' + j[i].promo_val + ' ' + j[i].promo_type + '</strong>';
				      		if(j[i].afficher_old_price == 1)
				      			prix_str = '<div class="place-price">'+
                                           'A partir de <strong class="pink">' + j[i].prix + ' €TTC / pers.</strong><br/>'+
                                           '<span class="promo">au lieu de ' + j[i].old_price + ' €TTC / pers.</span>'+
                                           '</div>';
                                           
				      			
				      	}
				      	
				      	str+='<div class="place">'+
        					 '<div class="place-image"><img src="/' + j[i].img_liste + '" alt="' + j[i].titre + '" /></div>'+
        					 '<div class="place-text">' +
            				 '<div class="place-title">' + j[i].titre + promo['type'] + '</div>'+
            				 '<div class="place-subtitle">' + j[i].nom + ' ' + etoiles + '</div>'+
            				 '<div class="place-right">'+ promo['style'] + prix_str + '</div>'+
            				 '<div class="place-date">'+ 'Séjour de ' + j[i].duree + ' en ' + j[i].sejour_titre + '<br/><span  style="color:#FF9800; font-weight:bold;">'+ dates + '</span></div>'+
            				 '<div class="place-instructions">'+
                			 '<a href="/' + j[i].url_alias + '/(prg)/' + j[i].prg_id + '/(prx)/' + j[i].prix_node_id +  '" class="bullet">Consultez la fiche détaillée</a>'+
                			 '</div>'+
            				 '<div class="place-reservation">'+
            				 '<a href="' + bouton_lien + '" class="button button-blue button-bullet button-rollover">' + bouton_titre + '</a>'+
     						 '</div></div></div>';
    
    					etoiles='';
				      	
                      }
                      total_sejour = j.length
                      
                  }
                  
                  var sejour_texte = ' séjour';
                  if($('#TotalEntries', '#carteFiltreForm').val()>2) sejour_texte += 's';
                  $('#filtre_titre').html($('#TotalEntries', '#carteFiltreForm').val() + sejour_texte);
                  
			      $('#places','#recherche-liste').html('');
			      $('#places','#recherche-liste').html(str);
			      hideLoader();
			      reloadDesign();
			  
			  
			  }
			  else if($('#TypeSearch', '#carteFiltreForm').val()=='photos')
	          {
			  	  total_sejour = 0;
				  if(j.length>0)
	    		  {
    				var str='';
    				var class_last_child='';
    				var cpt=1;
    				var dates='';
    				
    				
    				
    				for (var i = 0; i < j.length; i++) 
				    {
    					var promo = new Array();
    			    	promo['style'] ='';
    			    	promo['type'] ='';
    			    	
				    	if(cpt >= 3)
				    	{
				    		class_last_child = ' last-child';
				    		cpt=0;
				    	}
				    	
				    	if(j[i].date_arrivee!='')
				      	{
				      		dates='Arrivée le ' + j[i].date_arrivee + '<br/> Départ le ' + j[i].date_depart ;
				      	}
				    	
				    	if (typeof j[i].promo_titre != "undefined")
				      	{
				      		promo['type'] =  '&nbsp; <strong class="pink">' + j[i].promo_val + ' ' + j[i].promo_type + '</strong>';
				      			
				      	}
				    	
				    	if(j[i].periode_pro!=undefined)
				    	{
				    		dates=j[i].periode_pro;
				      		bouton_lien = j[i].cota;
				    	}else{
				    		bouton_lien = j[i].url_alias + '/(prg)/' + j[i].prg_id;
				    	}	
				    	
				    	str+='<div class="photo'+ class_last_child + '">'+
				    		 '<div class="content">'+
					         '<div class="content-wrap" style="height:30px;">' + j[i].titre + '<br/>'+
					         '<b><a href="' + bouton_lien + '">A partir de ' + j[i].prix + ' €TTC</a></b>'+
					         promo['type'] + 
					         '<div class="hr"></div>'+
    						 '<div>'+ 'Séjour de ' + j[i].duree + '<br/>'+ dates + '</div>'+
					         '</div></div>'+
					         '<img src="/' + j[i].img_liste + '" alt="' + j[i].titre + '" />'+
				    		 '</div>';
				    	class_last_child='';	 
				    	cpt++;	 	
				    }
				    total_sejour = j.length
    			  }
    			  
    			 var sejour_texte = ' séjour';
                 if($('#TotalEntries', '#carteFiltreForm').val()>2) sejour_texte += 's';
                 $('#filtre_titre').html($('#TotalEntries', '#carteFiltreForm').val() + sejour_texte);
			      
			     $('#photos').html('');
			     $('#photos').html(str);
			     hideLoader();			
			  	 reloadDesign();	
			  	 
			  	 
			  	 
			  	 
			  	 //When mouse rolls over  
			    $(".photo > .content > .content-wrap").mouseover(function () {
			        $(this).stop().animate({height:'90px'},{queue:false, duration:500, easing: 'easeOutBounce'})  
			    });  
			  
			    //When mouse is removed  
			    $(".photo > .content > .content-wrap").mouseout(function () {
			        $(this).stop().animate({height:'30px'},{queue:false, duration:500, easing: 'easeOutBounce'})  
			    });  
			  	 
			  }
			      
          }
	});
}	  



function showLoader(){
	$('.search-background').fadeIn(200);
}

function hideLoader(){
	$('.search-background').fadeOut(200);
}

function reloadDesign()
{
	// Putting round on buttons
    $("#recherche-liste .button").each(function() {
        if($(this).hasClass("button-bullet")) {
            $(this).prepend("<span class='button-icon'></span>");
        }

        $(this).prepend("<span class='button-left'></span><span class='button-right'></span>");
        var width = parseInt($(this).width());
        width += 12;
        $(this).css("display", "block").css("width", width + "px");
    });
    
    $("#recherche-liste .corner").each(function(){
        var spans = "";
        var lang = $(this).attr("lang");
        if(lang) {
            for(var i = 0; i < lang.length; i += 2) {
                if(lang.substring(i,i+2) == "tl") {
                    spans += "<span class=\"corner-tl\"></span>";
                }
                if(lang.substring(i,i+2) == "tr") {
                    spans += "<span class=\"corner-tr\"></span>";
                }
                if(lang.substring(i,i+2) == "br") {
                    spans += "<span class=\"corner-br\"></span>";
                }
                if(lang.substring(i,i+2) == "bl") {
                    spans += "<span class=\"corner-bl\"></span>";
                }
            }
        } else {
            // All corners
            spans = "<span class=\"corner-tl\"></span><span class=\"corner-tr\"></span><span class=\"corner-br\"></span><span class=\"corner-bl\"></span>";
        }

        if(spans != "") {
            $(this).prepend(spans);
        }
    });
}

function getSejoursTotal()
{
	var total_sejour = 0;
	var carte =false;
	if($('#TypeSearch').val() == 'carte')
	{
		carte =true;
		$('#TypeSearch').val('liste');
	}	
	
	$.ajax({
          url: '/layout/set/ajax/reservation/action',
          dataType: 'html',
          async: false,
          data: 'ope=getSejourFiltre&total=1&' + $('#carteFiltreForm').serialize(),
          type: 'post',
          success: function (j) {
          	total_sejour = j;
          }	
    });
    
    $('#TotalEntries', '#carteFiltreForm').val(total_sejour);
    
    if(carte)
    	$('#TypeSearch').val('carte');
     
}          
          



function radioFiltre(radioName,type)
{
	var valeur = $('input[name=' + radioName + ']:checked').val();
	var texte = $('#id_' + type + '_' + valeur).text() ;
	applyFiltre(type,texte,valeur);
}	


function setInitForm(oInit)
{
	var exists = false;
	
	$('input[name=radioSejour]','#carteFiltreForm').each(function(){
    	if (this.value == oInit.sejour) {
	        exists = true;
	        return false;
	    }
	});
	
	if(!exists) oInit.sejour=-1;
	$("input[name=radioSejour]",'#carteFiltreForm').filter("[value=" + oInit.sejour + "]").attr("checked","checked");
	
	
	exists = false;
	$('#destination option','#carteFiltreForm').each(function(){
    	if (this.value == oInit.destination) {
	        exists = true;
	        return false;
	    }
	});
	if(!exists) oInit.destination=-1;
	$('#destination','#carteFiltreForm').val(oInit.destination);
	
	exists = false;
	$('input[name=radioDuree]','#carteFiltreForm').each(function(){
    	if (this.value == oInit.duree) {
	        exists = true;
	        return false;
	    }
	});
	if(!exists) oInit.duree=-1;
	$("input[name=radioDuree]",'#carteFiltreForm').filter("[value=" + oInit.duree + "]").attr("checked","checked");
	
	
	exists = false;
	$("input[name=radioBudget]","#carteFiltreForm").each(function(){
    	if (this.value == oInit.budget) {
	        exists = true;
	        return false;
	    }
	});
	if(!exists) oInit.budget=-1;
	$("input[name=radioBudget]","#carteFiltreForm").filter("[value=" + oInit.budget + "]").attr("checked","checked");
	
	
	exists = false;
	$('input[name=radioPeriode]','#carteFiltreForm').each(function(){
    	if (this.value == oInit.periode) {
	        exists = true;
	        return false;
	    }
	});
	if(!exists) oInit.periode=-1;
	$("input[name=radioPeriode]","#carteFiltreForm").filter("[value=" + oInit.periode + "]").attr("checked","checked");
	
	exists = false;
	$('input[name=radioHebergement]','#carteFiltreForm').each(function(){
    	if (this.value == oInit.hebergement) {
	        exists = true;
	        return false;
	    }
	});
	if(!exists) oInit.hebergement=-1;
	$("input[name=radioHebergement]","#carteFiltreForm").filter("[value="+ oInit.hebergement +"]").attr("checked","checked");
	
	
	$('#filtreApplied').html('');
	$('#filtreApplied').append('<li>Filtre(s) appliqué(s):</li>');
	
	
	
	if(oInit.action=='reload')
	{
		window.location = '/'+ HCF.sejour.urlAlias +'/(type)/' + $('#TypeSearch').val();
		if($('#TypeSearch','#carteFiltreForm').val()=='liste' || $('#TypeSearch').val()=='photos')
		{
			
			getSejoursTotal();
			initPagination($('#TotalEntries').val());
		}else{
			getSejours();
		}
	}else if(oInit.action=='preset'){
		
		radioFiltre('radioSejour','t1');
		applyFiltre('t2',$("#destination option:selected").text(),$("#destination option:selected").val());
		radioFiltre('radioDuree','t3');
		radioFiltre('radioBudget','t4');
		radioFiltre('radioPeriode','t5');
		radioFiltre('radioHebergement','t6');
	}else{
		getSejoursTotal();
	}
}

function removeFiltre(type)
{
	//console.log('remove_t1');
	switch (type)
	{
		case 't1':
		  	$('input[name=radioSejour]','#carteFiltreForm')[0].checked="checked";
		  break;
		case 't2':
		  	$('#destination','#carteFiltreForm').val(-1);
		  break;
		case 't3':
		  	$('input[name=radioDuree]','#carteFiltreForm')[0].checked="checked";
		  break;
		case 't4':
		  	$('input[name=radioBudget]','#carteFiltreForm')[0].checked="checked";
		  break;
		case 't5':
		  	$('input[name=radioPeriode]','#carteFiltreForm')[0].checked="checked";
		  break;
		case 't6':
		  	$('input[name=radioHebergement]','#carteFiltreForm')[0].checked="checked";
		  break;      
	}
	
	$('.filtre_' + type).remove();
	getSejoursTotal();
	initPagination($('#TotalEntries','#carteFiltreForm').val());
}


function applyFiltre(type,txt,valeur)
{
	$('#filtreApplied > li').each(function(index) {
	    if($(this).attr('class') == 'filtre_' + type)
	    {
	    	$('.filtre_' + type).remove();
	    }
	});
	
	if(valeur!=-1)
		$("#filtreApplied").append('<li class="filtre_' + type +'"><div class="corner corner-1d70c8 corner-3">' + txt + '<a href="#" onclick="javascript:removeFiltre(\'' + type +'\');" class="close"></a></div></li>');
}



function pageselectCallback(page_index, jq)
{
	getSejours(page_index);
    return false;
}
   

function initPagination(num_entries) 
{
    // count entries inside the hidden content
    //var num_entries = jQuery('#hiddenresult div.result').length;
  
    // Create content inside pagination element
    $("#Pagination").html('');
    $("#Pagination").pagination(num_entries, {
        callback: pageselectCallback,
        items_per_page:$('#NbItemParPageMax').val(),
        prev_text:'PRECEDENT',
        next_text:'SUIVANT'
    });
}

