 var map;
 var geoCodeur;
 
 var isAjax;
 
 var verifPointLength;




/*   // GOOGLE MAP V2   */
  function initialize() 
  {
	
	if(GBrowserIsCompatible()) 
	{
	
	  map = new GMap2(document.getElementById('myMap'));
	  map.setCenter(new google.maps.LatLng(  44.28269110344576,  23.692618700000008), 4);

	  map.addControl(new GLargeMapControl());
	  map.addControl(new GMapTypeControl());
	  map.addMapType(G_SATELLITE_3D_MAP);
	  geoCodeur = new GClientGeocoder();

	}

  }
 
/* Si ajax=true on renvoie le resultat avec idPoint vers PHP pour l'enregistrer dans la base */
function geocodeAdresse( lieu, idPoint, isAjax )
{

	 /* Si isAjax : si on veut enregistrer les données trouvéees dans la base */
	 if ( isAjax )
	 {	 
		new GClientGeocoder().getLocations( lieu, function(response)
		{
				
				if (response.Status.code == 200) 
				{ 
					var place = response.Placemark[0];
					
					var latGeoloc = place.Point.coordinates[1];
					var lngGeoloc = place.Point.coordinates[0];

					var url ='../../include/ajax/ajax_Geocode.php';
			
					new Ajax.Request(
					url,
					{
						method:'post',
						parameters: { id:idPoint, lat:latGeoloc, lng:lngGeoloc },
						onComplete:geocodeAdresseCallBack
					});


					
				}
		});
	}
	else
	{
		new GClientGeocoder().getLocations( lieu, function(response)
		{
				/* // document.getElementById("test").innerHTML += response.Status.code+"<BR />"; */
				if (response.Status.code == 200) 
				{ 
					var place = response.Placemark[0];

					map.setCenter(new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]), 7);

				}
		});
	
	}
	
			

}


function geocodeAdresseCallBack ( response )
{

		

}


function geocodeAllAdresse ()
{
	var expression = new RegExp("^[0-9]{*}$");
		
	for ( var p in tabPoint )
	{
		if ( expression.test(p))	
		{
			geocodeAdresse( tabPoint[p], p, true )
		}
	}	
		
}

document.write("<script type=\"text/javascript\">initialize();</script>");



 
