
function GMload(map_id, w, h, address, city, state){
	var divEl = document.getElementById(map_id);
    if (GBrowserIsCompatible()) {
		divEl.style.Display="block";
		showAddress(w, h, map_id, address, city, state);
	}
	else{
		divEl.style.Display="none";
	}
}
function showAddress(w, h, divId, address, city, state) {
var geocoder = new GClientGeocoder();
  if (geocoder) {
	  total_address = address;
	  if(city) total_address += ", "+city;
	  if(state) total_address += ", "+state;
	  geocoder.getLatLng(
	    total_address,
	    function(point) {
		  var divEl = document.getElementById(divId);
		  divEl.style.width = w+"px";
	      if (!point) {
			if(city != null)
				setTimeout("showAddress("+w+", "+h+", \""+divId+"\", \""+address+"\", null, \""+state+"\")", 500);
			else if(state != null && city == null)
				setTimeout("showAddress("+w+", "+h+", \""+divId+"\", \""+address+"\", null, null)", 500);
			else{
				divEl.innerHTML = "GOOGLE MAP -- ADDRESS NOT FOUND";
				divEl.style.height = "auto";
				divEl.style.padding = "2px";
				divEl.style.align = "center";
				divEl.style.fontWeight = "bold";
			}
	      } else {
			divEl.style.height = h+"px";
			divEl.style.padding = "0px";
			divEl.style.Display="block";
			
			var map = new GMap2(divEl, {draggableCursor: 'move', draggingCursor: 'move'});
	        map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT));
	        map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT));
	        map.setMapType(G_NORMAL_MAP);
//			map.enableScrollWheelZoom();
//        		map.enableDoubleClickZoom();
	        keyboardhandler = new GKeyboardHandler(map);
		
			var marker = new GMarker( point, {title: address});
			map.setCenter( point, 14);
	        map.addOverlay(marker);
			//marker.openInfoWindowHtml();
			  var info = document.getElementById(divId+"_info");
			  if(info){
			    total_address = total_address.replace(" ", "+");
				info.innerHTML = "<a target=\"_BLANK\" href=\"http://maps.google.be/maps?f=q&q="+total_address+"&ie=UTF8&ll="+point.toUrlValue()+"&z=16&iwloc=addr\">Full Google Map</a>";
			  }
	      }
		  divEl.style.borderWidth = "1px";
		  divEl.style.borderStyle = "solid";
		  divEl.style.borderColor = "black";
		  divEl.style.overflow = "hidden";
	    }
	  );
  }
  else{
	  divEl.style.Display="none";
  }
}


