//<![CDATA[
	
	var map;
	var monGeocodeur;
	var AdresseBase, LatitudeBase, LongitudeBase;
	var PtDep;		
	var constNbMaxResultBeforeWarning=300;	
      // Create a base icon for all of our markers that specifies the
	// shadow, icon dimensions, etc.
	var baseIcon, baseIconSmall
	var URLMarkerGreen="http://labs.google.com/ridefinder/images/mm_20_green.png";
	var URLMarkerBlue="/images/markers/marker_blue.png";		
	var URLMarkerRed="http://labs.google.com/ridefinder/images/mm_20_red.png";
	var AutorizeGeoLocalisation=false;
	
	var circle;
	var circleRadius=0;
	var ZoomAtStart=0;
	var ZoomAutoLimit=12;
	var PtStart;
	

	var P;
	var TabPoints=new Array();
	var TailleTab;
	var DistMax=0;
	var DivInfosGeo;
	var DivLoading;
	var DivLoadingIMG;
	
function initialise() {

	if (TabRaisonSociale.length == 0) {	return false; }

	// On met en mémoire les div permettant l'affichage des infos;
	DivInfosGeo=document.getElementById("NbGeo");	
	DivLoading=document.getElementById("Loading");
	DivLoadingIMG=document.getElementById("LoadingIMG");
	
	if (!(AutorizeGeoLocalisation || TabRaisonSociale.length<=constNbMaxResultBeforeWarning)) {
		/* 
		Lorsqu'on a plus de constNbMaxResultBeforeWarning réponses (fixé à 300), par défaut, on ne géolocalise pas
		On demande à l'internaute de lancer lui même la géolocalisation
		*/
		DivInfosGeo.innerHTML="<BR><span style=\"color:red;\">Attention : </span> le nombre de réponses est important, et la localisation sur la carte peut durer plusieurs minutes et ralentir votre ordinateur . <BR>&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#\" onclick=\"javascript:AutorizeGeoLocalisation=true;initialise();return false;\">D'accord : je veux voir la carte</A><BR>";
		return false;
	
	}
	
	DivInfosGeo.innerHTML="";
	
	if (GBrowserIsCompatible()) {
		setTimeout("self.location.href=\"#Resultats\";",1750);	
		if (document.getElementById("map")) {
			document.getElementById("map").style.display="block";
		}	
	
		baseIcon = new GIcon(G_DEFAULT_ICON);
		baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png";
		baseIcon.iconSize = new GSize(20, 34);
		baseIcon.shadowSize = new GSize(37, 34);
		baseIcon.iconAnchor = new GPoint(9, 34);
		baseIcon.infoWindowAnchor = new GPoint(9, 2);	
	
		baseIconSmall = new GIcon(G_DEFAULT_ICON);
		baseIconSmall.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; 
		baseIconSmall.iconSize = new GSize(12, 20); 
		baseIconSmall.shadowSize = new GSize(22, 20); 
		baseIconSmall.iconAnchor = new GPoint(6, 20); 
		baseIconSmall.infoWindowAnchor = new GPoint(5, 1); 	
		
	
		//création de notre carte
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());  //intègre le zoom et les flèches de déplacement
		map.addControl(new GMapTypeControl());   //intègre le mode plan, satellite ou les deux
		map.enableContinuousZoom();
		map.doubleClickZoomEnabled();
		map.enableScrollWheelZoom();
		
		GEvent.addListener(map,"zoomend",ToggleCircle);
		
		monGeocodeur = new GClientGeocoder(); 	

		AdresseBase=document.forms["formRecherche"].cpville.value.trim();	
		
		DistMax=document.forms["formRecherche"].distance.value;		

		//ZoomFactor=7; // par défaut
				
		if (DistMax != "") {
			circleRadius=DistMax; // pour le disque de distance
			//DistMax*=1.05; // ajout de 5% de tolérance sur la distance			
			DistMax*=1000; // transfo en metres			

			PtDep=new AdherentGeo("",AdresseBase,"");
			PtDep.setLongitude(document.forms["formRecherche"].LongitudeDepart.value);
			PtDep.setLatitude(document.forms["formRecherche"].LatitudeDepart.value);
			LatitudeBase=document.forms["formRecherche"].LatitudeDepart.value;
			LongitudeBase=document.forms["formRecherche"].LongitudeDepart.value;
			PtDep.showAddress("blue");	
			
			
			//PutPointsOnTheMap()
			//setTimeout("Populate();",1800); // on laisse un temps de latence, le temps de positionner le point de départ
			//setTimeout("VerifPopulate();",14000);	
							
			
		}
		else {
			
			// centrage sur la Bourgogne
			map.setCenter(new GLatLng(47.12,4.38), 7); // Zoom à "7", pour voir la région entière
			//setTimeout("PopulateNonGeo();",1800);
		
		}	
		InitTabPoints();	
		
	}
	else{
		//alert("Erreur: votre navigateur ne supporte pas Google Maps");
		if (document.getElementById("map")) {
			document.getElementById("map").style.display="none";
		}		
	}
}	


