var mapa;

function initmapa(estado)
{
	if (GBrowserIsCompatible()) {
		var Zoom = 15;
		switch(estado) {
			case 1: //RS
				var Latitude = -29.97691600456989;
				var Longitude = -51.11654418996366;
				var endereco = "Av. Assis Brasil, 9000";
				break;
			case 2: //SC
				var Latitude = -27.61843968316822;
				var Longitude = -48.64860890592609;
				var endereco = "BR101, km 212";
				break;
			case 3: //PR
				var Latitude = -25.38859255063755;
				var Longitude = -49.1923891482854;
				var endereco = "Av. Abel Scuissiato, 3020";
				break;
		}
		mapa = new GMap2(document.getElementById("mapa"));
		var location = new GLatLng(Latitude, Longitude);
		mapa.setCenter(location, Zoom, G_HYBRID_MAP);
		//mapshift();
		mapa.addControl(new GSmallMapControl());
		var marker = new GMarker(location, {title:endereco});
		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;