
	/* Contantes de las posiciones de la información dentro del array de hoteles */
	var HOTEL_CODIGO    = 0;
	var HOTEL_NOMBRE    = 1;
	var HOTEL_CATEGORIA = 2;
	var HOTEL_PAIS      = 3;
	var HOTEL_CIUDAD    = 4;
	var HOTEL_DIRECCION = 5;
	var HOTEL_LATITUD   = 6;
	var HOTEL_LONGITUD  = 7;
	var HOTEL_MARCA     = 8;
	var HOTEL_PRECIO    = 9;
	var HOTEL_MONEDA    = 10;
	var HOTEL_MARCADOR	= 11;
	var HOTEL_URL   	= 12;
	var HOTEL_IMG   	= 13;
	var HOTEL_DISP      = 14;


		
	/* Valores para el mapa */
	var existenGeocodes       = false;   // False si no existe ningun hotel con geocodes en la busqueda
	var centroLatitud         = 39.57;   // Por defecto. Palma de Mallorca. Si aparece ha habido un error.
	var centroLongitud        = 2.65;    // Por defecto. Palma de Mallorca. Si aparece ha habido un error.
	var mapaProfundidad       = 14;      // Profundidad por defecto.
	var mapaAltura            = 0.54;    // Amplitud de altura permitido para la profundidad por defecto
	var mapaAnchura           = 0.30;    // Amplitud de altura permitido para la profundidad por defecto
	var mapaUmbral            = 0.01;    // Umbral minimo para la amplitud de la altura o anchura
	var mapaProfundidadMaxima = 14;      // Profundidad maxima permitida
	var mapaProfundidadMinima = 5;
	
	/* Devuelve el texto que se mostrara dentro de la ventana de información de cada marcador */
	function formatearContenido(indice) {
		var texto = new String();
		texto     = "<span class='v_333333_10n'>";
		if (!contenedorHoteles[indice][HOTEL_URL]==''){
			texto    += "<b><a class=\"v_333333_10bu\" target=\"blank\" href=\""+contenedorHoteles[indice][HOTEL_URL]+"\">"+contenedorHoteles[indice][HOTEL_NOMBRE]+"</a></b>";
		}else{
			texto    += "<b>"+contenedorHoteles[indice][HOTEL_NOMBRE]+"</b>";
		}
		
		texto    += " "+contenedorHoteles[indice][HOTEL_CATEGORIA];
		texto    += "<br>"+contenedorHoteles[indice][HOTEL_DIRECCION];
		texto    += "<br>"+contenedorHoteles[indice][HOTEL_CIUDAD];
		texto    += "<br>"+contenedorHoteles[indice][HOTEL_PAIS];
		
	
		if (fechas){
			if (contenedorHoteles[indice][HOTEL_DISP]=="Y"){
				if (contenedorHoteles[indice][HOTEL_PRECIO]!= null && contenedorHoteles[indice][HOTEL_PRECIO]!=""){
					texto    += "<br><img src=\"../../img/fle_gui/res_bullet_grisosc.gif\" border=\"0\"/>&nbsp;<a class=\"v_333333_10bu\" href=\"javascript:enviar('"+contenedorHoteles[indice][HOTEL_CODIGO]+"');\">"+ precio_desde + "&nbsp;" + contenedorHoteles[indice][HOTEL_PRECIO] + "&nbsp;" + contenedorHoteles[indice][HOTEL_MONEDA] + "</a>";
				}
			}else{
				texto    += "<br>" + sin_disp;	
			}
		}else{
			if (contenedorHoteles[indice][HOTEL_PRECIO]!= null && contenedorHoteles[indice][HOTEL_PRECIO]!=""){
				texto    += "<br><img src=\"../../img/fle_gui/res_bullet_grisosc.gif\" border=\"0\"/>&nbsp;"+ precio_desde + "&nbsp;" + contenedorHoteles[indice][HOTEL_PRECIO] + "&nbsp;" + contenedorHoteles[indice][HOTEL_MONEDA];
			}
		}
	
		
		texto    += "<br><img src=\""+contenedorHoteles[indice][HOTEL_IMG]+"\" border=\"0\" style=\"margin-top:5px;\"/>";
		texto    += "</span>";
		return texto;
	}

	/* 
	Crea un marcador para un hotel.
	La imagen depende de la marca del hotel
	Se añaden los eventos relaciones con el marcador.
	*/
	function crearMarcador(map, geocode, indice, icono) {
	
		/* Icono */
        	icono.image  = pathIconos+"sm_icono_"+contenedorHoteles[indice][HOTEL_MARCA]+".png";
		var marcador = new GMarker(geocode, icono);
		
		/* Eventos */
		GEvent.addListener(marcador, "click", function() {
			marcador.openInfoWindowHtml(formatearContenido(indice));
		});
		GEvent.addListener(marcador, "infowindowclose", function() {
			map.closeInfoWindow();
		});
		
		return marcador;
	}
	
			
	/* Carga el mapa si el navegador es compatible */
	var map;
	google.load("maps", "2.119a");
	
	function load(tipo) {
		
		var profundidad = "";
		map = new google.maps.Map2(document.getElementById("map"));
			
		   // ===== Start with an empty GLatLngBounds object =====     
		var bounds = new google.maps.LatLngBounds();
		map.setCenter(new google.maps.LatLng(0,0),0);
		existenGeocodes = false;
				
		//map.setCenter(new GLatLng(39.57, 2.65), 15);
			
		// Obtenemos el tipo de mapa que queremos mostrar
		if (tipo == "NORMAL") map.setMapType(G_NORMAL_MAP);
		if (tipo == "SATELITE") map.setMapType(G_SATELLITE_MAP);
		if (tipo == "HIBRIDO") map.setMapType(G_HYBRID_MAP);
			
		/* Icono base para las imagenes de los marcadores */
		var icono              = new google.maps.Icon();
		icono.iconSize         = new google.maps.Size(24, 24);
		icono.shadowSize       = new google.maps.Size(0, 0);
		icono.iconAnchor       = new google.maps.Point(12, 12);
		icono.infoWindowAnchor = new google.maps.Point(18, -10);
			
		/* Carga de los marcadores e infos de los hoteles */
		for (var i=0; i<contenedorHoteles.length; i++) {
			if (contenedorHoteles[i][HOTEL_LATITUD]!="" && contenedorHoteles[i][HOTEL_LONGITUD]!="") {
				var geocode  = new google.maps.LatLng(contenedorHoteles[i][HOTEL_LATITUD],contenedorHoteles[i][HOTEL_LONGITUD]);
				var marcador = crearMarcador(map, geocode, i, icono);
				contenedorHoteles[i][HOTEL_MARCADOR]=marcador;
				map.addOverlay(marcador);
				bounds.extend(geocode);
			}
		}
		var zoom;
		var zoomMax;
		// ===== determine the zoom level from the bounds =====
		if (contenedorHoteles.length>1) // Si hay más de un hotel fuerza el zoom para que no se queden los hoteles en los bordes del mapa
		{
			zoom=map.getBoundsZoomLevel(bounds)-1;
		}
		else
		{
			zoom=map.getBoundsZoomLevel(bounds);
		}
		var latitude = bounds.getCenter().lat();
		var longitude = bounds.getCenter().lng();
		var maps = map.getMapTypes();
		if (excluido){
			for (var i = 0; i<maps.length; i++){
				maps[i].getMaximumResolution = function() {return 8;}
				//maps[i].getMinimumResolution = function() {return 7;}
			}
		}
		map.setZoom(zoom);
		mapaProfundidad =map.getBoundsZoomLevel(bounds);
		// ===== determine the centre from the bounds ======
		map.setCenter(bounds.getCenter());
		geoCodeCenter=bounds.getCenter();
		
		/* Añadimos los controles al mapa */
		map.addControl(new GCentrarHotelControl(centrar_mapa,bounds.getCenter(),map.getBoundsZoomLevel(bounds)));
		map.addControl(new google.maps.LargeMapControl());
		map.addControl(new google.maps.MapTypeControl());	
	}
	/* VISUALIZACION DEL MAPA */
	
	/* Estado de visualizacion del mapa */
	var visualizacionMapa = false;
	
	/* Controla el estado de visualizacion del mapa */
	function estadoVisualizacionMapa() {
		if (visualizacionMapa) {
			mostrarMapa();
		} else {
			ocultarMapa();
		}
		visualizacionMapa = !visualizacionMapa;
	}
	
	/* Oculta el mapa en el navegador */
	function ocultarMapa() {
		document.getElementById("map").style.visibility = "hidden";
		document.getElementById("map").style.height     = 0;
		document.getElementById("map").style.width      = 0;
		// mostrar_mapa declarado fuera
		document.getElementById("estadoVisualizacionMapa").innerHTML = mostrar_mapa;
	}

	/* Muestra el mapa (oculto) en el navegador */
	function mostrarMapa() {
		document.getElementById("map").style.visibility = "visible";
		document.getElementById("map").style.height     = "300px";
		document.getElementById("map").style.width      = "593px";
		// ocultar_mapa declarado fuera
		document.getElementById("estadoVisualizacionMapa").innerHTML = ocultar_mapa;
	}
	
	/* AL CAMBIAR O CERRAR LA PAGINA */
	
