// Longitude = -51.193521;
// Latitude = -30.041105;
var Zoom = 16;

function montamapa()
{
	if (GBrowserIsCompatible()) {
		mapa = new GMap2(document.getElementById("divMapa"));
		mapa.setUIToDefault();
		var location = new GLatLng(Latitude, Longitude);
		mapa.setCenter(location, Zoom, G_NORMAL_MAP);
		
		
		//adiciona escala
		mapa.addControl(new GScaleControl());
		//adiciona controle de tipo de mapa
		mapa.addControl(new GMapTypeControl());
		//smooth zoom
		mapa.enableContinuousZoom();
		//zoom com a rodinha do mouse
		mapa.enableScrollWheelZoom();
		
		
		//cria icone
		var iconeVitrine = new GIcon();
		iconeVitrine.image = "imagens/ponto_mapa.png";
		iconeVitrine.iconSize = new GSize(100,34);
		iconeVitrine.iconAnchor = new GPoint(100, 20);
		iconeVitrine.infoWindowAnchor = new GPoint(100, 2);
		
		//adiciona marcador
		var latlng = new GLatLng(Latitude, Longitude);
		var marcador = new GMarker(latlng, {title: "IAHCS", icon: iconeVitrine});

		//formata html da aba de texto
		//var abatexto = "<div style='width:280px; height:213px;'><img border='0' style='margin-top:0;' src='imagens/iahcs_fachada.jpg' /></div>";		
		//quando clica no icone
		GEvent.addListener(marcador, "click", function () {
			marcador.openInfoWindowHtml(abatexto);
		});
		mapa.addOverlay(marcador);
		
		divComoChegar = document.getElementById("divComoChegar");
		comoChegar = new GDirections(mapa, divComoChegar);
		
		marcador.openInfoWindowHtml(abatexto);
	} else {
		alert("Seu navegador não suporta Google Maps!");
	}
}

function mostraRota() {
	var enderecoPartida = document.getElementById("enderecoPartida").value;
	comoChegar.load("from: " + enderecoPartida + " to: Rua Cel. Corte Real, 75 Porto Alegre Brasil",{ "locale": "pt_BR" });
}


window.onload = function(){
	montamapa();
};


