// API Google Maps

var map = null;
var geocoder = null;

function initialize(addressText, approche, address, neighborhood, cep, city, state, telephone) {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("mapa_loja"));
    geocoder = new GClientGeocoder();
    
		// Cria o conteúdo visualizado do site
		var text = "";
		text += address ? address + '<br />' : '';
		text += neighborhood ? neighborhood + '<br />' : '';
		text += city ? city + ' - ' + state + '<br />' : '';
		text += cep ? cep + '<br />' : '';
		text += telephone ? telephone + '<br />' : '';
		text = '<div class="google_maps_balao"><br />' + text + '</div>'
					
	  showAddress(addressText, approche, text);	  
  }
  else {
  	alert("Não foi possível exibir o mapa.");
  }  
}


function showAddress(addressText, approche, text) {
  if (geocoder) {
    geocoder.getLatLng(
      addressText,
      function(point) {
        if (!point) {
          alert(addressText + " not found");
        } else {          
					var Icon = new GIcon(G_DEFAULT_ICON);
					Icon.image = "/imagens/ico_pino_01.png";
					
					function createMarker(point, html) {
						var marker = new GMarker(point,Icon);
						GEvent.addListener(marker, "click", function() {
						marker.openInfoWindowHtml(html);
						});
						return marker;
					}
					
					map.addControl(new GLargeMapControl());
					map.setCenter(point, approche);
					
					marker = createMarker(point, text);
					map.addOverlay(marker);
					
					// Para mostrar o mapa mostrando as informações
					marker.openInfoWindowHtml(text);
        }
      }
    );
  }
}

// API Google Maps - FIM
