﻿var map = null;
var geocoder = null;

function load(adresse) {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map"));
	map.setCenter(new GLatLng(9.180758, 48.783580), 15);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());		
	geocoder = new GClientGeocoder();
  }	  
  showAddress(adresse);
}

function showAddress(address, name) {
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  document.getElementById('mapContainer').style.visibility = 'hidden';
		  document.getElementById('mapContainer').style.width = '0px';
		  document.getElementById('mapContainer').style.height = '0px';
		  document.getElementById('map').style.width = '0px';
		  document.getElementById('map').style.height = '0px';
		} else {
		  document.getElementById('mapContainer').style.width = 'auto';
		  document.getElementById('mapContainer').style.height = 'auto';
		  map.setCenter(point, 15);
		  var marker = new GMarker(point);
		  map.addOverlay(marker);
		  
		}
	  }
	);
  }
}