function ToggleCircle() {
	if (circle) {
		if (ZoomAtStart==0 || ZoomAtStart>=map.getZoom()-1) {
			map.addOverlay(circle);
		}
		else {
			map.removeOverlay(circle);
		}
	}
}


/*
Tracage d'un cercle
Code found at http://maps.forum.nu/gm_sensitive_circle2.html
 */
var rad=Math.PI/180;
var _PiSur180=Math.PI/180;
var _180SurPi=180/Math.PI;

function doDrawCircle(center){

	if (circle) {
		map.removeOverlay(circle);
	}
 
 	var bounds = new GLatLngBounds();

	var circlePoints = Array();
	with (Math) {
		var d = circleRadius/6378.137;	// radians (6 378,137  = rayon de la terre (wikipedia))
 
		var lat1 = (_PiSur180)* center.lat(); // radians
		var lng1 = (_PiSur180)* center.lng(); // radians
 
		for (var a = 0 ; a < 361 ; a+=2 ) {
			var tc = (_PiSur180)*a;
			var y = asin(sin(lat1)*cos(d)+cos(lat1)*sin(d)*cos(tc));
			var dlng = atan2(sin(tc)*sin(d)*cos(lat1),cos(d)-sin(lat1)*sin(y));
			var x = ((lng1-dlng+PI) % (2*PI)) - PI ; // MOD function
			var point = new GLatLng(parseFloat(y*(_180SurPi)),parseFloat(x*(_180SurPi)));
			circlePoints.push(point);
			bounds.extend(point);
		}
 	}
		if (d < 1.5678565720686044) {
			circle = new GPolygon(circlePoints, '#000099', 1, 1, '##333399', 0.2);	
		}
		else {
			circle = new GPolygon(circlePoints, '#000099', 1, 1);	
		}
		map.addOverlay(circle); 
		map.setZoom(map.getBoundsZoomLevel(bounds));
	
}

 
var TimerValidity;
 
function VerifAdresseDepart(Adresse) {
	if (!Adresse) {Adresse=document.forms["formRecherche"].cpville;}
	clearTimeout(TimerValidity);	

	document.getElementById("CPVilleStatus").innerHTML="";
	document.forms["formRecherche"].cpville.style.backgroundColor="#FFFFFF";
	if (Adresse.value.trim() != "") {
		document.forms["formRecherche"].BtSearch.disabled=true;
		TimerValidity=setTimeout("CheckValidity();",1250);

	}
	else {
		document.forms["formRecherche"].BtSearch.disabled=false;
	}
}

function CheckValidity() {
	var Adresse=document.forms["formRecherche"].cpville;
	var CP=GetCP(Adresse.value);
	var Add=GetAddress(Adresse.value);

	if (!IsCPVilleValid(Adresse.value)) {
		Adresse.value=CP + " " + Add;	
	}
	
	if ((CP=="") || (Add=="")) {
		document.forms["formRecherche"].cpville.style.backgroundColor="#FFCCCC";	
		if ((CP.trim())=="") {
			BadSyntax("Adresse incomplète : merci de préciser un code postal.");
		}
		else {
			BadSyntax("Adresse incomplète : merci de préciser le nom d'une ville.");		
		}
	}
	else {
		document.forms["formRecherche"].cpville.style.backgroundColor="#DDDDDD";	
		CheckAddress();
	}	
}




