	var CentroLat="";
	var CentroLon="";
	var LevelZoominicial="";
	var centreLat="";
	var centreLon="";
	var initialZoomLevel="";
	var Mapa="";
	var minLat="";
	var minLon="";
	var maxLat="";
	var maxLon="";
	var mapBounds="";
	var maxZoom="";
	var tiledir="";    
	var map; 
	var opacity=1;
	var position_marker = null;
	var poly;
	var count = 0;
	var points = new Array();	
	var markers = new Array();    
	var lineMode = 1;	
	var Evento = "";
	var Evento1 = "";   
	var LimpiaMapa = 1;	
	var Modo=1;
	var Xinforma="";	
	var Yinforma="";
	var posmsg ="";
	var AnchoBalonGE="";
	var AltoBalonGE="";
	var SesionData= 0;
	var Xpuntos=new Array();	
	var Ypuntos=new Array();
	var ventanaover=true;
	var overview;
	var mapa_overview;
	var Leyenda_fullscreen=false;
	var GEarth=false;
	var ge;
	var GEvias=true;
	var Superurl="";
	var Superurltransp="";
	var GE_Infowindow=false; 
	var WMSactivo=false;
	var XMLactivo=false;
	var PANOactivo=false;
	var WMScontrol=null;
	var XmlControl=null;
	var PANOcontrol=null;
	WMS_URL="http://www.idee.es/wms/IDEE-Base/IDEE-Base?";
	WMS_Layers="Hidrografia,bcn_hidrografia_et";
	WMS_Format="image/png";
	WMS_Style="default,default";
	WMS_Version="1.1.1";
	WMS_Transparent="TRUE";
	WMS_Opacity=1;    
	var Xmlurl="http://pepeyola.googlepages.com/provincias.kml";
	var PANOurl="http://pepeyola.googlepages.com/Panoramio.kml"; //cambiar el hospedaje de los archivos de Panoramio y Picassa hacia mi hosting, y poner directametne la url en las funciones, es decir, eliminar las variables
	
	//Función para cambiar la transparencia del mapa
	function changeOpacity(op) {
		var current=map.getCurrentMapType();        
		if (current==map.getMapTypes()[0]) {map.setMapType(G_SATELLITE_MAP);}
		if (current==map.getMapTypes()[1]) {map.setMapType(G_SATELLITE_MAP);} 
		if (current==map.getMapTypes()[2]) {map.setMapType(G_NORMAL_MAP);}
		if (current==map.getMapTypes()[3]) {map.setMapType(G_PHYSICAL_MAP);}  
		opacity=op;
		map.setMapType(current);
	}
	
	//Función para leer los valores de las varibles de la sesion previa
	function leesesion() { 
		var Mapatempo=sessvars.Tipodemapa;
		var centreLattempo=sessvars.Latitudcentral;  
		var centreLontempo=sessvars.Longitudcentral;  
		var initialZoomLeveltempo=sessvars.Zoominicial;  
		var Modotempo=sessvars.ModoNavega;
		var Xinformatempo=sessvars.InformaX;
		var Yinformatempo=sessvars.InformaY;
		var Opacitytempo=sessvars.Opacidad;
		var Contadortempo=sessvars.Contador;
		var XPuntostempo=new Array();
		var YPuntostempo=new Array();
		for (var i=0 ; i< Contadortempo; i++) {
			XPuntostempo[i]=sessvars.XPuntos[i];
			YPuntostempo[i]=sessvars.YPuntos[i];
		}
		var Modolineatempo=sessvars.Modolinea;
		var EsTresDtempo=sessvars.ESTreD;
		var ventanaovertempo=sessvars.overmapa;
		var PANOtempo=sessvars.PANO;
		var XMLtempo=sessvars.XML;
		var Xmlurltempo=sessvars.Xmlurl;        
		var WMSactivotempo=sessvars.WMS;
		var WMS_URLtempo=sessvars.WMSURL;
		var WMS_Layerstempo=sessvars.WMSLayers;
		var WMS_Formattempo=sessvars.WMSFormat;
		var WMS_Styletempo=sessvars.WMSStyle;
		var WMS_Versiontempo=sessvars.WMSVersion;
		var WMS_Transparenttempo=sessvars.WMSTransparent;
		var WMS_Opacitytempo=sessvars.WMSOpacity; 
		if (centreLattempo != undefined) {
			centreLat=centreLattempo;
			centreLon=centreLontempo;
			initialZoomLevel=initialZoomLeveltempo;
			Mapa=Mapatempo;
			Modo=Modotempo;
			Xinforma=Xinformatempo;	
			Yinforma=Yinformatempo;
			opacity=Opacitytempo;
			var Event = YAHOO.util.Event, 
			Dom  = YAHOO.util.Dom, 
			slider,  
			bg="slider-bg",
			thumb="slider-thumb";       
			var topConstraint = 0;
			var bottomConstraint = 136;
			var scaleFactor = 0.73529411764705882352941176470588;
			Event.onDOMReady(function() {
				slider = YAHOO.widget.Slider.getHorizSlider(bg,thumb, topConstraint, bottomConstraint, 1);
				slider.setValue(((1-opacity)*100/scaleFactor), true);
				slider.getRealValue = function() {return Math.round(this.getValue() * scaleFactor);};
				slider.subscribe("slideEnd", function() {            
					var actualValue = slider.getRealValue();
					var transparencia = 1-(actualValue/100);
					Dom.get(bg).title = "Transparencia: " + actualValue +"%";	
					changeOpacity(transparencia);
				});
				Event.on("boton_menos", "click", function() {
				    var actualValue = slider.getRealValue();
				    if (actualValue > 0) {
					actualValue = actualValue - 5;
					if (actualValue < 0) {actualValue=0;}
					slider.setValue((actualValue/scaleFactor), false); //false here means to animate if possible
				    }
			        });
                                Event.on("boton_mas", "click", function() {
				    var actualValue = slider.getRealValue();
				    if (actualValue < 100) {
					actualValue = actualValue + 5;
					if (actualValue > 100) {actualValue=100;}
					slider.setValue((actualValue/scaleFactor), false); //false here means to animate if possible
				    }
			        });
			});
			count=Contadortempo;
			for (var ii=0 ; ii< count; ii++) {
				Xpuntos[ii]=XPuntostempo[ii];
				Ypuntos[ii]=YPuntostempo[ii];
			}
			lineMode=Modolineatempo;
			GEarth=EsTresDtempo;
			ventanaover=ventanaovertempo;
			PANOactivo=PANOtempo;
			XMLactivo=XMLtempo;
			Xmlurl=Xmlurltempo;
			WMSactivo=WMSactivotempo;
			WMS_URL=WMS_URLtempo;
			WMS_Layers=WMS_Layerstempo;
			WMS_Format=WMS_Formattempo;
			WMS_Style=WMS_Styletempo;
			WMS_Version=WMS_Versiontempo;
			WMS_Transparent=WMS_Transparenttempo;
			WMS_Opacity=WMS_Opacitytempo;
		}
	}   

	//Función para escoger las imagenes del mapa
	function customGetTileURL(a,b) {
		var imagenblanco= "http://tilq.siesa.info/"+tiledir+"/blank-tile.png";
		if (b>maxZoom) {
			document.getElementById("zoout").innerHTML="Se ha superado el nivel de zoom máximo&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;admitido para visualizar este mapa temático&nbsp;";
			return imagenblanco;}
		else {document.getElementById("zoout").innerHTML="";}
		var c=Math.pow(2,b);
		var x=360/c*a.x-180;
		var y=180-360/c*a.y;
		var x2=x+360/c;
		var y2=y-360/c;
		var lon=x; //Math.toRadians(x); //would be lon=x+lon0, but lon0=0 degrees
		var lat=(2.0*Math.atan(Math.exp(y/180*Math.PI))-Math.PI/2.0)*180/Math.PI; //in degrees
		var lon2=x2;
		var lat2=(2.0*Math.atan(Math.exp(y2/180*Math.PI))-Math.PI/2.0)*180/Math.PI; //in degrees
		var tileBounds=new GLatLngBounds(new GLatLng(lat2,lon),new GLatLng(lat,lon2));
		if (!tileBounds.intersects(mapBounds)) {return imagenblanco;}
		var d=a.x;
		var e=a.y;
		var f="t";
		var ultimaletra="t"; //ultimaletra identifica el archivo por su ultima letra para ser almacenados en diferentes subdominios
		for(var g=0;g<b;g++){
			c=c/2;
			if(e<c){
				if(d<c){f+="q";ultimaletra="q";}                    
				else{f+="r";d-=c;ultimaletra="r";}  
			}
			else{
				if(d<c){f+="t";e-=c;ultimaletra="t";}
				else{f+="s";d-=c;e-=c;ultimaletra="s";}
			}
		}
		var imagen= "http://til"+ultimaletra+".siesa.info/"+tiledir+"/"+f+".png";
		return imagen;       
	}

	//Funcione para leer el WMS
	function WMSCustomGetTileUrl(a,b,c) {
		var lULP = new GPoint(a.x*256,(a.y+1)*256);
		var lLRP = new GPoint((a.x+1)*256,a.y*256);
		var lUL = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lULP,b,c);
		var lLR = G_NORMAL_MAP.getProjection().fromPixelToLatLng(lLRP,b,c);
		var west = lUL.x;
		var east = lLR.x;
		var north = lUL.y;
		var south = lLR.y;
		var lURL=this.myBaseURL;                   
		if (map.getZoom() < 6) { 
			if (map.getZoom() > 3) {
				if (map.getZoom() == 4) {
					north=lUL.y+0.3;
					south=lLR.y+0.3;}
				if (map.getZoom() == 5) {
					north=lUL.y+0.1;
					south=lLR.y+0.1;}	               
			} else {
				lURL="";  
				return lURL;
			}
		}        
		var sud = south; 
		if(north < south){south = north; north = sud;}	
		var lBbox=west+","+south+","+east+","+north;        
		if (this.myFormat == undefined) {this.myFormat = "image/png";}
		if (this.myStyles == undefined) {this.myStyles="";}
		if (this.myVersion == undefined) {this.myVersion = "1.1.1";} 
		var lSRS="EPSG:4326"; //Esto solo vale para este SRS
		if (this.myVersion != "1.0.0") {lURL+="&REQUEST=GetMap";} else {lURL+="&REQUEST=Map";} 
		lURL+="&SERVICE=WMS";
		lURL+="&VERSION="+this.myVersion;
		lURL+="&LAYERS="+this.myLayers;
		lURL+="&STYLES="+this.myStyles;
		lURL+="&FORMAT="+this.myFormat;
		lURL+="&BGCOLOR=0xFFFFFF"; 
		lURL+="&TRANSPARENT="+this.myTransparent; 
		lURL+="&SRS="+lSRS;
		lURL+="&BBOX="+lBbox;
		lURL+="&WIDTH=256";        
		lURL+="&HEIGHT=256";
		return lURL;
	}
	
	//Función para el slider bar de la transparencia
	(function() {
		var Event = YAHOO.util.Event, 
		Dom  = YAHOO.util.Dom, 
		slider,  
		bg="slider-bg",
		thumb="slider-thumb";       

		// The slider can move 0 pixels up
		var topConstraint = 0;
		// The slider can move 136 pixels down
		var bottomConstraint = 136;
		// Custom scale factor for converting the pixel offset into a real value
		var scaleFactor = 0.73529411764705882352941176470588;
		
		Event.onDOMReady(function() {
			slider = YAHOO.widget.Slider.getHorizSlider(bg, 
			thumb, topConstraint, bottomConstraint, 1);
			
			slider.getRealValue = function() {
				return Math.round(this.getValue() * scaleFactor);
			};

			slider.subscribe("slideEnd", function() {            
				var actualValue = slider.getRealValue();
				// Update the title attribute on the background.  This helps assistive
				// technology to communicate the state change
				var transparencia = 1-(actualValue/100);
				Dom.get(bg).title = "Transparencia: " + actualValue +"%";	
				changeOpacity(transparencia);
			});
			
			// Reducir transparencia con el boton menos
			Event.on("boton_menos", "click", function() {
				var actualValue = slider.getRealValue();
				if (actualValue > 0) {
					actualValue = actualValue - 5;
					if (actualValue < 0) {actualValue=0;}
					slider.setValue((actualValue/scaleFactor), false); //false here means to animate if possible
				}
			});

			// Aumentar transparencia con el boton mas
			Event.on("boton_mas", "click", function() {
				var actualValue = slider.getRealValue();
				if (actualValue < 100) {
					actualValue = actualValue + 5;
					if (actualValue > 100) {actualValue=100;}
					slider.setValue((actualValue/scaleFactor), false); //false here means to animate if possible
				}
			});
		});	
	})();
	
	//Función para convertir de decimal a grados
	function decimal_grad(coordenada) {
		var msg = coordenada.toString().replace(/\..*/,"");
		var tmp = parseFloat("."+coordenada.toString().replace(/.*\./,""));
		tmp = tmp*60; 
		msg += "&#176;&nbsp;" + tmp.toString().replace(/\..*/,"") + "\'&nbsp;";
		tmp = parseFloat("."+tmp.toString().replace(/.*\./,""));
		tmp = tmp*60; 
		msg += tmp.toString().replace(/\..*/,"") + "\"";
		return 	msg;
	} 

	//Función para actualizar las coordenadas del mapa 
	function zmouse_move(point){
		var posmsg="";
		posmsg=decimal_grad(point.lat());
		posmsg += "/";
		posmsg+=decimal_grad(point.lng());
		document.getElementById("coords1").innerHTML="Lat/Lon: "+posmsg; 
	}    

	//Función ficticia solo para genenar un valor inicial de un Evento
	function nada() {}
	
	//Función para activar/desactivar los botones de cambio de modo del GIS
	function select(buttonId) {
		document.getElementById("hand_b").className="unselected";
		document.getElementById("centrar").className="unselected";
		document.getElementById("shape_b").className="unselected";
		document.getElementById("line_b").className="unselected";
		document.getElementById("placemark_b").className="unselected";
		document.getElementById(buttonId).className="selected";
	}

	//Función para dibujar las lineas o poligonos en los modos de medicion
	function drawOverlay(){
		var lineColor = "#0000af";
		var fillColor = "#335599";	
		var lineWeight = 3;
		var lineOpacity = 0.7;
		var fillOpacity = 0.3;                 
		
		if(poly) {map.removeOverlay(poly);}
		points.length = 0;
		for(i = 0; i < markers.length; i++) {
			points.push(markers[i].getLatLng());
		}
		document.getElementById("status").style.display='inline';   	
		if (lineMode==1) {
			// Polyline mode
			poly = new GPolyline(points, lineColor, lineWeight, lineOpacity);
			var length = poly.getLength();
			var longitud = length/1000; 
			document.getElementById("status").innerHTML = "&nbsp;Longitud Total: " + longitud.toFixed(2) + " km&nbsp;" + "/ " + length.toFixed(2)+" m&nbsp;";
		}
		else {
			// Polygon mode
			points.push(markers[0].getLatLng());
			poly = new GPolygon(points, lineColor, lineWeight, lineOpacity, fillColor, fillOpacity);
			var area = poly.getArea()/10000;
			var superficie = poly.getArea()/(1000*1000);
			document.getElementById("status").innerHTML = "&nbsp;Area Total: " + superficie.toFixed(2) + " km&sup2;&nbsp;"+ "/ " + area.toFixed(2)+" ha&nbsp;";
		}
		map.addOverlay(poly);
	}	
	
	//Función para actuar cuando se hace clic en modo de medicion de distancia y area
	function leftClick(overlay, point) {
		if(point) {
			count++;
			var icon = new GIcon();
			icon.image = "vertice_icon.png";
			icon.shadow= "vertice_shadow.png";
			icon.iconSize = new GSize(11.0, 11.0);
			icon.shadowSize = new GSize(17.0, 11.0);
			icon.iconAnchor = new GPoint(5.0, 5.0);
			
			// Make markers draggable
			var marker = new GMarker(point, {icon:icon, draggable:true, bouncy:true, dragCrossMove:true, title: "Clic para eliminar vértice/Arrastra para desplazar vértice"});
			map.addOverlay(marker);
			marker.content = count;
			markers.push(marker);
			
			// Drag listener
			GEvent.addListener(marker, "drag", function() {
				drawOverlay();
			});

			// Second click listener
			GEvent.addListener(marker, "click", function() {
				// Find out which marker to remove
				for(var n = 0; n < markers.length; n++) {
					if(markers[n] == marker) {
						map.removeOverlay(markers[n]);
						break;
					}
				}
				// Shorten array of markers and adjust counter
				markers.splice(n, 1);
				if(markers.length == 0) {count = 0;}
				else {
					count=count-1; //Esto no estaba originalmente, pero la linea de abajo cascó y esto funciona bien
					//count = markers[markers.length-1].content; esto es lo que estaba antes pero cascó y lo cambié por el contador
					drawOverlay();     					
				}
			});
			drawOverlay();			
		}
	}


	//Función para actualizar las polilineas al cambiar el modo de medicion
	function toggleMode() {
		if(markers.length > 1) {drawOverlay();}
	}
	
	//Función para centrar la vista actual del mapa.
	function centrarvista(marker, point) {
		var custom_icon = new GIcon();
		custom_icon.image = "centro_icon.png";
		custom_icon.iconSize = new GSize(32, 32);
		custom_icon.iconAnchor = new GPoint(16, 16);  
		var mappan = true;             	 
		
		if (position_marker != null) {map.removeOverlay(position_marker);}
		if (SesionData==1) {
			point = new GLatLng(Xinforma, Yinforma);
			SesionData=0;
			mappan= false;
		}
		position_marker = new GMarker(point,{icon:custom_icon, title: "Clic para eliminar marca"});
		map.addOverlay(position_marker);
		Xinforma=point.lat();
		Yinforma=point.lng();
		if (mappan) {map.panTo(point);}
	} 


	//Funcion para borrar las lineas y poligonos al salir de los modos de medicion
	function clearMap() {
		if (position_marker!=null) {
			map.removeOverlay(position_marker);
			position_marker=null;}
		if (poly!=null) {
			map.removeOverlay(poly);
			poly=null;}
		if (markers!=null) {
			for(var pt = 0; pt < markers.length; pt++) {
				map.removeOverlay(markers[pt]);
				markers[pt]=null;}                        
		}			
		points.length = 0;
		markers.length = 0;
		count = 0;
		document.getElementById("status").style.display='none';		
	}

	//Función que se activa cuando se pulsa los botones de los modos de medicion
	function linepoly(mode) {
		GEvent.removeListener(Evento);
		Evento=GEvent.addListener(map, "click", leftClick);
		map.getDragObject().setDraggableCursor("crosshair");
		map.disableDoubleClickZoom();
		if (LimpiaMapa==1) {clearMap();}
		if (mode==1) {select("line_b");}
		else {select("shape_b");}
		lineMode = mode;
		LimpiaMapa=0;
		toggleMode();
		Modo=3;
	}

	//Función que se activa cuando se pulsa el boton de modo de consulta
	function placeMarker() {
		GEvent.removeListener(Evento);
		Evento=GEvent.addListener(map, "click", printdata);
		map.getDragObject().setDraggableCursor("help");
		map.disableDoubleClickZoom();
		select("placemark_b");
		LimpiaMapa=1;
		clearMap();
		Modo=2;
		if (SesionData==0) {
			Xinforma="";	
			Yinforma="";
		}
	}

	//Función que se activa cuando se pulsa el boton de modo centrado de vista
	function centradovista() {
		GEvent.removeListener(Evento);
		Evento=GEvent.addListener(map, "click", centrarvista);
		map.getDragObject().setDraggableCursor("crosshair");
		map.disableDoubleClickZoom();
		select("centrar");
		LimpiaMapa=1;
		clearMap();
		Modo=4;
		if (SesionData==0) {
			Xinforma="";	
			Yinforma="";
		}		
	}

	//Función que se activa cuando se pulsa el boton de modo normal predeterminado
	function stopEditing() {
		GEvent.removeListener(Evento);
		map.getDragObject().setDraggableCursor("default");
		map.enableDoubleClickZoom();
		select("hand_b");
		LimpiaMapa=1;   
		clearMap();
		Modo=1;		
	} 
	
	//Funciones que controlan el control Más...
	function desactiva_more() {
		document.getElementById('loading1').style.display='none';
		if (!WMSactivo && !PANOactivo && !XMLactivo) {document.getElementById("morea").className="unselected";}
	}
	
	function WMS(checked){     
		if(checked) {
			try {
				WMSactivo=true;
				document.getElementById("morea").className="selected";
				document.getElementById('loading1').style.display="inline";
				var WMS1= new GTileLayer("",0,17);	
				WMS1.myBaseURL=WMS_URL;
				WMS1.myLayers=WMS_Layers;
				WMS1.myFormat=WMS_Format;
				WMS1.myStyles=WMS_Style;
				WMS1.myVersion=WMS_Version;
				WMS1.myTransparent=WMS_Transparent;
				WMS1.getTileUrl=WMSCustomGetTileUrl; 
				if (WMS1.myFormat=="image/png") {WMS1.isPng=function() {return true;};} else {WMS1.isPng=function() {return false;};}	
				WMS1.getOpacity=function() {return WMS_Opacity;};
				WMScontrol=new GTileLayerOverlay(WMS1);                
				map.addOverlay(WMScontrol);                
				setTimeout(function(){document.getElementById('loading1').style.display='none';},1000);
			} catch (ex) {
				alert('El WMS no se ha ejecutado correctamente');
				WMSactivo=false;
				var opc = document.getElementsByTagName("input");
				opc[1].checked = false; 
				desactiva_more();
				map.removeOverlay(WMScontrol);        
			} 
		}         
		if(!checked) {
			WMSactivo=false; 
			map.removeOverlay(WMScontrol);
			desactiva_more();
		}
	}
	
	function XML(checked){
		if(checked) {
			XMLactivo=true; 
			document.getElementById("morea").className="selected";
			document.getElementById('loading1').style.display="inline";
			XmlControl = new GGeoXml(Xmlurl);                             
			//GGeoXml can add extra properties to the overlays that it creates. They always seem to have description, snippet and name
			//Estas propiedades se pueden utilizar para mostrarlas en un panel al igual que las propiedades del WMS (un boton al lado de la URL para visualizar las propiedades)
			//Ver GM Tutorial para ver como se usan estas propiedades
			var eventillo=GEvent.addListener(XmlControl,'load',function(){
				GEvent.removeListener(eventillo);                          
				var ok=XmlControl.loadedCorrectly();
				document.getElementById('loading1').style.display='none';
				if (!ok) {
					alert("El archivo XML no se ha cargado correctamente, por favor verifique la URL");
					XMLactivo=false;
					var opciones = document.getElementsByTagName("input");
					opciones[2].checked = false;
					desactiva_more();
					map.removeOverlay(XmlControl);                                 
				}
				return;                                                              
			});
			map.addOverlay(XmlControl);          
		}
		if(!checked) {
			XMLactivo=false;
			map.removeOverlay(XmlControl);
			desactiva_more();            
		}
	}
	
	//Función para recuperar lo que habia antes de un clearoverlay
	function recuperasesion() { 
		if (Modo==2) {		
			SesionData=1;
			placeMarker();
			if (Xinforma==""){SesionData=0;} else {printdata();}
		} 
		if (Modo==3) {		
			var Repetir=count;
			for (var i=0 ; i<count; i++) {
				Xpuntos[i]=points[i].lat();
				Ypuntos[i]=points[i].lng();
			}
			points.length = 0;
			markers.length = 0;
			count = 0;                                   	       
			for (var j=0 ; j< Repetir; j++) {
				var puntito = new GLatLng(Xpuntos[j], Ypuntos[j]);
				leftClick("", puntito);	
			}
		}
		if (Modo==4) {		
			SesionData=1;
			centradovista();
			if (Xinforma==""){SesionData=0;} else {centrarvista();}
		}
		if (WMSactivo) {WMS(true);}
		if (XMLactivo) {XML(true);}        
	}   
	
	function PANORAMIO(checked){
		if(checked) {
			PANOactivo=true;
			document.getElementById("morea").className="selected";
			document.getElementById('loading1').style.display="inline";
			PANOcontrol = new GGeoXml(PANOurl);                
			var eventillo1=GEvent.addListener(PANOcontrol,'load',function(){
				GEvent.removeListener(eventillo1); 
				var ok=PANOcontrol.loadedCorrectly();
				document.getElementById('loading1').style.display='none';
				if (!ok) {
					alert("Las fotografías de PANORAMIO no se han cargado correctamente");
					PANOactivo=false;
					var opc = document.getElementsByTagName("input");
					opc[3].checked = false; 
					desactiva_more();
					map.removeOverlay(PANOcontrol);                       
				}
				return;                                       
			});
			map.addOverlay(PANOcontrol);
		}
		if(!checked) {
			PANOactivo=false;
			//map.removeOverlay(PANOcontrol); El removeOverlay no siempre elimina todas las fotos, así que no queda otra que poner un ClearOverlay y reuperar la sesion
			map.clearOverlays();
			recuperasesion();
			desactiva_more();                          
		}
	}
	
	//Para cambiar la apariencia de los controles de navegacion
	function Glarge3DMapControl() {
		var Contador=0;
		var images = map.getContainer().getElementsByTagName("img");
                var hasta=images.length;  
		for(var i=0; i<hasta; i++){ 
		        if (images[i].src=="http://maps.gstatic.com/intl/es_es/mapfiles/mapcontrols2.png") {
				images[i].src = "mapcontrols3d.png";                        
				Contador++;
			}
			if (Contador==4) {break;} 
		}
                if (Contador==4) {
                        document.getElementById('loading1').style.display='none';
			document.getElementById('loading').style.display='none';}
		else {setTimeout("Glarge3DMapControl()",10);}
	}
	
	//Funciones que muestra, esconde y actualiza el mapoverview y desplaza la ventana de coordenadas  
	function mapoverview(velocidad) {
		var d = document.getElementById("coords");
		if (ventanaover) {
			overview.hide(velocidad);
			document.getElementById("botonoverview").className="closed";
			ventanaover=false; 		
			d.style.right = 3+"px";
                } else {
			overview.show(velocidad);
			document.getElementById("botonoverview").className="unselected";
			ventanaover=true;		
			d.style.right = 124+"px";
		}			
	}
	function actualizamapoverview() {
		var current=map.getCurrentMapType();        
		if (current==map.getMapTypes()[0]) {overview.setMapType(G_HYBRID_MAP);}
		if (current==map.getMapTypes()[1]) {overview.setMapType(G_HYBRID_MAP);} 
		if (current==map.getMapTypes()[2]) {overview.setMapType(G_NORMAL_MAP);}
		if (current==map.getMapTypes()[3]) {overview.setMapType(G_PHYSICAL_MAP);}
	}
	
	//Función que ejecuta instancias de GE 
	function getEarthInstanceCB(object) {
		ge = object;	       
		ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
		ge.getLayerRoot().enableLayerById(ge.LAYER_BORDERS, true);
		ge.getLayerRoot().enableLayerById(ge.LAYER_ROADS, GEvias);
		ge.getLayerRoot().enableLayerById(ge.LAYER_BUILDINGS, true);
		ge.getLayerRoot().enableLayerById(ge.LAYER_TERRAIN, true);
		var options = ge.getOptions();
		options.setStatusBarVisibility(true);
		options.setScaleLegendVisibility(true);
		if (Modo==2) {
			if (Xinforma != "" && GE_Infowindow) {
				map.clearOverlays();
				var icon = ge.createIcon('');
				icon.setHref("http://maps.google.com/mapfiles/kml/pushpin/red-pushpin.png");
				var style = ge.createStyle('');
				style.getIconStyle().setIcon(icon);                              
				var point = ge.createPoint('');
				point.setLatitude(Xinforma);
				point.setLongitude(Yinforma); 
				var placemark = ge.createPlacemark('');
				placemark.setGeometry(point);
				placemark.setStyleSelector(style);
				ge.getFeatures().appendChild(placemark);
				var balloon = ge.createHtmlStringBalloon(''); 
				balloon.setFeature(placemark);
				balloon.setMinWidth(AnchoBalonGE);
				balloon.setMaxHeight(AltoBalonGE);
				balloon.setContentString(posmsg);                               
				google.earth.addEventListener(placemark, 'mouseover', function() {ge.setBalloon(balloon);});
				//ge.setBalloon(balloon);
			}
		}
		if (Modo==4) {
			if (Xinforma != "") {
				var icon1 = ge.createIcon('');
				icon1.setHref("http://maps.google.com/mapfiles/kml/shapes/hospitals.png");
				var style1 = ge.createStyle('');
				style1.getIconStyle().setIcon(icon1);                              
				var point1 = ge.createPoint('');
				point1.setLatitude(Xinforma);
				point1.setLongitude(Yinforma); 
				var placemark1 = ge.createPlacemark('');
				placemark1.setGeometry(point1);
				placemark1.setStyleSelector(style1);
				ge.getFeatures().appendChild(placemark1);                                
			}
		}                   
		if (WMSactivo) {
			var URL=WMS_URL;
			URL+="VERSION="+WMS_Version;
			if (WMS_Version != "1.0.0") {URL+="&amp;REQUEST=GetMap";} else {URL+="&amp;REQUEST=Map";} 
			URL+="&amp;SERVICE=WMS";
			URL+="&amp;LAYERS="+WMS_Layers;
			URL+="&amp;STYLES="+WMS_Style;
			URL+="&amp;FORMAT="+WMS_Format;
			URL+="&amp;BGCOLOR=0xFFFFFF"; 
			URL+="&amp;TRANSPARENT="+WMS_Transparent; 
			URL+="&amp;SRS=EPSG:4326";
			URL+="&amp;WIDTH=512";        
			URL+="&amp;HEIGHT=512&amp;";
			try {
				var wmskml = ge.parseKml(
				'<?xml version="1.0" encoding="UTF-8"?>' +
				'<kml xmlns="http://earth.google.com/kml/2.2">' +
				'<GroundOverlay>' +
				'       <name>WMS</name>' +
				'       <drawOrder>99</drawOrder>' +
				'	<Icon>' +
				'		<href>'+ URL +'</href>' +
				'		<refreshMode>onInterval</refreshMode>' +
				'		<refreshInterval>356401</refreshInterval>' +
				'		<viewRefreshMode>onStop</viewRefreshMode>' +
				'		<viewRefreshTime>1</viewRefreshTime>' +
				'		<viewFormat>BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]</viewFormat>' +
				'	</Icon>' +
				'       <LatLonBox>' +
				'               <north>90</north>' +
				'               <south>-90</south>' +
				'               <east>180</east>' +
				'               <west>-180</west>' +
				'       </LatLonBox>' +
				'</GroundOverlay>' + 
				'</kml>');
				ge.getFeatures().appendChild(wmskml);
			} catch (ex) {alert('El WMS no se ha ejecutado correctamente');}
		}
		if (XMLactivo) { 
			google.earth.fetchKml(ge, Xmlurl, function(kmlObject){
				if (!kmlObject) {
					alert('El archivo XML no se ha cargado correctamente, por favor verifique la URL');
					return;}                              
				ge.getFeatures().appendChild(kmlObject);                              		              		      
			});                    
		}
		if (PANOactivo) {
			google.earth.fetchKml(ge, PANOurl, function(kmlObject){
				if (!kmlObject) {
					alert('Las fotografías de PANORAMIO no se han cargado correctamente');
					return;}                              
				ge.getFeatures().appendChild(kmlObject);                              		              		      
			});
			google.earth.fetchKml(ge, "http://pepeyola.googlepages.com/Picasa.kml", function(kmlObject1){
				if (!kmlObject1) {
					alert('Las fotografías de PICASA no se han cargado correctamente');
					return;}                              
				ge.getFeatures().appendChild(kmlObject1);                              		              		      
			});                      
		}
		if (opacity > 0.05) {
			if (opacity > 0.95) {urlok=Superurl;} else {urlok=Superurltransp;}
			google.earth.fetchKml(ge,urlok, function(kmlObject){
				if (!kmlObject) {
					alert('El mapa temático no se ha cargado correctamente en Google Earth!');
					return;}                              
				ge.getFeatures().appendChild(kmlObject);
				//con el método removeChild se elimina la capa, cuando el zoom sobrepase el valor admitido                                                      		              		      
			});
		}
                if (Leyenda_fullscreen) {document.getElementById("Leyenda").style.display="block";}                 
	}
	
	//cuando sale de GE se recupera la sesion
	function Salida_GE() {
		GEarth=false;                
		document.getElementById("GE").style.display='inline';                           
		GEvent.removeListener(Evento1);
		if (mapa_overview) {if (!ventanaover) {mapoverview(true);}}
		else {if (ventanaover) {mapoverview(true);}}        
		document.getElementById("coords").style.display='inline';
		document.getElementById("nlcc").style.display='inline';
                document.getElementById("Leyenda").style.display="block";   
		recuperasesion();
		if (PANOactivo) {PANORAMIO(true);}
	}
	
	//Función que cambia el mapa a 3D 
	function google_earth() {
		mapa_overview=false;
		GEarth=true;
		document.getElementById("GE").style.display='none';                              
		sessvars.Tipodemapa=0;
		if (ventanaover) {
			mapoverview(true);
			mapa_overview=true;}		
		document.getElementById("coords").style.display='none';
		document.getElementById("nlcc").style.display='none';                
          	map.clearOverlays();
		document.getElementById("status").style.display='none';		
		GEvias=true;
		if (map.getCurrentMapType()== map.getMapTypes()[0]) {GEvias=false;} 
                document.getElementById("Leyenda").style.display="none"; 
		map.setMapType(G_SATELLITE_3D_MAP);                
		map.getEarthInstance(getEarthInstanceCB);               
		Evento1=GEvent.addListener(map, "maptypechanged", Salida_GE); 		         
	}
	
	//Funciones que verifica si se debe ir a GE
	function verificallamadaGE() {
		YAHOO.util.Event.removeListener("map");  
		if (GEarth==true) {google_earth();}
	}      
	
	//Funciones para añadir controles a GMap 
	function AdicionaControl(Posconstant,desX,desY,Elemento) {
		var pos = new GControlPosition(Posconstant, new GSize(desX,desY));
		pos.apply(document.getElementById(Elemento));
		// map.getContainer().appendChild(document.getElementById(Elemento));
	}
	function AdicionaControl1(toppx,leftperc,Elemento) {
		// map.getContainer().appendChild(document.getElementById(Elemento));         
		var posicion = document.getElementById(Elemento);
		posicion.style.top = toppx+"px";
		posicion.style.left = leftperc+"%";
	} 
        
        //muestran y cierran la leyenda en pantalla completa
        function cierra_leyenda(){
                Leyenda_fullscreen=false;
                Leyenda1.hide();
                document.getElementById("Leyenda").style.display="none";   
                document.getElementById("Legend").innerHTML = '<img title="Leyenda del Mapa Temático" style="cursor:pointer" width=28 height=28 src="leyenda_boton.png" onclick="Legend_show()">';
        };
        function Legend_show() {
                if (Leyenda_fullscreen) {return;};
                document.getElementById("Leyenda").style.display="block";   
                Leyenda1 = new YAHOO.widget.Panel("Leyenda", {
	               width: "200px",
                       height: "300px",
                       x:105,
	               y:50,
	               zIndex:1000,	               
                       underlay:"matte", 
	               close:false, 
	               visible:true, 
	               draggable:true,
	               iframe:true,
                       constraintoviewport: true,
                       effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25},
                       modal:false
                });
                var kl = new YAHOO.util.KeyListener(document, { keys:27 },{
                      fn: cierra_leyenda,
		      scope: Leyenda1,
		      correctScope:true } );
                Leyenda1.cfg.queueProperty("keylisteners", kl);               
                Leyenda1.render(document.body);
                document.getElementById("close_boton").style.display="block";
                document.getElementById("Legend").innerHTML = '<img title="Leyenda del Mapa Temático" style="cursor:pointer" width=28 height=28 src="leyenda_boton_activo.png" onclick="Legend_show()">';
                Leyenda_fullscreen=true;
            
                var resize = new YAHOO.util.Resize("Leyenda", {
                        handles: ['br'],
                        autoRatio: false,
                        minWidth: 110,
                        minHeight: 110,
                        useShim: true,
                        status: false                        
                });
                
                resize.on("resize", function(args) {
                        var panelHeight = args.height;
                        this.cfg.setProperty("height", panelHeight + "px");
                }, Leyenda1, true);                 
        }
	
	//Función que inicializa los mapas
	function load() {
		if (GBrowserIsCompatible()) {
			centreLat=CentroLat;
			centreLon=CentroLon;
			initialZoomLevel=LevelZoominicial;
			leesesion();
			var posmsg="";
			posmsg=decimal_grad(centreLat);
			posmsg += "/";
			posmsg+=decimal_grad(centreLon);
			document.getElementById("coords1").innerHTML="Lat/Lon: "+posmsg;
			var n_buttonText="Mapa"; 
			var s_buttonText="Satélite";
			var h_buttonText="Añadir Callejero";
			var p_buttonText= "Relieve";
			var copyright=new GCopyright(1,new GLatLngBounds(new GLatLng(-90, -180),new GLatLng(90, 180)),
			0,"<a href=\"http://www.dap.es\" target=\"_blank\" style=\"color:#7777CC;\">DAP</a>" );
			var copyrightCollection = new GCopyrightCollection('Mapa temático (cc) 2009 ');       
			copyrightCollection.addCopyright(copyright); 
			
			//crea la capa personalizada de G_NORMAL_MAP
			var n_tileLayers = [ G_NORMAL_MAP.getTileLayers()[0], new GTileLayer(copyrightCollection , 0, 17)];
			n_tileLayers[1].getTileUrl = customGetTileURL;
			n_tileLayers[1].isPng = function() { return true; };
			n_tileLayers[1].getOpacity = function() { return opacity; };
			var n_customMap = new GMapType(n_tileLayers, new GMercatorProjection(n_tileLayers[0].maxResolution()+1), n_buttonText,
			{textColor:"black", alt:"Callejero", maxResolution:17, minResolution:2, errorMessage:"No disponemos de imágenes de esta región con este nivel de zoom"});
			
			//crea la capa personalizada de G_SATELLITE_MAP
			var s_tileLayers = [ G_SATELLITE_MAP.getTileLayers()[0], new GTileLayer(copyrightCollection , 0, 19)];
			s_tileLayers[1].getTileUrl = customGetTileURL;
			s_tileLayers[1].isPng = function() { return true; };
			s_tileLayers[1].getOpacity = function() { return opacity; };
			var s_customMap = new GMapType(s_tileLayers, new GMercatorProjection(s_tileLayers[0].maxResolution()+1), s_buttonText,
			{textColor:"white", alt:"Imágenes de Satélite",maxResolution:19, minResolution:2, errorMessage:"No disponemos de imágenes de esta región con este nivel de zoom"});
			
			//crea la capa personalizada de G_HYBRID_MAP
			var h_tileLayers = [ G_HYBRID_MAP.getTileLayers()[0], new GTileLayer(copyrightCollection , 0, 19),G_HYBRID_MAP.getTileLayers()[1]];
			h_tileLayers[1].getTileUrl = customGetTileURL;
			h_tileLayers[1].isPng = function() { return true; };
			h_tileLayers[1].getOpacity = function() { return opacity; };
			var h_Layers=[h_tileLayers[0],h_tileLayers[1],h_tileLayers[2]]; 
			var h_customMap = new GMapType(h_Layers, new GMercatorProjection(h_tileLayers[0].maxResolution()+1), h_buttonText,
			{textColor:"white", alt:"Imágenes de Satélite con Callejero",maxResolution:19, minResolution:2, errorMessage:"No disponemos de imágenes de esta región con este nivel de zoom"});

			//crea la capa personalizada de G_PHYSICAL_MAP
			var p_tileLayers = [ G_PHYSICAL_MAP.getTileLayers()[0], new GTileLayer(copyrightCollection , 0, 17)];
			p_tileLayers[1].getTileUrl = customGetTileURL;
			p_tileLayers[1].isPng = function() { return true; };
			p_tileLayers[1].getOpacity = function() { return opacity; };
			var p_customMap = new GMapType(p_tileLayers, new GMercatorProjection(n_tileLayers[0].maxResolution()+1), p_buttonText,
			{textColor:"black", alt:"Relieve con Callejero", maxResolution:15, minResolution:2, errorMessage:"No disponemos de imágenes de esta región con este nivel de zoom"});
			
			//Ahora se crea el mapa personalizado. Puede ser G_NORMAL_MAP,G_SATELLITE_MAP,G_HYBRID_MAP, G_PHYSICAL_MAP
			map = new GMap2(document.getElementById("map"),{mapTypes:[s_customMap, h_customMap, n_customMap, p_customMap],
					googleBarOptions:{
							showOnLoad:false,
							linkTarget:G_GOOGLEBAR_LINK_TARGET_BLANK,
							suppressZoomToBounds:true},
					draggableCursor:"default", draggingCursor:"move"}  
			); 
			
			//Este control muestra los controles del zoom normal
			var arribaizq = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(8,70));
			map.addControl(new GLargeMapControl(),arribaizq);        
			
			//Este control muestra la escala
			var bottonLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(90,3));
			map.addControl(new GScaleControl(), bottonLeft); 
			
			//Este control permite añadir el cuadro de busqueda en el mapa   
			map.enableGoogleBar();
			
			//Este control muestra el boton para la salida de pantalla completa y el boton de leyenda en pantalla completa
			CambioPantalla(); 
			AdicionaControl(G_ANCHOR_TOP_LEFT,0,0,"screen");
                        AdicionaControl(G_ANCHOR_TOP_LEFT,71,49,"Legend");         
			
			//Este control es para el desplazamiento del mapa 
			myJoystickControl=new JoystickControl();
			map.addControl(myJoystickControl, new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(11, 9)));
			GEvent.addListener(myJoystickControl, 'drag', function(ancho, alto){map.panBy(new GSize(ancho, alto));});

			//Este control muestra el zoom arrastable
			var boxStyleOpts = { opacity: 0.4, border: "2px solid #4B7CBF" };
			var otherOpts = {
					buttonHTML: '<img title= "Zoom de Caja" src="zoom_boton1.png" style="width: 28px; height: 28px;"/>',
					buttonZoomingHTML: '<img title= "Zoom de Caja" src="zoom_activo_boton1.png" style="width: 28px; height: 28px;"/>',
					buttonStartingStyle: {width: '0px', height: '0px'},
					overlayRemoveTime: 0 };
			map.addControl(new DragZoomControl(boxStyleOpts, otherOpts, {}),
			new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(51,131)));
		
			//Estos controles permiten el zoom continuo y con la rueda de scroll del raton y activa el zoom con doble click
			map.enableContinuousZoom();
			map.enableScrollWheelZoom();
			map.enableDoubleClickZoom();
			
			//Este control muestra la advertencia que se ha superado el zoom maximo del mapa tematico
			AdicionaControl(G_ANCHOR_TOP_LEFT,81,132,"zoout");
			
			//Estos controles muestran el slider de la transparencia
			AdicionaControl(G_ANCHOR_TOP_LEFT,93,27,"slider-bg");
			AdicionaControl(G_ANCHOR_TOP_LEFT,73,25,"boton_menos");
			AdicionaControl(G_ANCHOR_TOP_LEFT,240,25,"boton_mas");
			
			//Estos controles muestran los botones de modos (medicion, centrado, informacion, etc) 
			AdicionaControl1(7,42.7,"tools-outer");
			AdicionaControl1(53,42.7,"status");
			
			//Este control muestra los botones para elegir el tipo de mapa base
			var mapControl = new GHierarchicalMapTypeControl();
			// Set up map type menu relationships
			mapControl.addRelationship(s_customMap, h_customMap, h_buttonText, false);
			map.addControl(mapControl); 
			
			//Estos controles muestran el menu mas... y el 3D y lo adicionan al elemento original de GM que contiene los botones de tipos de mapa
			YAHOO.util.Event.onContentReady("hmtctl", function(){ 
				YAHOO.util.Event.removeListener("hmtctl");
				var mapcontroles = document.getElementById("hmtctl"); 
				//Este control muestra el menu mas...
				var controlmas=document.getElementById("more");
				mapcontroles.appendChild(controlmas);       
				controlmas.style.right = "15.7em";
				//Este control el boton de Google Earth
				var controlGE=document.getElementById("GE");
				mapcontroles.appendChild(controlGE);        
				controlGE.style.right = "0px";  
				controlGE.style.bottom = "-6px";
			});
			
			//Captura el evento de movimiento del raton para actualizar las coordenadas de la ventana
			GEvent.addListener(map, "mousemove", function(point) {zmouse_move(point);});
			
			//Captura el evento click de forma ficticia solo para asignar un valor a evento
			Evento=GEvent.addListener(map, "click", nada);
			
			//Este control muestra el mensaje de geoposición
                        map.addControl(new GNavLabelControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT));
                 	document.getElementById("coords").appendChild(document.getElementById("nlcc"));   
                        document.getElementById("nlcc").style.right = "-1px"; 
                        document.getElementById("nlcc").style.top = "-2.5em";                       
                        
			if (Mapa==0) {MapType = s_customMap;} 
			if (Mapa==1) {MapType = h_customMap;}
			if (Mapa==2) {MapType = n_customMap;}    
			if (Mapa==3) {MapType = p_customMap;}   

			//Este control muestra el mapa de gogle en si. Se repite el control para poder retornar a la posicion inicial original
			map.setCenter(new GLatLng(CentroLat, CentroLon), LevelZoominicial, MapType);
			map.setCenter(new GLatLng(centreLat, centreLon), initialZoomLevel, MapType); 
			
			//Estos controles muestran la ventana de overview   	
			overview=new GOverviewMapControl();
			map.addControl(overview);
			actualizamapoverview();
			GEvent.addListener(map, "maptypechanged", actualizamapoverview);
			YAHOO.util.Event.onContentReady("map_overview", function(){ 
				YAHOO.util.Event.removeListener("map_overview");
				//Permite que la flechita del overview no se despiste cuando el mapa resize en IE y Chrome 
			        overview.hide();
			        overview.show(); 
                                var omap=document.getElementById("map_overview");
				omap.firstChild.style.border = "0px";
				omap.firstChild.firstChild.style.left="4px";
				omap.firstChild.firstChild.style.top="4px";
				omap.firstChild.firstChild.style.width="115px";
				omap.firstChild.firstChild.style.height="115px";
				AdicionaControl(G_ANCHOR_BOTTOM_RIGHT,0,0,"botonoverview"); 
				//Este control muestra las coordenadas del cursor
			        AdicionaControl(G_ANCHOR_BOTTOM_RIGHT,124,20,"coords");
                                document.getElementById("coords").style.bottom = "2em"; 
                                //Actualiza el estado del Window overview
			        if (!ventanaover) {
				            ventanaover=true;
				            mapoverview(true);
                                }    
				Glarge3DMapControl();                                                  
			});	
			
			//Selecciona el boton de modo de navegacion
			if (Modo==1) {stopEditing();} 
			if (Modo==2) {		
				SesionData=1;
				placeMarker();
				if (Xinforma==""){SesionData=0;}
				else {printdata();}
			} 
			if (Modo==3) {		
				var Repetir=count;
				linepoly(lineMode);
				count=0;
				for (var i=0 ; i< Repetir; i++) {
					point = new GLatLng(Xpuntos[i], Ypuntos[i]);
					leftClick("", point);	
				}
			}
			if (Modo==4) {		
				SesionData=1;
				centradovista();
				if (Xinforma==""){SesionData=0;} else {centrarvista();}
			}
			
			//Carga las capas activas en el menu mas...
			if (WMSactivo) {
				var opciones = document.getElementsByTagName("input");
				opciones[0].checked = true;
				WMS(true);
				opciones[1].checked = false;
			}	
			if (XMLactivo) {
				var opciones1 = document.getElementsByTagName("input");
				opciones1[1].checked = true;
				XML(true);
				opciones1[2].checked = false;
			}
			if (PANOactivo) {
				var opciones2 = document.getElementsByTagName("input");
				opciones2[2].checked = true;
				PANORAMIO(true);
			}           
			YAHOO.util.Event.onContentReady("map", verificallamadaGE);
		}
	}
	
	//Esta funcion se llama cuando se cierra la pagina y actualiza los variables de las sesion 
	function Actualizasesion() {
		if (GEarth != true) {
			var mTypes = map.getMapTypes();
			for (var n = 0 ; n < mTypes.length ; n++ ) {
				if (mTypes[n] == map.getCurrentMapType()) {tipomapa = n;}
			}
			sessvars.Tipodemapa=tipomapa;
		} else {
			document.getElementById('loading').style.display='inline';
			GEvent.removeListener(Evento1); 
			map.setMapType(G_SATELLITE_MAP);
		} 
		var latitudactual=map.getCenter().lat();
		var longitudactual=map.getCenter().lng();
		var nivelzoom=map.getZoom();
		if (GEarth) {if (nivelzoom > 19) {nivelzoom=19;}}
		sessvars.Latitudcentral=latitudactual;
		sessvars.Longitudcentral=longitudactual;
		sessvars.Zoominicial=nivelzoom;
		sessvars.ModoNavega=Modo;
		sessvars.InformaX=Xinforma;
		sessvars.InformaY=Yinforma;
		sessvars.Opacidad=opacity;
		sessvars.Contador=count;
		sessvars.XPuntos=new Array();
		sessvars.YPuntos=new Array();
		for (var i=0 ; i<count; i++) {
			sessvars.XPuntos[i]=points[i].lat();
			sessvars.YPuntos[i]=points[i].lng();
		}
		sessvars.Modolinea=lineMode;
		sessvars.ESTreD=GEarth;
		if (GEarth) {sessvars.overmapa=mapa_overview;} else {sessvars.overmapa=ventanaover;}
		sessvars.PANO=PANOactivo;  
		sessvars.XML=XMLactivo;
		sessvars.Xmlurl=Xmlurl;
		sessvars.WMS=WMSactivo;
		sessvars.WMSURL=WMS_URL;
		sessvars.WMSLayers=WMS_Layers;
		sessvars.WMSFormat=WMS_Format;
		sessvars.WMSStyle=WMS_Style;
		sessvars.WMSVersion=WMS_Version;
		sessvars.WMSTransparent=WMS_Transparent;
		sessvars.WMSOpacity=WMS_Opacity;                            
		sessvars.$.flush();
		GUnload();
	}
