// función Showaddress Javascript que muestra el mapa clásico de google
//<![CDATA[

    var map = null;
    var geocoder = null;

    function showAddress(address,description) {
	   var map = new GMap2(document.getElementById("map"));

        map.enableDoubleClickZoom();
		map.addControl(new GSmallMapControl());
        geocoder = new GClientGeocoder();

      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              
            } else {
              map.setCenter(point, 15,G_NORMAL_MAP);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(description);
            }
          }
        );
      }
	  
    }
//]]>

// función MostrarMapa Javascript que muestra el mapa de google mas como llegar

//<![CDATA[

var map;
var gdir;
var geocoder = null;
var addressMarker;

function MostrarMapa(direccion,descripcion,desde,idioma,elemento1,elemento2) {

  if (GBrowserIsCompatible()) {      

	   var map = new GMap2(document.getElementById(elemento1));

		map.enableDoubleClickZoom();
		map.addControl(new GSmallMapControl());
		geocoder = new GClientGeocoder();

  if (desde=='')
  
	{      

	  if (geocoder) {
		geocoder.getLatLng(
		  direccion,
		  function(point) {
			if (!point) {
			  
			} else {
			  map.setCenter(point, 15,G_NORMAL_MAP);
			  var marker = new GMarker(point);
			  map.addOverlay(marker);
			  marker.openInfoWindowHtml(descripcion);
			}
		  }
		);
	  }
	
	}
	
	else
	
	{

		gdir = new GDirections(map, document.getElementById('route_larratxo'));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
		GEvent.addListener(gdir, "error", handleErrors);

		setDirections(desde, direccion, idioma);
		
	}
  }
}

function setDirections(fromAddress, toAddress, locale) {
  gdir.load("from: " + fromAddress + " to: " + toAddress,
			{ "locale": locale });
  document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
}

function handleErrors(){
   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	 alert("No se ha podido encontrar la dirección indicada.");
   else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
	 alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
   
   else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
	 alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);

//   else if (gdir.getStatus().code == G_UNAVAILABLE_ADDRESS)  <--- Doc bug... this is either not defined, or Doc is wrong
//     alert("The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: " + gdir.getStatus().code);
	 
   else if (gdir.getStatus().code == G_GEO_BAD_KEY)
	 alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);

   else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
	 alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	
   else alert("Ha ocurrido un error desconocido. Sentimos las molestias");
   
}

function onGDirectionsLoad(){ 
	  // Use this function to access information about the latest load()
	  // results.

	  // e.g.
  // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
  // and yada yada yada...
}


//]]>
function Abrir_Ventana(url,nombre,opciones) {
window.open(url,nombre,opciones);
}

function window_new(url,descripcion,ancho,alto,barras,clase,tecla)
{
var opciones="top=0,left=0,toolbar=no,location=no,status=no,menubar=no,scrollbars=" + barras + ",resizable=no,width=" + ancho + ",height=" + alto
document.write("<a class=" + clase + " accesskey=" + tecla + " title=" + descripcion + " id=" + descripcion + " href=javascript:Abrir_Ventana('" + url + "','','" + opciones + "')>" + descripcion + "</a>");
}

function actualidad_galerias_SeleccionarImagen(imagen){ 

document.ImgPrincipal.src='Jpeg.asp?Imagen=' + imagen + '&Ancho=370';
self.scroll(1,document.ImgPrincipal.offsetTop);

}
