// 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)
{
	var icon = new GIcon();
	icon.image = icon_path;
	
	if(icon_path == "images/building-icon-blue.png")
	{
		icon.iconAnchor = new GPoint(40, 35);
		icon.iconSize = new GSize(40, 35);
	}
	else
	{
		icon.iconAnchor = new GPoint(40, 35);
		icon.iconSize = new GSize(40, 35);
	}
	icon.infoWindowAnchor = new GPoint(20, 20);

	var building_icon = icon;
	
	return building_icon;
}

function showAddress(address, info, icon_path, zoom, centra) {
	
  if (geocoder) {
	  
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) 
		{
		  //alert("La dirección no se ha encontrado");
		} 
		else 
		{
			if(!zoom){ zoom = 15; }
			
			if(centra==1){ 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);-->
		}
	  }
	);
  }
}
