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);

	//Plano Pamplona
	var Mapa = new Object();
		 Mapa.MId="map0";
		 Mapa.MLat = 42.832500;
 		 Mapa.MLng = -1.665200;	 
		 Mapa.MZoom = 16;
	var Punto = new Object();
		 Punto.PLat = -1.665200;
		 Punto.PLng = 42.832500;
		 Punto.PIcon = icon;
		 Punto.PTab1="Avanco";
		 Punto.PTab2="C\u00F3mo llegar";
		 Punto.PTab1Info="<p class='pGoogle'>Edificio Ronda, P.5&ordf; y 6&ordf;<br />Madres de la Plaza de Mayo, 44 <br />31013 Artica-Pamplona<br />Tel&eacute;fono: 948 26 06 00 </p><br />";
		 Punto.PTab2Info="<p class='pGoogle'>Ej.:  Calle Tajonar, Pamplona</p><form action='http://maps.google.es/maps' method='get' target='_blank'><input type='text' name='saddr' id='saddr' class='inpuGoogle' style='width:150px;padding:0;' /><input type='submit' class='botonGoogle' style='width:70px;' value='Enviar' /><input type='hidden' name='daddr' id='daddr' value='40.42992,-3.67915' style='display:none;' /><br class='clear' /></form>";


	//Plano Madrid
	var Mapa1 = new Object();
		 Mapa1.MId="map1";
		 Mapa1.MLat = 40.42992;
 		 Mapa1.MLng = -3.67915;	 
		 Mapa1.MZoom = 16;
	var Punto1 = new Object();
		 Punto1.PLat = -3.67915;
		 Punto1.PLng = 40.42992;
		 Punto1.PIcon = icon;
		 Punto1.PTab1="Avanco";
		 Punto1.PTab2="C\u00F3mo llegar";
		 Punto1.PTab1Info="<p class='pGoogle'>Plaza del Marqu&eacute;s de Salamanca, 9, Pl.1&ordf;<br />28006 Madrid<br />Tel&eacute;fono: 91 557 23 90 </p><br />";
		 Punto1.PTab2Info="<p class='pGoogle'>Ej.:  Calle Tajonar, Pamplona</p><form action='http://maps.google.es/maps' method='get' target='_blank'><input type='text' name='saddr' id='saddr' class='inpuGoogle' style='width:150px;padding:0;' /><input type='submit' class='botonGoogle' style='width:70px;' value='Enviar' /><input type='hidden' name='daddr' id='daddr' value='40.42992,-3.67915' style='display:none;' /><br class='clear' /></form>";
	
	
	//Plano Sevilla
	var Mapa2 = new Object();
		 Mapa2.MId="map2";
		 Mapa2.MLat =  37.382179;
 		 Mapa2.MLng =  -5.969739;	 
		 Mapa2.MZoom = 15;
	var Punto2 = new Object();
		 Punto2.PLat = -5.969740;
		 Punto2.PLng = 37.382252;
		 Punto2.PIcon = icon;
		 Punto2.PTab1="Avanco";
		 Punto2.PTab2="C\u00F3mo llegar";
		 Punto2.PTab1Info="<p class='pGoogle'>Eduardo Dato 69<br />Planta 8 - Modulo 4<br /> 41005 Sevilla<br />Tel&eacute;fono: 954 25 81 30 </p><br />";
		 Punto2.PTab2Info="<p class='pGoogle'>Ej.:  Calle Tajonar, Pamplona</p><form action='http://maps.google.es/maps' method='get' target='_blank'><input type='text' name='saddr' id='saddr' class='inpuGoogle' style='width:150px;padding:0;' /><input type='submit' class='botonGoogle' style='width:70px;' value='Enviar' /><input type='hidden' name='daddr' id='daddr' value='37.406488,-5.93045' style='display:none;' /><br class='clear' /></form>";
	
	
	//Plano Islantilla
	var Mapa3 = new Object();
		 Mapa3.MId="map3";
		 Mapa3.MLat = 37.276445;
 		 Mapa3.MLng = -6.991621;	 
		 Mapa3.MZoom = 15;
	var Punto3 = new Object();
		 Punto3.PLat = -6.991621;
		 Punto3.PLng = 37.276445;
		 Punto3.PIcon = icon;
		 Punto3.PTab1="Avanco";
		 Punto3.PTab2="C\u00F3mo llegar";
		 Punto3.PTab1Info="<p class='pGoogle'>Glorieta Isla Bacuta, Local n-8<br />Edificio Coral Centro<br />21120 Nuevo Corrales-Aljaraque (Huelva)<br />Tel&eacute;fono: 959 48 60 97 </p><br />";
		 Punto3.PTab2Info="<p class='pGoogle'>Ej.:  Calle Tajonar, Pamplona</p><form action='http://maps.google.es/maps' method='get' target='_blank'><input type='text' name='saddr' id='saddr' class='inpuGoogle' style='width:150px;padding:0;' /><input type='submit' class='botonGoogle' style='width:70px;' value='Enviar' /><input type='hidden' name='daddr' id='daddr' value='37.21288,-7.24470' style='display:none;' /><br class='clear' /></form>";
		 		 
	//Plano vera
	var Mapa4 = new Object();
		 Mapa4.MId="map4";
		 Mapa4.MLat = 37.202535;
 		 Mapa4.MLng = -1.893039;	 
		 Mapa4.MZoom = 15;
	var Punto4 = new Object();
		 Punto4.PLat = -1.893039;
		 Punto4.PLng = 37.201555;
		 Punto4.PIcon = icon;
		 Punto4.PTab1="Avanco";
		 Punto4.PTab2="C\u00F3mo llegar";
		 Punto4.PTab1Info="<p class='pGoogle'>Urb. Valle del Este<br />Centro Comercial local 24<br /> 04620 Vera (Almer&iacutea) <br />Tel&eacute;fono: 950 61 70 44 </p><br />";
		 Punto4.PTab2Info="<p class='pGoogle'>Ej.:  Calle Tajonar, Pamplona</p><form action='http://maps.google.es/maps' method='get' target='_blank'><input type='text' name='saddr' id='saddr' class='inpuGoogle' style='width:150px;padding:0;' /><input type='submit' class='botonGoogle' style='width:70px;' value='Enviar' /><input type='hidden' name='daddr' id='daddr' value='37.21288,-7.24470' style='display:none;' /><br class='clear' /></form>";
		 
    //Plano Malaga
	var Mapa5 = new Object();
		 Mapa5.MId="map5";
		 Mapa5.MLat = 36.715477;
 		 Mapa5.MLng = -4.424744;	 
		 Mapa5.MZoom = 15;
	var Punto5 = new Object();
		 Punto5.PLat = -4.424744;
		 Punto5.PLng = 36.715477;
		 Punto5.PIcon = icon;
		 Punto5.PTab1="Avanco";
		 Punto5.PTab2="C\u00F3mo llegar";
		 Punto5.PTab1Info="<p class='pGoogle'>Alameda de Col&oacute;n n&deg;9 1&deg;-3<br />29001 M&aacute;laga<br />Tel&eacute;fono: 952 60 39 80</p><br />";
		 Punto5.PTab2Info="<p class='pGoogle'>Ej.:  Calle Tajonar, Pamplona</p><form action='http://maps.google.es/maps' method='get' target='_blank'><input type='text' name='saddr' id='saddr' class='inpuGoogle' style='width:150px;padding:0;' /><input type='submit' class='botonGoogle' style='width:70px;' value='Enviar' /><input type='hidden' name='daddr' id='daddr' value='36.715477,-4.424744' style='display:none;' /><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, numero_punto){
	// Emplazar marcadores
	if(numero_punto==1){
		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);
						 });
	}
	
	if(numero_punto==2){
		point1 = new GPoint(Punto.PLat,Punto.PLng);
		marker1 = new GMarker(point1, Punto.PIcon);
		map.addOverlay(marker1);
		GEvent.addListener(marker1, "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)
							];
							marker1.openInfoWindowTabsHtml(infoTabs);
						 });
	}
	
	if(numero_punto==3){
		point2 = new GPoint(Punto.PLat,Punto.PLng);
		marker2 = new GMarker(point2, Punto.PIcon);
		map.addOverlay(marker2);
		GEvent.addListener(marker2, "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)
							];
							marker2.openInfoWindowTabsHtml(infoTabs);
						 });
	}
	
	if(numero_punto==4){
		point3 = new GPoint(Punto.PLat,Punto.PLng);
		marker3 = new GMarker(point3, Punto.PIcon);
		map.addOverlay(marker3);
		GEvent.addListener(marker3, "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)
							];
							marker3.openInfoWindowTabsHtml(infoTabs);
						 });
	}
	if(numero_punto==5){
		point4 = new GPoint(Punto.PLat,Punto.PLng);
		marker4 = new GMarker(point4, Punto.PIcon);
		map.addOverlay(marker4);
		GEvent.addListener(marker4, "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)
							];
							marker4.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);
}
