var map,point,marker;
var gdir;
var geocoder = null;
var addressMarker;

var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(12, 20);
	var Mapa0 = new Object();
		 Mapa0.MId="map";
		 Mapa0.MLat = 43.28145;
 		 Mapa0.MLng = -1.95063;	 
		 Mapa0.MZoom = 14;
	var Punto0 = new Object();
		 Punto0.PLat = -1.95063;
		 Punto0.PLng = 43.28145;
		 

		
		
		 
		 Punto0.PLat = -1.95063;
		 Punto0.PLng = 43.28145;
		 Punto0.PIcon = icon;
		 Punto0.PTab1="Info";
		 Punto0.PTab2="Como llegar";
		 Punto0.PTab1Info="<h2>APASA</h2><p class='pGoogle'>Pol&iacute;gono Bidebitarte. Avda. Donostia, 76<br />20115 Astigarraga - Gipuzkoa - (Spain).<br /> TEL. 943 552 924 | Fax. 943 556 425<br /> <a href='mailto:apasa@apasa.info'>apasa@apasa.info</a></p><br />";
		 Punto0.PTab2Info="<p class='pGoogle'>Ej.:  Calle Serrano, Madrid</p><form action='http://maps.google.es/maps' method='get' target='_blank'><input type='text' name='saddr' id='saddr' class='inpuGoogle'/><input type='submit' class='btn' value='Enviar' /><input type='hidden' name='daddr' id='daddr' value='43.28145,-1.95063' class='oculto' /><br class='clear' /></form>";
function crear_mapa(Mapa){
	//Map
	map = new GMap2(document.getElementById(Mapa.MId));
	map.setCenter(new GLatLng(Mapa.MLat,Mapa.MLng), Mapa.MZoom);
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl(1));
}
function crear_punto(Punto){
	// Emplazar marcadores
	point = new GPoint(Punto.PLat,Punto.PLng);
	marker = new GMarker(point, Punto.PIcon);
	map.addOverlay(marker);
	GEvent.addListener(marker, "click", function() {
                       var html, html2
						map.savePosition();
						html = Punto.PTab1Info;
							html2 =	Punto.PTab2Info;
			
						var infoTabs = [
						new GInfoWindowTab(Punto.PTab1, html),
						new GInfoWindowTab(Punto.PTab2,html2)
						];
						marker.openInfoWindowTabsHtml(infoTabs);
                     });
}


function mostrar_mapa(Mapa){
			map.panTo(new GLatLng(Mapa.MLat, Mapa.MLng));
}
function mostrar_punto(Punto){
	marker.setPoint(new GLatLng(Punto.PLat,Punto.PLng));
	GEvent.addListener(marker, "click", function() {
                       var html, html2
						map.savePosition();
						html = Punto.PTab1Info;
							html2 =	Punto.PTab2Info;
			
						var infoTabs = [
						new GInfoWindowTab(Punto.PTab1, html),
						new GInfoWindowTab(Punto.PTab2,html2)
						];
						marker.openInfoWindowTabsHtml(infoTabs);
                     });
	crear_punto(Punto);
}