function CheckAddress() {
	monGeocodeur = new GClientGeocoder(); 		
	document.getElementById("CPVilleStatus").innerHTML="<img src=\"/images/ajax-loader.gif\" alt=\"Chargement\" align=\"absmiddle\">&nbsp;<span style=\"color:black;font-weight:bold;\">&nbsp;Adresse en cours de vérification ...";
	PtStart=new AdherentGeo("",document.forms["formRecherche"].cpville.value,"","");
	PtStart.verifAddress();
}


function BadSyntax(Message) {
	document.getElementById("CPVilleStatus").innerHTML="<span style=\"color:red;font-weight:bold;\">" + Message + "</span>";
}


var RegExDelAdresse1=/ (du|des?|les?|bvd|av|rte?) /i; // supprime tous les mots de 2 ou 3 lettres
var RegExDelAdresse1b=/ (l|d)['`]/i; // supprime tous les lettres suivies d'une apostrophe
var RegExDelAdresse2=/(- )?bp *\d+/i; //Supprime les boites postales (BP xxx) dans l'adresse
var RegExDelAdresse3=/\b(le)? *bourg\b/i; // Supprime les infos du type "le bourg" (utilisé dans les petites communes)
var RegExDelAdresse4=/\b(route|rte?)? *nationale?\b/i; // Supprime les infos du type "route nationale" (utilisé dans les petites communes)
var RegExDelAdresse5=/\bcedex(\b)?(\d)*\b/i; // supprime les infos concernant les "cedex" (utile uniquement pour le CPVille)
var RegExDelAdresse6=/(- )?(zone|site) .*,/i; // supprime les infos concernant les "zone xxxx", "site xxxx" (comme "site industriel" par exemple) 

function CleanAddress(LaChaine) {
	// on ne supprime pas les mots de 2 ou 3 lettre dans le CP/ville, mais uniquement dans l'adresse
	if (isNaN(LaChaine.Left(5))) {
		do {
			LaChaine=LaChaine.replace(RegExDelAdresse1," ");
			LaChaine=LaChaine.replace(RegExDelAdresse1b," ");		
		} while (RegExDelAdresse1.exec(LaChaine) != null)
	}
	LaChaine=LaChaine.replace(RegExDelAdresse2,"");
	LaChaine=LaChaine.replace(RegExDelAdresse3,"");
	LaChaine=LaChaine.replace(RegExDelAdresse4,"");
	LaChaine=LaChaine.replace(RegExDelAdresse5,"");
	LaChaine=LaChaine.replace(RegExDelAdresse6,",");
	LaChaine=LaChaine.replace(/\&/i," et ");
	// on supprime tout ce qu'il y a "avant" un " - " 
	LaChaine=LaChaine.replace("\n"," - ");
	if (LaChaine.indexOf(" - ")!=-1) {
		LaChaine=LaChaine.substr(LaChaine.indexOf(" - ")+2);
	}	
	return LaChaine;
}


function GetDistance(lat1, lng1 , lat2 , lng2 ) {

	// Calcul provenant de http://www.phpsources.org/calcul-de-la-distance-entre-deux-coordonnees-gps-avec-mysql_101.html
   
    lng1*=rad;
    lat1*=rad;
    lng2*=rad;
    lat2*=rad;
    
    var dlo = (lng2 - lng1) / 2;
    var dla = (lat2 - lat1) / 2;
    
	// rayon terrestre : 6 378,137 (wikipedia) 
    var a = Math.sin(dla) * Math.sin(dla) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dlo) * Math.sin(dlo);
    return (6378137 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)));
}





