//google maps

function MyLoader(nom, adr1, adr2, cp, com, photo, tel)
{
	load();
	geocode(nom, adr1, adr2, cp, com, photo, tel, adr1+" "+com+" france");
}

function load() 
{ 
	if (GBrowserIsCompatible()) {
		//Création de la map :
		var map = new GMap2(document.getElementById("map"));
		
		//controles :
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		
		//centrage de la map :
		map.setCenter(new GLatLng(0, 0), 2); 
		
		//instanciation du geocode :
		geocoder = new GClientGeocoder();
		
	} 
	else
	{
		alert("Desole, l'API Google Maps n'est pas compatible avec votre navigateur.");
	}
}

function geocode(nom, adr1, adr2, cp, com, photo, tel, address)
{
	geocoder.getLatLng(
		address, 
		function(point) 
		{
			if (!point)
			{
				if (address == com + " france")
				{
					alert(address + " n'est pas reference sur la carte");
					address = cp + " france";
					geocode(nom, adr1, adr2, cp, com, photo, tel, address);
				}
				else
				{
					alert(address + " n'est pas reference sur la carte");
					address = com + " france";
					geocode(nom, adr1, adr2, cp, com, photo, tel, address);
				}
			}
			else
			{
				//Création de la map :
				var map = new GMap2(document.getElementById("map"));
				
				//controles :
				map.addControl(new GLargeMapControl());
				map.addControl(new GMapTypeControl());
				
				//recentrage de la maps
				map.setCenter(point, 12);
				
				//création du Marker
				var html = "<table border=0><tr><td><img src="+ photo + " width=100 /></td><td>" + nom + "<br>" + adr1  + "<br>" + cp +" "+ com + "<br><br>Telephone : "+ tel + "</td></tr></table>";
				var marker = createMarker(point, html);
				map.addOverlay(marker);
			}
		}
	);
	return false;
}

function createMarker(point,html)
{ 
	var marker = new GMarker(point);
	GEvent.addListener(
		marker,
		"click",
		function() 
		{ 
			marker.openInfoWindowHtml(html); 
		}
	); 
	return marker;
}