	function tb_show_mask(){
		if(document.getElementById("TB_window"))
		{
			document.getElementById("TB_window").style.display = "none";
		}
		if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			$("body","html").css({height: "100%", width: "100%"});
			$("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				$("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				$("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
			}
		}
		
		if(tb_detectMacXFF()){
			$("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			$("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}
	
	
		$("body").append("<div id='TB_load'><img src='../images/loading_wheel.gif' /><div style=\"color:#FFF; margin:10px 0 0 0;\">" + srtPatienter + "</div></div>");//add loader to the page
		$('#TB_load').show();//show loader
	}
	
	//------------------------------------------------------
	/* Fonction qui à partir d'une adresse va déterminer le point géographique */
	//------------------------------------------------------
	function showAddress() {
		var address = $("#adresse").val();
		var pays = $("#pays").val();
		if (pays=="Aquarine"){
			pays = "Europe";
		}
		
		if (pays != "")
		{
			if (address != ""){
				address = address + "," + pays;
			}else{
				address = pays;
			}
				
		}
		
		if(address == "Luxembourg"){
			var point = new GLatLng(49.7741696, 6.1166382);
			map.setCenter(point, 9);
			/* Création d'un marqueur */
			var marker = new GMarker(point);
		}else if(address == "belgique"){
			var point = new GLatLng(50.7573099, 4.4384766);
			map.setCenter(point, 7);
			/* Création d'un marqueur */
			var marker = new GMarker(point);
		}else if(address == "Pays-Bas"){
			var point = new GLatLng(52.1671936, 5.3173828);
			map.setCenter(point, 7);
			/* Création d'un marqueur */
			var marker = new GMarker(point);
		}else if(address == "Europe"){
			var point = new GLatLng(54.5259614, 15.2551187);
			map.setCenter(point, 4);
			/* Création d'un marqueur */
			var marker = new GMarker(point);
		}else{
			if (geocoder) {
				geocoder.getLatLng(address, function(point) {
					if (!point) { /* Si les coordonnées n'ont pas été trouvés */
						//alert("Impossible de localiser l'adresse :\n\n" + address);
						tb_show("","#TB_inline?height=80&width=200&inlineId=message",false);

					} else { /* /* Les coordonnées ont été trouvés */
						/* Centrer la carte sur le point */
						map.setCenter(point, 11);
						/* Création d'un marqueur */
						var marker = new GMarker(point);

					}
				});
			}
		}
	}
	
		
	//------------------------------------------------------
	// Fonction  appeler à chaque changment de la carte
	//------------------------------------------------------
	function onChange()
	{
		// efface les marqueurs
		map.clearOverlays();
		
		//creer un point au centre de la carte
    	var center = map.getCenter();
		var marker = new GMarker(center , {draggable: true});
		
		// Action sur le déplacement du marqueur
		GEvent.addListener(marker, "dragend", function() {
      		var point = marker.getPoint();
	     	map.panTo(point);
        });
		
		//recupère les coins
		var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();  
		var northEast = bounds.getNorthEast();
		
		//recupère les infos coins
		var NE_lat = northEast.lat().toFixed(7);
		var NE_lng = northEast.lng().toFixed(7);
		var SW_lat = southWest.lat().toFixed(7);
		var SW_lng = southWest.lng().toFixed(7);
		
		// requete Ajax pour récupèrer la liste des revendeurs
		$.ajax({
		   type: "POST",
		   url: "../js/ajax/ajax_recherche_revendeurs.asp",
		   data: "ne_lat=" + NE_lat + "&ne_lng=" + NE_lng + "&sw_lat=" + SW_lat + "&sw_lng=" + SW_lng + "&centre_lng=" + map.getCenter().lng() + "&centre_lat=" + map.getCenter().lat() + "&pays=" + paysAct,
		   beforeSend: function(){
 				tb_show_mask();
			   $("#list_revendeurs").html("<img src=\"../images/loading_wheel.gif\" height=\"32\" width=\"32\" alt=\"loading\" title=\"loading\" />");
			   $("#nb_revendeurs").html("<i>Loading</i>");
		   },
		   success: function(msg){

				// Si on a des revendeurs
		   		if (msg != "")
				{
					//On vide notre tableau
					StructurePoint = new Array();
					
					// L'Ajax renvoie une structure de point				
					eval(msg);
										
					// on récupère le num de la dernière page et on met à jour les varaibales gloabales				
					page_actuelle = 1;
					page_end = Math.ceil(StructurePoint.length / nb_element);
					
					//Pagination
					AffichePagination(1)
					
					// On affiche les 10 premiers si possible
					var nbMax = StructurePoint.length;
					if (StructurePoint.length > nb_element)
					{
						nbMax = nb_element;
					}
					
					// On affiche le nombre de revendeurs au total
					if(StructurePoint.length > 0)
					{
						$("#nb_revendeurs").html(StructurePoint.length + " " + srtRevendeursTrouves)
					}else{
						$("#nb_revendeurs").html(strAucunRevendeurTrouve)
					}
										
					// On affiche les revendeurs
					AfficheRevendeur(0, nbMax, "-1");

					tb_remove();
				}
		   }
		});		

	}
	
	//------------------------------------------------------
	// Fonction qui fait du cherche et remplace
	//------------------------------------------------------
	function searchANDreplace(chaine,mySearch,myReplace)
	{
		var reg = new RegExp("(" + mySearch + ")", "g");
		chaine = chaine.replace(reg,myReplace);
		
		return chaine;
	}
	//------------------ FIN --------------------------------

	//------------------------------------------------------
	// Fonction qui affiche les revendeurs sur la carte
	//------------------------------------------------------
	function AfficheRevendeur(id_start, id_end, id_selected, needRedirect)
	{
		// Déclarations variables listes
		var list = "";
		// Déclarations du tableau des marqueurs
		var marker = new Array();

		// efface les marqueurs
		map.clearOverlays();

		// Icone
		var icon_highlight = new GIcon();
		icon_highlight.iconSize = new GSize(19, 19);
		icon_highlight.image = "../images/icon_geo.png";
		icon_highlight.iconAnchor = new GPoint(6, 20);
		
		// Icone surbrillance
		var icon_highlight2 = new GIcon();
		icon_highlight2.iconSize = new GSize(19, 19);
		icon_highlight2.image = "../images/icon_geo_over.png";
		icon_highlight2.iconAnchor = new GPoint(6, 20);
		
		// Parcours des marqueurs
		for (i=id_start; i<id_end; i++) {
			
				
			// Creation d'un point
			var point = new GLatLng(StructurePoint[i].Lat, StructurePoint[i].Lng);
	
			// Création d'un marqueur
			if (parseInt(i)==parseInt(id_selected) && parseInt(id_selected)!= -1) // si c'est le marqueur que l on a choisit
			{
				marker[i] = new GMarker(point, { icon:icon_highlight2, id:i});
				// Liste des revendeurs			
				//list = list + "<div class='revendeur' id='item_" + i + "'><div class='revendeur_titre_selected'>" + StructurePoint[i].Nom + "-" + StructurePoint[i].Dist + "</div><div class='revendeur_adresse'>" + StructurePoint[i].Rue + "<br />" + StructurePoint[i].Cp + " " + StructurePoint[i].Ville + "</div><div class='revendeur_localiser_selected'><a href='javascript:AfficheRevendeur(" + id_start + ", " + id_end + "," + i + ",false)'><img src='../images/puce-ronde-geo-over.png' height='5' width='5' alt='' border='0' align='absmiddle' /> " + strLocaliser + "</a></div></div>";
				list = list + "<div class='revendeur' id='item_" + i + "'><div class='conteneur_revendeur_titre'><table cellpadding='0' cellspacing='0'><tr><td>&nbsp;</td><td><div class='revendeur_titre_selected'>" + StructurePoint[i].Nom + "</div></td></tr></table></div><div class='revendeur_adresse'>" + StructurePoint[i].Rue + "<br />" + StructurePoint[i].Cp + " " + StructurePoint[i].Ville + "</div><div class='revendeur_localiser_selected'><a href='javascript:AfficheRevendeur(" + id_start + ", " + id_end + "," + i + ",false)'><img src='../images/puce-ronde-geo-over.png' height='5' width='5' alt='' border='0' align='absmiddle' /> " + strLocaliser + "</a></div></div>";
			}
			else
			{
				marker[i] = new GMarker(point, { icon:icon_highlight, id:i});
				// Liste des revendeurs			
				//list = list + "<div class='revendeur' id='item_" + i + "'><div class='revendeur_titre'>" + StructurePoint[i].Nom + "-" + StructurePoint[i].Dist + "</div><div class='revendeur_adresse'>" + StructurePoint[i].Rue + "<br />" + StructurePoint[i].Cp + " " + StructurePoint[i].Ville + "</div><div class='revendeur_localiser'><a href='javascript:AfficheRevendeur(" + id_start + ", " + id_end + "," + i + ",false)'><img src='../images/puce-ronde-geo.png' height='5' width='5' alt='' border='0' align='absmiddle' /> " + strLocaliser + "</a></div></div>";
				list = list + "<div class='revendeur' id='item_" + i + "'><div class='conteneur_revendeur_titre'><table cellpadding='0' cellspacing='0'><tr><td>&nbsp;</td><td><div class='revendeur_titre'>" + StructurePoint[i].Nom + "</div></td></tr></table></div><div class='revendeur_adresse'>" + StructurePoint[i].Rue + "<br />" + StructurePoint[i].Cp + " " + StructurePoint[i].Ville + "</div><div class='revendeur_localiser'><a href='javascript:AfficheRevendeur(" + id_start + ", " + id_end + "," + i + ",false)'><img src='../images/puce-ronde-geo.png' height='5' width='5' alt='' border='0' align='absmiddle' /> " + strLocaliser + "</a></div></div>";
			}
			
			idTemp = i;	
			// Action sur le click du marqueur
			GEvent.addListener(marker[i], "click", function() {				
				AfficheRevendeur(id_start, id_end, this.id, true);
			 });
						

			// Affichage d'un point
			map.addOverlay(marker[i]);
			

		}
			
		//--- Ajout des noms de revendeurs
		$("#list_revendeurs").html(list);
		
		if(needRedirect)
		{
			window.location = "#item_" + id_selected;
		}		
	}
	//------------------ FIN --------------------------------
	
	//------------------------------------------------------
	// Fonction permettant d'afficher la pagination
	//------------------------------------------------------
	function AffichePagination(num)
	{
		if (StructurePoint.length <= nb_element)
		{			
			$("#pagination").html("<div id='pagination_precedent'>&nbsp;</div><div id='pagination_page'><b>"+strPage+" 1/1</b></div><div id='pagination_suivant'>&nbsp;</div>");
		}
		else{
		
			switch (num) {
				case 1:				
					$("#pagination").html("<div id='pagination_precedent'>&nbsp;</div><div id='pagination_page'><b>"+strPage+" " + num + "/" + page_end + "</b></div><div id='pagination_suivant'><a href='javascript:GoToPage(" + (num+1) +  ")'>"+strSuivant+" <img src='../images/fleche-pagination-droite.png' width='10' height='12' align='texttop' border='0' /></a></div>");
					break;
				case page_end:
					$("#pagination").html("<div id='pagination_precedent'><a href='javascript:GoToPage(" + (num-1) +  ")'><img src='../images/fleche-pagination-gauche.png' alt='"+strPrecedentLC+"' width='10' height='12' align='texttop' border='0' /> "+strPrecedent+"</a></div><div id='pagination_page'><b>"+strPage+" " + num + "/" + page_end + "</b></div><div id='pagination_suivant'>&nbsp;</div>");
					break;			
				default: 
					$("#pagination").html("<div id='pagination_precedent'><a href='javascript:GoToPage(" + (num-1) +  ")'><img src='../images/fleche-pagination-gauche.png' alt='"+strPrecedentLC+"' width='10' height='12' align='texttop' border='0' /> "+strPrecedent+"</a></div><div id='pagination_page'><b>"+strPage+" " + num + "/" + page_end + "</b></div><div id='pagination_suivant'><a href='javascript:GoToPage(" + (num+1) +  ")'>"+strSuivant+" <img src='../images/fleche-pagination-droite.png' width='10' height='12' align='texttop' border='0' /></a></div>");
					break;
			}
		}
	}
	//------------------ FIN --------------------------------
	
	function GoToPage(num)
	{
		AffichePagination(num);


		switch (num) {
			case 1:
				start = 0;
				end = nb_element-1;
				break;
			case page_end:
				start = ((num-1) * nb_element)-1;
				end = StructurePoint.length-1;
				break;			
			default: 
				start = ((num-1) * nb_element)-1;
				end = (num * nb_element)-1;
				break;
		}
		
		AfficheRevendeur(start,end , "", false);
	}