function AdherentGeo(_Nom, _Adresse, _CP_Ville, _URL, _IndexInTab) {

	// Vars privées
	var _Dist=0;
	var _Duration=0;
	var _DistOK=false;
	var GDist = new GDirections();
	var _ChaineGeo;
	var marker;
	var _AdresseReelle=_Adresse; // Sauvegarde de l'adresse réelle
	var _CP_VilleReel=_CP_Ville;
	var _PolyLineDirection;
	var _Errors=0;
	var _longitude, _latitude;
	var NeedAutoReopenMaker=false;
	
	if (_Adresse.toLowerCase().indexOf("lotissement") != -1) { _Adresse=""; }
	
	// valeur par défaut de ChaineGeo
	if (_Nom !="") {
		_ChaineGeo = CleanAddress(_Adresse) + ", " + CleanAddress(_CP_Ville);		
	}
	else {
		_ChaineGeo = CleanAddress(_Adresse);
	} 
	
	
	// vars publiques
	this.Nom=_Nom;
	this.Adresse=_Adresse;
	this.CP_Ville=_CP_Ville;
	this.URL=_URL;
	
	if (_Adresse.trim()== "" && _CP_Ville.trim() == "") {
		_DistOK=true;
	}	
	
	// méthodes publiques
	
	this.getLongitude = function() {
		return _longitude;
	}
	this.getLatitude = function() {
		return _latitude;
	}		
	
	this.setLongitude = function(val) {
		if (val) _longitude=val.replace(",",".");
	}
	this.setLatitude = function(val) {
		if (val) _latitude=val.replace(",",".");
	}		
	
	this.distOK = function() {
		return _DistOK;
	}	
	this.Distance = function() {
		return _Dist;
	}
	
	this.GetDistanceFromDep = function() {
		return GetDistance(PtDep.getLatitude(),PtDep.getLongitude(), _latitude, _longitude);	
	}	

	this.CalculerItineraire=function() {
		CalcItineraire();
	}
	
	function CalcItineraire()  {
		//_ChaineGeo=_Adresse.trim() + ", " + _CP_Ville.trim(); // On mémorise cette chaine de géocodage, pour réutilisation si OK
		//_ChaineGeo=CleanAddress(_ChaineGeo);
		if (LatitudeBase) {
			var Chaine="from:" + LatitudeBase + ", " + LongitudeBase + " to:" + _latitude + ", " + _longitude;
			DoInternalDirectionLoad(Chaine);
		}
	}
	
	function DoInternalDirectionLoad(Chaine) {
		GDist.clear();
		GDist.load(Chaine, {'preserveViewport': 'true','getPolyline' :'true'});
	}
	
	// Gestion, évènement Load du calcul d'itinéraire
	// => permet de mémoriser la Distance calculée
	GEvent.addListener(GDist, "load",
		function GetDist() {
			if (_DistOK==false) {
				_Dist=this.getDistance();
				_Duration=this.getDuration();
				_DistOK=true;
				if (NeedAutoReopenMaker) {
					NeedAutoReopenMaker=false;
					setAndOpenMarkerInfos(false);
				}
			}	
		}

	); 	 
	
	GEvent.addListener(GDist, "error", 
		function HandleError() {
			// vu que tout est géolocalisé, on doit pouvoir avoir tous les itinéraires ! (calcul lancé 3 fois maxi)
			_Errors++;
			if (_Errors<3) {
				CalcItineraire();
			}
			else {

			}
		}
	);
	
	
	// Géocode le point, pour obtenir Latitude/longitude
	// utilisé depuis l'admin, et dans le fichier permettant de géolocaliser toute la base lors de la première init
	this.GeocodePoint=function() {
		_Errors=0;
		DoInternalGeocodePoint();
	}
	
	function DoInternalGeocodePoint() {
		if (monGeocodeur) {
			switch (_Errors) {
				case 0:
				case 1:
					// On retente le 1er géocodage
					break;
				
				case 2:
					// 2eme géocodage
					_ChaineGeo=_CP_Ville;	
					break;
			
				case 3:
					// 3eme géocodage
					_ChaineGeo=_CP_Ville.trim().Left(2) + " " + _CP_Ville.trim().substr(6);
					break;
				
				case 4:
					_DistOK=false;
					return false;
					break;
			} 
		
		
		monGeocodeur.getLocations(_ChaineGeo + ", France",
		function(reponse) {
			if (!reponse || reponse.Status.code != 200) {
				_Errors++;
				DoInternalGeocodePoint();
			} else { 
				var place = reponse.Placemark[0]; 
				if (place.AddressDetails.Accuracy<5 && _Errors<2) {
					_Errors++;
					DoInternalGeocodePoint();
				}
				else {
					 // ChaineCompleteGeoCode+=_Nom + " - " + _Adresse + " " + _CP_Ville + " => " + _ChaineGeo + "<BR>\n"
					 // Utile uniquement pour le debug de la phase de géolocalisation globale de la BDD
					_latitude=place.Point.coordinates[1];
					_longitude=place.Point.coordinates[0];
				}	
			}
		}
		);
	}	
	}
	
	this.showAddress=function(icon)  {
		if (!_latitude) return false;
		
		var Glatitude = _latitude; 
		var Glongitude = _longitude;
		createMarker(Glatitude, Glongitude, icon);
		//CalcItineraire();
					
		if (_Nom=="") {
		// On se positionne sur le point de départ
			map.setCenter(new GLatLng(parseFloat(Glatitude),parseFloat(Glongitude)));
			// on trace un cercle autour de ce point, la fontion va zoomer automatiquement dessus
			doDrawCircle(map.getCenter());
			// On récupère le zoom de départ, qui servira à Toogle le display du cercle
			ZoomAtStart=map.getZoom();
		} 
	}

	this.hideAddress=function() {
		if(marker) map.removeOverlay(marker);
		
	}
	
	
	/* Vérifie l'adresse donnée en point de "départ" */
	this.verifAddress=function()  {
		if (monGeocodeur) {
			monGeocodeur.getLocations(_Adresse + _CP_Ville + ", France" ,
			function(reponse) {
				if (!reponse || reponse.Status.code != 200) { 
						document.getElementById("CPVilleStatus").innerHTML="<span style=\"color:red;font-weight:bold;\">Votre adresse est inconnue, merci de vérifier votre code postal et votre ville.</span>";
						document.forms["formRecherche"].cpville.style.backgroundColor="#FFCCCC";
				} else {
					if (reponse.Placemark.length == 1) {
						var Precision=reponse.Placemark[0].AddressDetails.Accuracy;

						if (Precision >= 4 ) {
							_latitude = reponse.Placemark[0].Point.coordinates[1]; 
							_longitude = reponse.Placemark[0].Point.coordinates[0];	
							document.forms["formRecherche"].LatitudeDepart.value=_latitude;
							document.forms["formRecherche"].LongitudeDepart.value=_longitude;
														
							document.forms["formRecherche"].cpville.style.backgroundColor="#CCFFCC";	
							document.getElementById("CPVilleStatus").innerHTML="<span style=\"color:green;font-weight:bold;\">Adresse valide</span>";								
							document.forms["formRecherche"].BtSearch.disabled=false; // on active le bouton de recherche
							// On reformate le CP / Ville avec les infos trouvées par google
							switch (Precision) {
								case 4 : 
									// ça a retourné un CP + ville valide
									if (reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode  &&  reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality) {
										document.forms["formRecherche"].cpville.value = reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber + " " + reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
									}
									else {
										// On vérifie que l'adress "texte" retournée comporte un CP
										if (!isNaN(parseFloat(reponse.Placemark[0].address.Left(5)))) {
											// On a un nombre, on modifie la zone de saisie
											document.forms["formRecherche"].cpville.value = reponse.Placemark[0].address.replace(", France","");											 
										}
										else {
											// L'adresse texte retournée ne comporte pas de CP, et l'objet GMAP CP  est vide, donc on prend le CP tapé par le user, et on rajoute la chaine "ville" retournée par GMap
											document.forms["formRecherche"].cpville.value=GetCP(document.forms["formRecherche"].cpville.value) + " " + reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName.replace(", France","");
										}
									}
									break;
								case 6 : 
									document.forms["formRecherche"].cpville.value = reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName + ", " + reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber + " " + reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;
									break;
								case 5 : 
								case 9 : 
									document.forms["formRecherche"].cpville.value = reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber + " " + reponse.Placemark[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName;								
									break;
							}
						}
						else {
							//on a une réponse mais pas au niveau "région", donc pas génial					
							document.forms["formRecherche"].cpville.style.backgroundColor="#FFCCCC";	
							document.getElementById("CPVilleStatus").innerHTML="<span style=\"color:red;font-weight:bold;\">Localisation imprécise : merci de vérifier/compléter votre code postal et votre ville.</span>";								

						}
					}
					else  { 
						//on a une réponse mais pas au niveau "ville", donc pas génial					
						document.forms["formRecherche"].cpville.style.backgroundColor="#FFCCCC";	
						document.getElementById("CPVilleStatus").innerHTML="<span style=\"color:red;font-weight:bold;\">Adresse imprécise : merci de vérifier/compléter votre code postal et votre ville.</span>";								
					}
				}
			}
			);
		}
	}
	
	
	this.ShowMarker=function() {
		//alert(CalcDistance());
		setAndOpenMarkerInfos(true);
		map.setZoom(ZoomAutoLimit);
		//alert(_latitude + " " + _longitude);
	}
	
	this.ShowItineraire=function() {
		ShowPolyLineDirection();
	}
	
	this.HideItineraire=function() {
		HidePolyLineDirection();
	}
	
	// Méthodes privées
	
	//Créer les marqueurs avec leur contenus
	function createMarker(lat, lng, icon) {
		/* ... Création d'un nouveau point nommé "point" ayant pour latitude "lat" et longitude "lng" ... */ 
		/*_latitude=lat;
		_longitude=lng;
		*/
		var point = new GLatLng(lat, lng); 		
		var markerOptions;
		
		/* Gestion de l'icone  */
		switch (icon) {
			case "blue": 
				// icone "bleue" pour le point de départ
				baseIcon
				baseIcon.image = URLMarkerBlue;
				
				markerOptions = { icon:baseIcon };
				break;

			case "":				
			case "red":
				baseIconSmall
				baseIconSmall.image = URLMarkerRed;			
				markerOptions = { icon:baseIconSmall }; // icone par défaut (rouge)
				break;
				
			case "green":
				// icone "verte" pour les à bonne distance
				
				baseIconSmall
				baseIconSmall.image = URLMarkerGreen;			
				markerOptions = { icon:baseIconSmall };
				break;			
		}
	
		// marker est déclaré global à la classe
		marker = new GMarker(point, markerOptions); //, markerOptions);   //créer les marqueurs
		GEvent.addListener(marker, "mouseover", function() {
			setAndOpenMarkerInfos(false);
			}
		);
		
		GEvent.addListener(marker, "click", function() {
				if (!_PolyLineDirection && _DistOK) {
					ShowPolyLineDirection();
					setAndOpenMarkerInfos(false);
				}
				else {
					setAndOpenMarkerInfos(true);
				}
			}
		);
		
		GEvent.addListener(marker, "mouseout", function() {
			//marker.closeInfoWindow(); // on cache ce point 
			}
		);

	
		map.addOverlay(marker);  //créer les marqueurs sur la carte
		
	}

	function ShowPolyLineDirection() {
		if (!_PolyLineDirection ) {
			_PolyLineDirection=GDist.getPolyline()
			map.addOverlay(_PolyLineDirection);
			setAndOpenMarkerInfos(false);
		}			
	}
	
	function HidePolyLineDirection() {
		if (_PolyLineDirection) {
			map.removeOverlay(_PolyLineDirection);
			_PolyLineDirection=null;
			setAndOpenMarkerInfos(false);
		}	
	}
	
	function setAndOpenMarkerInfos(DoZoom) {
		if (marker) {
			if (_Nom != "") { 
				var Chaine;
				var _add=_AdresseReelle;
				// Mise en forme de l'adresse
				_add=_add.replace(" - ","<BR>")
				_add=_add.replace("\n","<BR>")	

				Chaine="<B>" + _Nom +"</B> <BR />" + _add + "<BR />" + _CP_VilleReel;
				if (_DistOK) {
					Chaine+="<BR/><BR/><B>Distance : </b>" + _Dist.html + " (Environ " + _Duration.html + ")";
					if (!_PolyLineDirection) {
						Chaine+="&nbsp;&nbsp;<a href=\"#\" onClick=\"MontrerItinetaire(" + _IndexInTab + ");return false;\">Afficher l'itinéraire</a>";
					}
					else {
						Chaine+="&nbsp;&nbsp;<a href=\"#\" onClick=\"CacherItinetaire(" + _IndexInTab + ");return false;\">Masquer l'itinéraire</a>";
					}
				}
				else {
					if (LatitudeBase) {
						CalcItineraire();
						Chaine+="<BR/><BR/><b><img src=\"/images/ajax-loader.gif\" alt=\"Chargement\" align=\"absmiddle\">&nbsp;Calcul de l'itinéraire en cours ...</b>";
						NeedAutoReopenMaker=true;
					} 
				}				

				if (_URL!="") Chaine+="<BR/><BR/><a href=\"" + _URL + "\" onclick=\"NewWin(this.href);return false;\">Consulter la fiche détaillée</a>";						
				marker.openInfoWindowHtml(Chaine); //sur clic, afficher les données dans le marqueur						
			}
			else {
				marker.openInfoWindowHtml('<B>Départ</B> <BR />' + _AdresseReelle );   //sur clic, afficher les données dans le marqueur
			}
			
			if (DoZoom ) { // on Zoom uniquement si on a déjà affiché l'itinéraire (si dispo)
				map.setCenter(marker.getPoint());
				
				var CurrentZoom=map.getZoom();
				if (CurrentZoom<ZoomAutoLimit) {
					map.setZoom(ZoomAutoLimit);
				}
				else {
					CurrentZoom+=2;
					map.setZoom(CurrentZoom);
				}
			}			
		}

		
	}

}



var NbInPerim=0;
var NbOutPerim=0;
var i_ShowPoint=0;
var i_Itineraire=0;
var TimerShowPoints;
var TimerCalcItineraire;
var TimerDelay=80;

function InitTabPoints() {
	var i;
	TailleTab=TabRaisonSociale.length;

	for(i=0;i<TailleTab;i++) {
		P=new AdherentGeo(TabRaisonSociale[i],TabAdresse[i],TabCPVille[i], TabURL[i], i);
		P.setLongitude(TabLongitude[i]);
		P.setLatitude(TabLatitude[i]);
		TabPoints[i]=P; // mémorisation de l'adhérent 
	}

	DivInfosGeo.innerHTML="";	
	TimerShowPoints=window.setInterval("PutPointsOnTheMap();",TimerDelay);
	if (DistMax!=0) {
		// on lance le calcul après un délai, pour ne pas tout faire calculer en même temps
		setTimeout("LaunchCalculerIntineraires();",(TimerDelay+1)*(TailleTab+1));		
	}
	else {
		DivLoadingIMG.innerHTML="<img src=\"/images/ajax-loader.gif\" alt=\"Chargement\" align=\"absmiddle\">";
	}
}

function LaunchCalculerIntineraires() {
	DivLoadingIMG.innerHTML="<img src=\"/images/ajax-loader.gif\" alt=\"Chargement\" align=\"absmiddle\">";
	TimerCalcItineraire=window.setInterval("CalculerItineraire();",TimerDelay*2.5);
}

function PutPointsOnTheMap() {
	if (i_ShowPoint<TailleTab) {
		if (DistMax!=0 && TabPoints[i_ShowPoint].GetDistanceFromDep()<=DistMax) {
			TabPoints[i_ShowPoint].showAddress("green");
			NbInPerim++;					
			document.getElementById("LinkLocMap" + i_ShowPoint).style.display="inline";
			document.getElementById("imgLocMap" + i_ShowPoint).src=URLMarkerGreen;
		}
		else {
			TabPoints[i_ShowPoint].showAddress("red");
			NbOutPerim++;			
			document.getElementById("LinkLocMap" + i_ShowPoint).style.display="inline";		
			document.getElementById("imgLocMap" + i_ShowPoint).src=URLMarkerRed;
		}
		i_ShowPoint++;
				
		if (DistMax!=0) {
			DivInfosGeo.innerHTML=(NbInPerim) + ((NbInPerim>=2)?" entreprises":" entreprise") + " dans la zone demandée";	
			if (NbOutPerim != 0) DivInfosGeo.innerHTML+="&nbsp;et&nbsp;" + NbOutPerim + ((NbOutPerim>=2)?" entreprises":" entreprise") + " dans la zone étendue de 10%";			
		}
		else {
			DivLoading.innerHTML="Affichage en cours ... " + Math.round(1000*i_ShowPoint/TailleTab)/10 + "%";		
		}	

	}
	else {
		clearTimeout(TimerShowPoints);
		if (DistMax != 0) {
			DivInfosGeo.innerHTML="<img src=\"" + URLMarkerGreen + "\"  class=\"imgLoc\">&nbsp;" + (NbInPerim) + ((NbInPerim>=2)?" entreprises":" entreprise") + " dans la zone demandée";		
			if (NbOutPerim != 0) DivInfosGeo.innerHTML+="&nbsp;et&nbsp;<img src=\"" + URLMarkerRed + "\"  class=\"imgLoc\">&nbsp;" + NbOutPerim + ((NbOutPerim>=2)?" entreprises":" entreprise") + " dans la zone étendue de 10%";
		}	
		else {
			DivLoadingIMG.innerHTML="";
			DivLoading.innerHTML="";	
		}
	}
}


function CalculerItineraire() {
	if (i_Itineraire<TailleTab) {
		while (i_Itineraire<TailleTab && TabPoints[i_Itineraire].distOK()) i_Itineraire++;
		DivLoading.innerHTML="Calcul des itinéraires en cours ..." + Math.round(1000*i_Itineraire/TailleTab)/10 + "%";			
		TabPoints[i_Itineraire].CalculerItineraire();	
		i_Itineraire++;
	}
	else {
		DivLoadingIMG.innerHTML="";
		DivLoading.innerHTML="";	
		clearTimeout(TimerCalcItineraire);
	}
}



var mouse_x, mouse_y;
function register_position(){
	mouse_x = 0;
	mouse_y = 0;
	document.onmousemove = position;
}

function position(evt){
	if(!evt) evt = window.event;	
	mouse_x = evt.clientX;
	mouse_y = evt.clientY;
}

function ShowThisPointOnMap(lien, indice) {
	var curtop=0;
	var obj;
	var yClic;
	var ZoneAffichee=document.body.offsetHeight;

	yClic=mouse_y;
	
	obj=lien;
	curtop=0
	
	// recherche de la position du lien
	if (obj.offsetParent) {
		do {
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}

	if (indice<TabPoints.length) {
		if (document.body.scrollHeight >= 1700) { 
			// on s'arrange pour que ça ne dépasse pas en bas de la page 
			if (curtop+document.getElementById("map").offsetHeight > document.body.scrollHeight) {
				curtop=document.body.scrollHeight - document.getElementById("map").offsetHeight - 40 // la carte dépasse de 38 px sinon ...
			}
			
					
			// on se positionne par rapport à l'élement "DivResultats"
			// on enlève la taille du corps du doc (partie form de recherche), la taille de la zone de recherche, le bandeau de 216 px, et le menu (78 px)
			if (document.all) {
				curtop-=(document.getElementById("DivResultats").offsetTop + document.getElementById("DivResultats").offsetHeight + 216 + 78);
			}
			else {
				curtop-=(document.getElementById("DivResultats").offsetTop + document.getElementById("DivResultats").offsetHeight + 10);
			} 
			// on position la carte au niveau du lien, puis on affiche le marker
			document.getElementById("map").style.top=curtop;
				
		}	
				
		TabPoints[indice].ShowMarker();
		if (yClic > (ZoneAffichee/2)) {
			window.scrollBy(0,2*(yClic - ZoneAffichee/2)); // pour positionner la fenêtre avant le lien cliqué
		}
	}
}

function MontrerItinetaire(Indice) {
	TabPoints[Indice].ShowItineraire();
}

function CacherItinetaire(Indice) {
	TabPoints[Indice].HideItineraire();
}
