// JavaScript Document
var map = null;
var geocoder = null;
var building_icon = null;

function initialize() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map_canvas"));
	map.addControl(new GSmallMapControl());
	geocoder = new GClientGeocoder();
  }
}

function getIcon(icon_path)
{
	if(!building_icon)
	{
		var icon = new GIcon();
		icon.image = icon_path;
		icon.iconAnchor = new GPoint(29, 37);
		icon.infoWindowAnchor = new GPoint(15, 0);
		icon.iconSize = new GSize(29, 37);

		building_icon = icon;
	}
	return building_icon;
}

function showAddress(address, info, icon_path, zoom) {
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  //alert("La dirección no se ha encontrado");
		} else {
			if(!zoom){ zoom = 15; }
		  map.setCenter(point, zoom);
		 
		  var marker = new GMarker(point, { icon: getIcon(icon_path) });
		  GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(info);
		  });
		  map.addOverlay(marker);
		  <!--marker.openInfoWindowHtml(address);-->
		 
		}
	  }
	);
  }
}
