var map = null;
var geocoder = null;
var adrTest = null;

function load() {
	 if (GBrowserIsCompatible()) {
	   	  map = new GMap2(document.getElementById("map"));
		  map.addControl(new GSmallMapControl());
		  map.addControl(new GMapTypeControl());
	   	  map.setCenter(new GLatLng(37.4419, -122.1419), 13);
		  geocoder = new GClientGeocoder();
	 }
}

function showAddress(address){
	//alert(address);
	if (geocoder){
	  geocoder.getLatLng(
	    address,
	    function(point){
	    	if (!point){
			//alert(address + " non trouvé");
			document.getElementById('nontrouve').style.display="inline";
		}else{
			map.setCenter(point,16);
			var marker = new GMarker(point);
			map.addOverlay(marker);
//			marker.openInfoWindowHtml(address);
			GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml(address);
			});
		}
	       }
	  );
	}
}

function resizeMap(){
	dv = document.getElementById("map");
	dv.style.height = document.body.clientHeight - 10;
	dv.style.width = document.body.clientWidth - 10;
	showAddress(adrTest);
}

function init() {
	load();
	//alert(adress);
	showAddress(adress);
}

if (window.addEventListener){
  window.addEventListener('load', function (){ init(); } , false);
} else if (window.attachEvent) { //-- IE
  window.attachEvent('onload', function (){ init(); } );
}