// Google Map ==================================================================

var map = null;
var geocoder = null;

function load(div,adresse,adresse2,afficherControl,afficherZoom,niveauZoom,pourEditos,urlPrincipale){
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById(div));
		geocoder = new GClientGeocoder();
		showAddress(adresse,adresse2,afficherControl,afficherZoom,niveauZoom,pourEditos,urlPrincipale);
	}
}
function showAddress(adresse,adresse2,afficherControl,afficherZoom,niveauZoom,pourEditos,urlPrincipale) {
	if (geocoder) {
		geocoder.getLatLng(adresse,
		function(point) {
			if (!point){
				if(pourEditos==true) alert('L\'adresse exacte n\'a pas été trouvée. Seule la ville sera affichée.');
				load('map',adresse2,'',afficherControl,afficherZoom,niveauZoom,pourEditos,urlPrincipale);
			}
			else {
				// Carte
				if(afficherControl=='oui'){
					map.addControl(new GSmallMapControl());
					map.addControl(new GMapTypeControl());
					map.setCenter(point, niveauZoom,G_HYBRID_MAP);// Mode mixte
				}
				else map.setCenter(point, niveauZoom);// Mode non mixte
				// Icone au centre
				var icon = new GIcon();
				icon.image = "http://www.1001fleurs.com/css/images/pictogrammes/labmap.png";
				icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
				icon.iconSize = new GSize(12, 20);
				icon.shadowSize = new GSize(22, 20);
				icon.iconAnchor = new GPoint(6, 20);
				icon.infoWindowAnchor = new GPoint(5, 1);
				map.addOverlay(new GMarker(point, icon));
				// Lightbox
				if(afficherZoom=='oui'){
					GEvent.addListener(map, "click", function() {
						afficherGrille('700','400');
						document.getElementById('zoneLightBox').innerHTML='<img id="fermer" src="'+urlPrincipale+'/css/images/pictogrammes/fermer.png" alt="Fermer" onclick="masquerGrille();" /><h1>'+adresse+'</h1><div id="carteGoogleEnGrand"></div>';
						load('carteGoogleEnGrand',adresse,adresse2,'oui','non',10,pourEditos,urlPrincipale);
					});
				}
			}
		}
		);
	}
}