//Autolocalización de la calle usando google maps
// ====== Create a Client Geocoder ======
var geo = new GClientGeocoder(); 

// ====== Array for decoding the failure codes ======
function getAddress(search) {
geo.getLocations(search, function (result) { 
	// If that was successful
	if (result.Status.code == G_GEO_SUCCESS) {
		var p = result.Placemark[0].Point.coordinates;
		document.all.LAT.value=p[1];
		document.all.LNG.value=p[0];
		document.FormularioDist.submit();
	} else {
		alert('Lugar no localizado especifiquelo mas');
	}
  }
)
}
function BuscarDist(){
	if (isNaN(document.all.TxtDistancia.value)||document.all.TxtDistancia.value==''){
		alert('Introduzca una distancia maxima valida');
		return;
	}
	var Aux = document.all.TxtLugar.value+' Espa&ntilde;a';
	//alert(Aux);
	getAddress(Aux);
}

function getAddress2(search) {
geo.getLocations(search, function (result) { 
	// If that was successful
	if (result.Status.code == G_GEO_SUCCESS) {
		var p = result.Placemark[0].Point.coordinates;
		document.all.LAT.value=p[1];
		document.all.LNG.value=p[0];
		document.Formulario.submit();
	} else {
		alert('Lugar no localizado especifiquelo mas');
	}
  }
)
}

// ====== ======================== ======
var Icono1 = new GIcon();
Icono1.image = "img/pin3.gif";
Icono1.iconSize = new GSize(20, 22);
Icono1.iconAnchor = new GPoint(20, 22);
Icono1.infoWindowAnchor = new GPoint(20, 22);
var Icono2 = new GIcon();
Icono2.image = "img/pin.gif";
Icono2.iconSize = new GSize(22, 36);
Icono2.iconAnchor = new GPoint(22, 36);
Icono2.infoWindowAnchor = new GPoint(22, 36);

function loadMapa() {
if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.enableScrollWheelZoom();
	
	map.setCenter(new GLatLng(CentroLAT,CentroLNG), Zoom);
	}
}
function createInfo(point, icon, html) {
var marker = new GMarker(point, icon);
GEvent.addListener(marker, "click", function() {
  marker.openInfoWindowHtml(html);
});
map.addOverlay(marker);
}