var Latitude = -30.03927058881221;
var Longitude = -51.22028775370382;
var Zoom = 16;
var mapa;

function initmapa()
{
	if (GBrowserIsCompatible()) {
			mapa = new GMap2(document.getElementById("mapa"));
			var location = new GLatLng(Latitude, Longitude);
			mapa.setCenter(location, Zoom, G_HYBRID_MAP);
			mapshift();
			mapa.addControl(new GSmallMapControl());
			//mapa.addControl(new GMapTypeControl());
			//var geoXml = new GGeoXml("http://azulcobalto.maratona.uni5.net/img/azulcobalto.kml");
			//mapa.addOverlay(geoXml);
			var marker = new GMarker(location, {title:"Rua Lima e Silva, 744"});
			mapa.addOverlay(marker);
			
			GEvent.addListener(mapa,"zoomend",function() {
													   mapshift();
													   });
			GEvent.addListener(mapa,"maptypechanged",function() {
													   mapshift();
													   });

	}
}

function mapshift() {
	//alert("passou");
	tipomapa = mapa.getCurrentMapType();
	if(tipomapa == G_HYBRID_MAP) {
		Zoom = mapa.getZoom();
		switch (Zoom) {
			case 15:
			offsetleft = "-6px";
			offsettop = "2px";
			break
			case 16:
			offsetleft = "-11px";
			offsettop = "5px";
			break
			case 17:
			offsetleft = "-25px";
			offsettop = "10px";
			break
			default:
			offsetleft = "0px";
			offsettop = "0px";
		}
		//navega arvore DOM ate alcançar a div do mapa de ruas
		nivel1 = document.getElementById("mapa");
		nivel2 = nivel1.firstChild;
		nivel3 = nivel2.firstChild;
		nivel4 = nivel3.firstChild;
		nivel4 = nivel4.nextSibling;
		divruas = nivel4.lastChild;
		//altera atributos
		divruas.setAttribute("id", "ruas");
		document.getElementById("ruas").style.left = offsetleft;
		document.getElementById("ruas").style.top = offsettop;
	}
	
}

window.onunload = GUnload;