/*******************************/
/*         VARIABLES           */
/*******************************/
    var gdir;
    var geo;
    var hay_origen=false;
    var hay_destino=false;
	  var map = null;
    var markerSearch = null;
    var geocoder = null;   
    var tooltip = null;  
    var loadlay = null;      		   
    var num_load = 0;
    var reasons=[];
    latlon = new Array(2);
    var h=0;
    var geoXml;

    var ge;
    function getEarthInstanceCB(object) {
      ge = object;
      //map.setMapType(G_SATELLITE_3D_MAP);
      //map.addControl(new GMapTypeControl());
      
      // You can now manipulate ge using the full Google Earth API.
    }

    		    
/*******************************/
/*     FUNCION PRINCIPAL       */
/*******************************/

  function loadMap() {
    if (GBrowserIsCompatible()) {
      geocoder = new GClientGeocoder();
      geo = new GClientGeocoder();         
    	reasons[G_GEO_SUCCESS]            = "Success";
    	reasons[G_GEO_MISSING_ADDRESS]    = "Introduzca una direccion.";
    	reasons[G_GEO_UNKNOWN_ADDRESS]    = "Direccion Desconocida: No se pudo geolocalizar la direccion.";
    	reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
    	reasons[G_GEO_BAD_KEY]            = "Bad Key: The API key is either invalid or does not match the domain for which it was given";
    	reasons[G_GEO_TOO_MANY_QUERIES]   = "Too Many Queries: The daily geocoding quota for this site has been exceeded.";
    	reasons[G_GEO_SERVER_ERROR]       = "Server error: The geocoding request could not be successfully processed.";
      }
    }
    
    
    function vermapa3d() {
    map.setMapType(G_SATELLITE_3D_MAP);
    }
    
  function showAddress(address, categoria, icono) { 
    document.getElementById("flashcontent").style.display="none"; 
     map = new GMap2(document.getElementById("map"));


    map.addMapType(G_SATELLITE_3D_MAP);
    map.addControl(new GHierarchicalMapTypeControl());
     // Uncomment the following line to start the map with 3D enabled.
     // map.setMapType(G_SATELLITE_3D_MAP);
     // Obtain a pointer to the Google Earth instance attached to
     // your map.
	  //map.getEarthInstance(getEarthInstanceCB);    

var publisher_id = "ca-pub-1939275015713518";

var adsManagerOptions = {
 maxAdsOnMap : 2,
 style: 'adunit',
 // The channel field is optional - replace this field with a channel number
 // for Google AdSense tracking
 channel: '2' 
};

adsManager = new GAdsManager(map, publisher_id, adsManagerOptions);
adsManager.enable();


     document.getElementById("fromAddress").value="";
		 document.getElementById("toAddress").value="";	
  
    gdir = new GDirections(map, document.getElementById("directions"));
    GEvent.addListener(gdir, "load", onGDirectionsLoad);
    GEvent.addListener(gdir, "error", handleErrors);
    options = {linkTarget:GSearch.LINK_TARGET_PARENT,title : "Busqueda local"};
    map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(10,20))); 
    
    //map.addOverlay(trafficInfo);
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.addControl(new GOverviewMapControl(new GSize(100,100)));              
    map.enableContinuousZoom();
    map.enableDoubleClickZoom();
    //map.enableScrollWheelZoom();

    //Publicidad
    var adsManager = new GAdsManager(map, "ca-pub-1939275015713518");
    adsManager.enable();


  //map.addControl(new ExtMapTypeControl());
  
  //var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, 'owned by NASA');
  //var copyrights = new GCopyrightCollection('The Blue Marble Imagery');
  //copyrights.addCopyright(copyright);
  //var tilelayer = new GTileLayer(copyrights, 0, 17);
  //tilelayer.getTileUrl = function(tile, zoom) { 
   // return "http://gmaps-utility-library.googlecode.com/svn/trunk/extmaptypecontrol/1.2/examples/blue_marble.jpg"; 
  //};
  //var CUSTOM_MAP = new GMapType( [tilelayer], new GMercatorProjection(20), "NASA" );
  //map.addMapType(CUSTOM_MAP);

    var min = 0;
    var max = 12;   
    var osmmax = 15;   


    var license = "<a href='http://www.maps-for-free.com/html/about.html' target='_blank'>License</a>";
    var copyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, license);
    var copyrightCollection = new GCopyrightCollection("Relief Maps: ");
    copyrightCollection.addCopyright(copyright);

//    var relief = [new GTileLayer(copyrightCollection, min, max)];
//    relief[0].getTileUrl = function(a,b) {
//      return "http://srtm.in-ulm.de/layer/relief/z" +
//      b + "/row" + a.y + "/" + b + "_" + a.x + "-" + a.y + ".jpg"; };
//    reliefLayer = new GMapType(relief, G_SATELLITE_MAP.getProjection(), "Relief", {minResolution:min, maxResolution:max});

    var osmlicense = "<a href='http://www.openstreetmap.com' target='_blank'>License</a>";
    var osmcopyright = new GCopyright(1, new GLatLngBounds(new GLatLng(-90, -180), new GLatLng(90, 180)), 0, osmlicense);
    var osmcopyrightCollection = new GCopyrightCollection("OpenStreetsMap: ");
    osmcopyrightCollection.addCopyright(osmcopyright);

    var osm = [new GTileLayer(osmcopyrightCollection, min, osmmax)];
    osm[0].getTileUrl = function(a,b) {
      return "http://tile.openstreetmap.org/" + b + "/" + a.x + "/" + a.y + ".png"; };
    osmLayer = new GMapType(osm, G_SATELLITE_MAP.getProjection(), "OpenStMap", {minResolution:min, maxResolution:osmmax});
   // map.addMapType(reliefLayer);
    map.addMapType(osmLayer);
    map.setCenter(new GLatLng(40.2022, -4.1748 ), 7);
    

    
    document.getElementById("cargando").style.display="none"; 

    //tooltip = document.createElement("div");
    //map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
    //tooltip.style.visibility="hidden";         
      
    //map.getPane(G_MAP_FLOAT_PANE).appendChild(loadlay);	
	  /*GEvent.addListener(map, "addoverlay", function(overlay) {     			
    	GEvent.addListener(overlay,"mouseover", function() {
        	showTooltip(overlay);
        });        
        GEvent.addListener(overlay,"mouseout", function() {
		tooltip.style.visibility="hidden";
     	});   		  		
	});	

*/
	myDragend=GEvent.addListener(map, "dragend", function() {
	 tratarCategorias2();
	});

	GEvent.addListener(map, "zoomend", function() {  
		//map.clearOverlays();
	 tratarCategorias2();
	});
	}



function TextualZoomControl2() {}

  TextualZoomControl2.prototype = new GControl();
  TextualZoomControl2.prototype.initialize = function(map) {  
    var container = document.createElement("div");  
    var zoomInDiv = document.createElement("div");  
    this.setButtonStyle_(zoomInDiv);  
    container.appendChild(zoomInDiv);  
    zoomInDiv.appendChild(document.createTextNode(""));  
    GEvent.addDomListener(zoomInDiv, "click", function() {    
     map.zoomIn();  
    });  
    map.getContainer().appendChild(container);  return container;
  }

  TextualZoomControl2.prototype.getDefaultPosition = function() {  
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(47, 10));
  }

   // Sets the proper CSS for the given button element.
   TextualZoomControl2.prototype.setButtonStyle_ = function(button) {  
    button.style.textDecoration = "underline"; 
    button.style.color = "#0000cc";  
    button.style.backgroundColor = "transparent"; 
    button.style.font = "small Arial"; 
    //button.style.border = "1px solid black"; 
    button.style.padding = "2px";  
    button.style.marginBottom = "2px";    
    button.style.textAlign = "center";  
    button.style.width = "50px";  
    button.style.height = "50px";
    button.style.cursor = "pointer";
    button.style.background = 'url(ico_mas.gif) no-repeat';
    button.style.backgroundColor = "transparent";  
  }


function TextualZoomControl() {}

  TextualZoomControl.prototype = new GControl();
  TextualZoomControl.prototype.initialize = function(map) {  
    var container = document.createElement("div");  

    var zoomOutDiv = document.createElement("div");  
    this.setButtonStyle_(zoomOutDiv); 
    container.appendChild(zoomOutDiv);  
    zoomOutDiv.appendChild(document.createTextNode(""));  
    GEvent.addDomListener(zoomOutDiv, "click", function() {    
    map.zoomOut();  
    });  

    map.getContainer().appendChild(container);  return container;
  }
  TextualZoomControl.prototype.getDefaultPosition = function() {  
    return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(80, 10));
  }

   // Sets the proper CSS for the given button element.
   TextualZoomControl.prototype.setButtonStyle_ = function(button) {  
    button.style.textDecoration = "underline"; 
    button.style.color = "#0000cc";  
    button.style.backgroundColor = "transparent"; 
    button.style.font = "small Arial"; 
    //button.style.border = "1px solid black"; 
    button.style.padding = "2px";  
    button.style.marginBottom = "2px";    
    button.style.textAlign = "center";  
    button.style.width = "50px";  
    button.style.height = "50px";
    button.style.cursor = "pointer";
    button.style.background = 'url(ico_menos.gif) no-repeat';
    button.style.backgroundColor = "transparent";  
  }


/*******************************/
/*     TRAFICO    */
/*******************************/


    function showAddress22(address) {
      geocoder.getLatLng(
        address,
        function(point) {
          if (!point) {
            alert(address + " not found");
          } else {
            map.clearOverlays();
            map.setCenter(point, 13);
            var marker = new GMarker(point, {draggable: true});
            GEvent.addListener(marker, "dragend", function() {
              var latlng = marker.getLatLng();
              document.getElementById("latbox").value = latlng.lat();
              document.getElementById("lonbox").value = latlng.lng();
            });
            var latlng = marker.getLatLng();
            document.getElementById("latbox").value = latlng.lat();
            document.getElementById("lonbox").value = latlng.lng();
            map.addOverlay(marker);
          }
        }
      );
    }


 function MostrarFotos(map,lat,lng,lat2, lng2){
 	  var lat1=lat;
 	  var lat2=lat2;
	  var lng1=lng;
 	  var lng2=lng2;

  url="http://www.davifer.es/trafico/cargaPano.php?latNS="+lat2+"&longNS="+lng2+"&latSW="+lat1+"&longSW="+lng1+"";
  http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       var http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml');}
    }
    else if (window.ActiveXObject) { // IE
            try {
                var http_request = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (e) {
                  try {
                    var http_request = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (e) {}
              }
    }
    if (!http_request) {
               alert('Giving up :( Cannot create an XMLHTTP instance');
               return false;
    }
    else {        	 
      http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
          if (http_request.status == 200) {
              document.getElementById("cargando").style.display="none"; 
              //var xmlDoc = http_request.responseXML;      		          
              //alert(http_request.responseText);
              if (http_request.responseText =="") 
                alert("Lo sentimos, pero en estos momentos estamos teniendo problemas para mostrar los resultados. Gracias.")
              else {
              var objCentro = eval("("+ http_request.responseText +")");
              for (var i = 0; i < objCentro.count; i++) {

                var point = new GLatLng(objCentro.photos[i].latitude,objCentro.photos[i].longitude);
                var html="<div style='font-size:14px;color:#c37602;'>"+objCentro.photos[i].photo_title+"</div><div style='border-top:1px solid #c37602;border-bottom:1px solid #c37602; font-size:14px;color:#c37602;padding:10px;height:auto;width:"+objCentro.photos[i].width+";'><img src='"+objCentro.photos[i].photo_file_url+"'/></div>";
                map.addOverlay(createMarkerPanoramio(point,html));
             }
             }
          }
		       else if (http_request.status == 204)
	             alert('NO HAY RESPUESTA');
        }
      }
    document.getElementById("cargando").style.display="";
    http_request.open("GET", url, true);
    http_request.send(null);
    }
} 

function createMarkerPanoramio(point,html){
 	var icono  = new GIcon();
  icono.image = "http://maps.google.com/mapfiles/kml/pal4/icon38.png";
  icono.iconSize = new GSize(32, 32);
  icono.shadowSize = new GSize(37, 34);
  icono.iconAnchor = new GPoint(9, 34);
  icono.infoWindowAnchor = new GPoint(9, 2);
  icono.infoShadowAnchor = new GPoint(18, 25);
    	var marker = new GMarker(point,{icon:icono});
  GEvent.addListener(marker, "click", function() {           
    //map.setCenter(point,11);
    marker.openInfoWindowHtml(html);
    //tooltip.style.visibility="hidden";
  });
  return marker;
}

function cargarDatos(url){
  http_request = false;
   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       var http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml');}
    }
    else if (window.ActiveXObject) { // IE
            try {
                var http_request = new ActiveXObject("Msxml2.XMLHTTP");
              } catch (e) {
                  try {
                    var http_request = new ActiveXObject("Microsoft.XMLHTTP");
                  } catch (e) {}
              }
    }
    if (!http_request) {
               alert('Giving up :( Cannot create an XMLHTTP instance');
               return false;
    }
    else {        	 
      http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {      
          if (http_request.status == 200) {
            document.getElementById("cargando").style.display="none"; 	        		          
            parseJsonElementos(http_request.responseText, 0, map);
             }
		       else if (http_request.status == 204)
	             alert('NO HAY RESPUESTA');
        }
      }
    document.getElementById("cargando").style.display="";
    http_request.open("get", url,true);
    http_request.send(null);
    }
}

/*******************************/
/*     INCIDENCIAS    */
/*******************************/
  function showIncidencias(pArbDrch,pAbjIz,zoom){

	  var request = GXmlHttp.create();	 
    document.getElementById("cargando").style.display="";            
    //request.open("GET", "http://www.guiacampsa.com/gcampsa/InformacionRuta/Trafico/Incidencias.asp?vista=PROV", true);
    request.open("GET", "http://www.davifer.es/trafico/cargaInc.php", true);
      request.onreadystatechange = function() {
        if (request.readyState == 4) {  
        document.getElementById("cargando").style.display="none";                    
        var texto =request.responseText.substr(request.responseText.indexOf("<td class=\"textoazul\">"),request.responseText.length);
        var array=[];
        while (texto.indexOf("<td><img src=\"/gcampsa/images/void.gif\" width=7 height=35></td>") >=0) {
        texto=texto.substr(texto.indexOf("<td><img src=\"/gcampsa/images/void.gif\" width=7 height=35></td>")+63);
        for (var i=0; i<16; i++){
          var inicio=texto.indexOf('>');
          var fin =texto.indexOf('</td>');          
          array[i]=texto.substr(inicio+1,fin-(inicio+1));

          texto=texto.substr(fin+5);            
                  
        }        
         var coord= array[14];
        
        if (coord.length >12) {
        var nombre = array[0];
        var carretera = array[6];
        var kilometro = array[8];
        var sentido = array[10];
        var provincia = array[12];
        var incidencia = array[4];
        var nivel = array[2];             

        var nivelini=nivel.indexOf('"');
        var nivelbueno=nivel.substr(0,nivelini+1)+"http://www.guiacampsa.com"+nivel.substr(nivelini+1);
  
        var icononivel=nivelbueno.substr(nivelbueno.indexOf('h'),(nivelbueno.indexOf('"',nivelbueno.indexOf('h'))-nivelbueno.indexOf('h')));
      
                             
        var inicio=coord.indexOf('x=');        
        var fin =coord.indexOf('&',inicio);
        var x=coord.substr(inicio+2,fin-(inicio+2));  
        var inicio=coord.indexOf('y=');        
        var fin =coord.indexOf('&',inicio);
        var y=coord.substr(inicio+2,fin-(inicio+2));  
        // zone = Math.floor ((lon + 180.0) / 6) + 1
        UTMXYToLatLon (x, y, "30", false, latlon);
        var latitud=RadToDeg (latlon[0]);
        var longitud=RadToDeg (latlon[1]);
        
        //if ((latitud < pArbDrch.lat() & latitud > pAbjIz.lat()) & ((longitud < pArbDrch.lng() & longitud > pAbjIz.lng()))) {
          var point = new GLatLng(latitud,longitud);	            
          var icono="Icon"+i;
         	icono  = new GIcon();
  	      //icono.image = "http://maps.google.com/mapfiles/kml/pal3/icon"+i+".png";
  	      icono.image ='incid.png';
  	      icono.iconSize = new GSize(35, 38);
  	      icono.shadowSize = new GSize(37, 34);
  	      icono.iconAnchor = new GPoint(9, 34);
  	      icono.infoWindowAnchor = new GPoint(9, 2);
  	      icono.infoShadowAnchor = new GPoint(18, 25);
  
  			  var msg = "<div id='popE'>&nbsp;";
  				if (incidencia=="OBRAS"){
  					msg += "<ul class='iconTb_InciObras'>";			
  				} else if (incidencia=="METEREOLOGIA"){
  					msg += "<ul class='iconTb_InciMeteo'>";						
  				}   				
  				imgNivel=nivelbueno;
  				msg +="<li>"+imgNivel+"&nbsp&nbsp</li></br>"
  			 	msg += "<li><span class='popEcab'>Tipo</span>: "+incidencia +" </li>";
  	    	msg += "<li class='pijama1'><span class='popEcab'>Lugar:</span> "+carretera + " kilometros: "+kilometro+" </li>";
  	    	//msg += "<li><span class='popEcab'>Causa:</span> "+ele.causa +"</li>";
  	    	msg += "<li class='pijama1'><span class='popEcab'>Poblacion:</span> "+nombre +" / "+provincia+" </li>";
  	    	//msg += "<li><span class='popEcab'>Nivel:</span> "+ele.nivel +"</li>";
  	    	msg += "<li class='pijama1'><span class='popEcab'>Sentido:</span> "+sentido +" </li><br>";
  	    	msg += "</ul>";
    
          map.addOverlay(createMarkerIcono2(point,icono,msg,map));
        //}   
        //if (h==30) break;
        h++;   
  
      }
    }  	
   }
  }  
  request.send(null);
} 
	
	
 function createMarkerIcono2(point,icono,infoSucursal,map)
  {	          	           
    	var marker = new GMarker(point,{icon:icono});
		  //marker.name = nombre;    

        GEvent.addListener(marker, "click", function() {           
          //map.setCenter(point,11);
          marker.openInfoWindowHtml(infoSucursal);
          //tooltip.style.visibility="hidden";
        });
        return marker;

    }

  
/*******************************/
/*     FUNCIONES AUXILIARES    */
/*******************************/
 
  function Alternar(Seccion){ 
    if (document.getElementById(Seccion).style.display=="none"){document.getElementById(Seccion).style.display=""}
    else{document.getElementById(Seccion).style.display="none"} 
}
 
 
   function showMapAviso(){
  	document.getElementById("avisoMapa").innerHTML='&nbsp;Acerque el zoom para ver elementos sobre el mapa';
  	document.getElementById("avisoMapa").style.background="#FFDB61";
	//document.getElementById("avisoMapa").style.display="";
  }


  function hideMapAviso(){
  	document.getElementById("avisoMapa").innerHTML='&nbsp;&nbsp;';
  	document.getElementById("avisoMapa").style.background="#FFFFFF";
	//document.getElementById("avisoMapa").style.display="none";
  }
 
  function showTooltip(marker) {
  //alert(marker.name);
  tooltip.innerHTML = '<div class="tooltip" style="width:100px">punto</div>';
 	if(marker.name){
 		if(marker.tipo){
 			tooltip.innerHTML = '<div class="tooltip" style="width:100px">'+ marker.name +'</div>';
 		}
      		else tooltip.innerHTML = '<div class="tooltip">'+ marker.name +'</div>';
		var point=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());
		var point2=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getSouthWest(),map.getZoom());
		var point3=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.getBounds().getNorthEast(),map.getZoom());
		var offset=map.getCurrentMapType().getProjection().fromLatLngToPixel(marker.getPoint(),map.getZoom());
		var anchor=marker.getIcon().iconAnchor;
		var width=marker.getIcon().iconSize.width;
		var alto=tooltip.clientHeight;
		var largo=tooltip.offsetWidth;
		//alert("offset=" + offset.x + "," + offset.y + " Point=" + point.x + "," + point.y  + " Point2=" + point2.x + "," + point2.y  + " Point3=" + point3.x + "," + point3.y  + " Anchor=" + anchor + " width=" + width + " height=" + alto);
		
		var desplz_x = (largo+anchor.x)/2;
		var desplz_y = (alto);
		
		if((offset.y - point3.y  ) < (desplz_y + anchor.y)){
			desplz_y = (anchor.y) * (-1);
			
		}
		if((offset.x - point2.x) < desplz_x){
			desplz_x= (offset.x - point2.x);
			
		}else if((point3.x - offset.x)  < desplz_x){
			desplz_x=desplz_x + desplz_x -(point3.x - offset.x);
			
		}
		
		var pos = new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(offset.x - point.x - anchor.x + (width-desplz_x), offset.y - point.y -anchor.y -(desplz_y))); 
		pos.apply(tooltip);
		tooltip.style.visibility="visible";		
		}
		else {
			tooltip.style.visibility="hidden";
		}
	}
	
	
  function createMarkerIcono(point,tipo,infoSucursal,map,zoom,nombre,total_puntos) {	 
		var baseIcon = new GIcon();	  
          	baseIcon.iconSize=new GSize(32,32);
          	baseIcon.shadowSize=new GSize(56,32);
          	baseIcon.iconAnchor=new GPoint(16,32);
          	baseIcon.infoWindowAnchor=new GPoint(16,0);


          	var icono = null;        
	
    	var marker = new GMarker(point,{icon:icono});
		  marker.name = nombre;    

        GEvent.addListener(marker, "click", function() {
		      if (total_puntos==0)           
          	map.setCenter(point,16);
            marker.openInfoWindowHtml(infoSucursal);
            tooltip.style.visibility="hidden";
        });
        return marker;

    }
 

     function Buscar() {
    	var search = document.getElementById("search").value ;
    	//var search2 = document.getElementById("search2").value ;
     	
     	document.getElementById("cat0").innerHTML='';
		document.getElementById("cat0").style.display="none";
		document.getElementById('msg_cat0').style.display="none"  ;
		document.getElementById("msg_cat0").innerHTML=''; 		
    	document.getElementById('cat_museos').style.display="none";
		document.getElementById('cat_bibliotecas').style.display="none";
		document.getElementById('cat_archivos').style.display="none";
		document.getElementById('cat_exposiciones').style.display="none";
		document.getElementById('cat_patrimonio').style.display="none";
		document.getElementById('cat_centrosinaem').style.display="none";
		document.getElementById('cat_registrosmcu').style.display="none";
		document.getElementById('cat_centrosdoc').style.display="none";
		document.getElementById('cat_sedesmcu').style.display="none";
		document.getElementById('cat_externos').style.display="none";
		document.getElementById('cat_otros').style.display="none";
		
		document.getElementById('msg_cat1').style.display="none";
		document.getElementById("msg_cat1").innerHTML=''; 
		document.getElementById('msg_cat2').style.display="none";
		document.getElementById("msg_cat2").innerHTML=''; 
		document.getElementById('msg_cat5').style.display="none";
		document.getElementById("msg_cat5").innerHTML=''; 
		document.getElementById('msg_cat3').style.display="none";
		document.getElementById("msg_cat3").innerHTML=''; 
		document.getElementById('msg_cat4').style.display="none";
		document.getElementById("msg_cat4").innerHTML=''; 
		document.getElementById('msg_cat6').style.display="none";
		document.getElementById("msg_cat6").innerHTML='';                                                         
		document.getElementById('msg_cat7').style.display="none";
		document.getElementById("msg_cat7").innerHTML='';   
		document.getElementById('msg_cat8').style.display="none";
		document.getElementById("msg_cat8").innerHTML='';   
		document.getElementById('msg_cat9').style.display="none";
		document.getElementById("msg_cat9").innerHTML='';   
		document.getElementById('msg_cat10').style.display="none";
		document.getElementById("msg_cat10").innerHTML='';   
		document.getElementById('msg_cat11').style.display="none";
		document.getElementById("msg_cat11").innerHTML='';   
		document.getElementById("message1").innerHTML ='';
	      	
     	if(search!="") MostrarSugerencias();
     	//if(search2!="") BuscarPuntos();     	
     }

	function  limpiarBusqueda(id) {
		document.getElementById(id).value="";
	}



function crearMarker(nombre,latitud,longitud,tipo,html){
	if(markerSearch){
		map.removeOverlay(markerSearch);
		markerSearch = null;
	}

		var baseIcon = new GIcon();	  
          	baseIcon.iconSize=new GSize(32,32);
          	baseIcon.shadowSize=new GSize(56,32);
          	baseIcon.iconAnchor=new GPoint(16,32);
          	baseIcon.infoWindowAnchor=new GPoint(16,0);
          	var icono = null;
          	if(tipo=="museos") icono = new GIcon(baseIcon,"images/m_museo.png");
        	else if(tipo=="bibliotecas") icono = new GIcon(baseIcon,"images/m_bibliotecas.png");
          	else if(tipo=="exposiciones") icono = new GIcon(baseIcon,"images/m_exposicion.png");
          	else if(tipo=="patrimonio") icono = new GIcon(baseIcon,"images/m_patrimonio.png");
          	else if(tipo=="archivos") icono = new GIcon(baseIcon,"images/m_archivo.png");
          	//else if(tipo=="exposiciones") icono = new GIcon(baseIcon,"images/m_otros.png");
			else if(tipo=="centrosinaem") icono = new GIcon(baseIcon,"images/m_otros.png");
			else if(tipo=="registrosmcu") icono = new GIcon(baseIcon,"images/m_otros.png");
			else if(tipo=="centrosdoc") icono = new GIcon(baseIcon,"images/m_otros.png");
			else if(tipo=="sedesmcu") icono = new GIcon(baseIcon,"images/m_otros.png");
			else if(tipo=="sedesmcu") icono = new GIcon(baseIcon,"images/m_otros.png");
			else if(tipo=="externos") icono = new GIcon(baseIcon,"images/m_otros.png");							

		var point = new GLatLng(latitud,longitud);
		if(icono) markerSearch = new GMarker(point,{icon:icono});  
		else markerSearch = new GMarker(point);  
        	markerSearch.name = nombre;      
        	map.setCenter(point, 15);	
		map.addOverlay(markerSearch); 
        	GEvent.addListener(markerSearch, "click", function() {
		  markerSearch.openInfoWindowHtml(html);
	 	});
		markerSearch.openInfoWindowHtml(html);

}
 
	function  DesmarcarTodas() {
		document.optionform.trafico.checked=0;
		document.optionform.radares.checked=0;
		//document.optionform.incidencias.checked=0;
		document.optionform.panoramio.checked=0;
		
	}



/****************************/
//     TRATAR CATEGORIAS
/*****************************/

		    var toggleState = 0;

  function toggleTraffic(toggleState,trafficInfo,map) {
      if (toggleState == 1) {
        map.removeOverlay(trafficInfo);
        toggleState = 0;
      } else {
        map.addOverlay(trafficInfo);
        toggleState = 1;
      }
    }
		    
function tratarCategorias() {
	map.clearOverlays();

    var trafficInfo = new GTrafficOverlay();
/*		if (document.optionform.traficoeeuu.checked) {
		    toggleState = 0;
		    toggleTraffic(toggleState,trafficInfo,map);
		}
		else {
		  toggleState = 1;
      toggleTraffic(toggleState,trafficInfo,map);
    }
	*/
	if (document.optionform.trafico.checked) {
	  var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();  
		var northEast = bounds.getNorthEast();  
		var lngSpan = northEast.lng() - southWest.lng(); 
		var latSpan = northEast.lat() - southWest.lat();
		map.getZoom();			
    //url="http://infocar.dgt.es/etraffic/BuscarElementosServlet?latNS="+northEast.lat()+"&longNS="+northEast.lng()+"&latSW="+southWest.lat()+"&longSW="+southWest.lng()+"&zoom="+map.getZoom()+"&accion=getElementos&Camaras=true&SensoresMeteorologico=true&Paneles=true&IncidenciasCONO=true&IncidenciasRETENCION=true&IncidenciasOBRAS=true&IncidenciasMETEOROLOGICA=true&IncidenciasPUERTOS=true&&niveles=true";
    url="http://www.davifer.es/trafico/cargaTrafico.php?latNS="+northEast.lat()+"&longNS="+northEast.lng()+"&latSW="+southWest.lat()+"&longSW="+southWest.lng()+"&zoom="+map.getZoom()+"&accion=getElementos&Camaras=true&SensoresMeteorologico=true&Paneles=true&IncidenciasCONO=true&IncidenciasRETENCION=true&IncidenciasOBRAS=true&IncidenciasMETEOROLOGICA=true&IncidenciasPUERTOS=true&&niveles=true";
    //if (map.getZoom() >9)
      cargarDatos(url);
  }

	if (document.optionform.panoramio.checked) {
	 var llb = map.getBounds();  
	 MostrarFotos(map,llb.getNorthEast().lat(),llb.getNorthEast().lng(),llb.getSouthWest().lat(),llb.getSouthWest().lng());
  } 	

	if (document.optionform.radares.checked) {
	 //cargar_radares(map);
		var ctr = map.getCenter();
    var lat =ctr.lat();
    var lng=ctr.lng();
	 var zoom = map.getZoom();
	 cargarRadares();
	 map.setCenter(new GLatLng(lat,lng),zoom ); 
  } 
  
	if (document.optionform.camarasMadrid.checked) {
	 geoXml = new GGeoXml("http://www.davifer.es/trafico/camarasMadrid.kml");
   map.setCenter(new GLatLng(40.43884717005281,-3.6972427368164062), 12);
   map.addOverlay(geoXml); 
  } 
  
  	
/*	if (document.optionform.incidencias.checked) {
	  var bounds = map.getBounds();
		var pAbjIz = bounds.getSouthWest();  
		var pArbDrch = bounds.getNorthEast();  
	  showIncidencias(pArbDrch,pAbjIz,map.getZoom());
	  }
  */   		
}


function tratarCategorias2() {
	if (document.optionform.trafico.checked) {
	  var bounds = map.getBounds();
		var southWest = bounds.getSouthWest();  
		var northEast = bounds.getNorthEast();  
		var lngSpan = northEast.lng() - southWest.lng(); 
		var latSpan = northEast.lat() - southWest.lat();
		map.getZoom();			
    //url="http://infocar.dgt.es/etraffic/BuscarElementosServlet?latNS="+northEast.lat()+"&longNS="+northEast.lng()+"&latSW="+southWest.lat()+"&longSW="+southWest.lng()+"&zoom="+map.getZoom()+"&accion=getElementos&Camaras=true&SensoresMeteorologico=true&Paneles=true&IncidenciasCONO=true&IncidenciasRETENCION=true&IncidenciasOBRAS=true&IncidenciasMETEOROLOGICA=true&IncidenciasPUERTOS=true&&niveles=true";
    url="http://www.davifer.es/trafico/cargaTrafico.php?latNS="+northEast.lat()+"&longNS="+northEast.lng()+"&latSW="+southWest.lat()+"&longSW="+southWest.lng()+"&zoom="+map.getZoom()+"&accion=getElementos&Camaras=true&SensoresMeteorologico=true&Paneles=true&IncidenciasCONO=true&IncidenciasRETENCION=true&IncidenciasOBRAS=true&IncidenciasMETEOROLOGICA=true&IncidenciasPUERTOS=true&&niveles=true";
    //if (map.getZoom() >11)
      cargarDatos(url);
  }
  if (document.optionform.panoramio.checked) {
	   var llb = map.getBounds();  
	   MostrarFotos(map,llb.getNorthEast().lat(),llb.getNorthEast().lng(),llb.getSouthWest().lat(),llb.getSouthWest().lng());
  } 	
}

/****************************/
// SUGERENCIAS EN LAS BUSQUEDAS
/*****************************/

    // ===== list of words to be standardized =====
    var standards = [   ["road","rd"],   
                        ["street","st"], 
                        ["avenue","ave"], 
                        ["av","ave"], 
                        ["drive","dr"],
                        ["saint","st"], 
                        ["north","n"],   
                        ["south","s"],    
                        ["east","e"], 
                        ["west","w"],
                        ["expressway","expy"],
                        ["parkway","pkwy"],
                        ["terrace","ter"],
                        ["turnpike","tpke"],
                        ["highway","hwy"],
                        ["lane","ln"]
                     ];

   // ===== convert words to standard versions =====
    function standardize(a) {
      for (var i=0; i<standards.length; i++) {
        if (a == standards[i][0])  {a = standards[i][1];}
      }
      return a;
    }

 // ===== check if two addresses are sufficiently different =====
    function different(a,b) {
      // only interested in the bit before the first comma in the reply
      var c = b.split(",");
      b = c[0];
      // convert to lower case
      a = a.toLowerCase();
      b = b.toLowerCase();
      // remove apostrophies
      a = a.replace(/'/g ,"");
      b = b.replace(/'/g ,"");
      // replace all other punctuation with spaces
      a = a.replace(/\W/g," ");
      b = b.replace(/\W/g," ");
      // replace all multiple spaces with a single space
      a = a.replace(/\s+/g," ");
      b = b.replace(/\s+/g," ");
      // split into words
      awords = a.split(" ");
      bwords = b.split(" ");
      // perform the comparison
      var reply = false;
      for (var i=0; i<bwords.length; i++) {
        //GLog.write (standardize(awords[i])+"  "+standardize(bwords[i]))
        if (standardize(awords[i]) != standardize(bwords[i])) {reply = true}
      }
      //GLog.write(reply);
      return (reply);
    }

     function MostrarSugerencias4() {
		document.getElementById('msg_cat0').style.display="none"  ;
		document.getElementById("msg_cat0").innerHTML=''; 	
		
     	var search = document.getElementById("search").value ;
   		var busqueda_concreta = true;
		  if(!search){
			 busqueda_concreta = false;
			 search = document.getElementById("search").value ;     
		}
		if(search=="") return false;
		document.getElementById('msg_cat0').style.display=""  ; 
        geocoder.getLocations(search, function (result)
          {
            var pointSearch = null;	
            if (result.Status.code == G_GEO_SUCCESS) {
            	var encontrados= 0;   
              if (result.Placemark.length > 1) { //SI HA ENCONTRADO MAS DE UN RESULTADO 	  
                document.getElementById("msg_cat0").style.visibility='visible';	   
                document.getElementById("msg_cat0").innerHTML = "";            
                for (var i=0; i<result.Placemark.length; i++) {
                  	var p = result.Placemark[i].Point.coordinates;
                  	var es_direccion = result.Placemark[i].address;
                  	if(es_direccion.indexOf("Spain")>0){
                      es_direccion = es_direccion.replace('Spain','Espa&#241;a');
          						document.getElementById("msg_cat0").innerHTML+="<div class='resultDir'><a href='javascript:showAddressAux(" +p[1]+","+p[0]+")' target='_top'>"+ es_direccion +"</a><div>";                  
          						encontrados++;
          						if(!pointSearch){
          							pointSearch = p;
                        showAddressAux(pointSearch[1],pointSearch[0]); 
          						}
          					}
                }                
              }
              else { // SI SOLO HA ENCONTRADO UN RESULTADO
                document.getElementById("msg_cat0").innerHTML = "";                
                var es_direccion = result.Placemark[0].address;
                if(es_direccion.indexOf("Spain")>=0){
                  	es_direccion = es_direccion.replace('Spain','Espa&#241;a');                  
					           encontrados++;         
                	if (different(search, result.Placemark[0].address)) {                 
                  		var p = result.Placemark[0].Point.coordinates;
                  		document.getElementById("msg_cat0").innerHTML += "<div class='resultDir'><a href='javascript:showAddressAux(" +p[1]+","+p[0]+")'>"+ es_direccion+"</a></div>";
                	} else {
                  		var p = result.Placemark[0].Point.coordinates;
                  		document.getElementById("msg_cat0").innerHTML += "<div class='resultDir'><a href='javascript:showAddressAux(" +p[1]+","+p[0]+")'>"+ es_direccion+"</a></div>";
                  		showAddressAux(p[1],p[0]);
                	}
                }
              }
              document.getElementById('msg_cat0').style.display="none";
              if(encontrados==0){
              	if(!busqueda_concreta){
              		MostrarSugerencias(search + ", Spain");
              		return;
              	}
              	document.getElementById('msg_cat0').style.display="";
              	document.getElementById("msg_cat0").innerHTML = '<p>No se ha encontrado ninguna direcci&#243;n perteneciente a Espa&#241;a.</p>';                 	           		              	
              }
              else{
              	document.getElementById('msg_cat0').style.display="";
               }              
            }
            // ====== Decode the error status ======
            else {
              var reason="Codigo "+result.Status.code;
              if (reasons[result.Status.code]) {
                reason = reasons[result.Status.code]
              } 
              document.getElementById('msg_cat0').style.display="";
              document.getElementById("msg_cat0").innerHTML = '<p>No se ha encontrado ninguna direcci&#243;n.</p>'; 
            }
          }
        );
        
        //verXML();
      }
     function mostrarOcultarMenuOld(id) {
	 	if(document.getElementById(id)){
	  		if(document.getElementById(id).style.display=="none"){	 			
				if(document.getElementById("f_" + id)){
					document.getElementById("f_" + id).src="http://10.10.149.19:8080/geocultura4/images/fv.gif";
				}
				document.getElementById(id).style.display = "";
	  		}else{       			
				if(document.getElementById("f_" + id)){
					document.getElementById("f_" + id).src="http://10.10.149.19:8080/geocultura4/images/fh.gif";
				}
				document.getElementById(id).style.display = "none";
	   		}
     	}
    }	
    
    function mostrarOcultarMenu(id) {
	 var count=0;
	 var new_id;
	 while(document.getElementById("msg_cat" + count)){
	 	new_id = "msg_cat" + count;
	 	if(new_id==id){	 		
	  		if(document.getElementById(new_id).style.display=="none"){	 			
				if(document.getElementById("f_" + new_id)){
					document.getElementById("f_" + new_id).src="http://10.10.149.19:8080/geocultura4/images/fv.gif";
				}
				document.getElementById(new_id).style.display = "";
	  		}else{       			
				if(document.getElementById("f_" + new_id)){
					document.getElementById("f_" + new_id).src="http://10.10.149.19:8080/geocultura4/images/fh.gif";
				}
				document.getElementById(new_id).style.display = "none";
	   		}
     		}
     		else{
     			if(document.getElementById("f_" + new_id)){
					document.getElementById("f_" + new_id).src="http://10.10.149.19:8080/geocultura4/images/fh.gif";
				}
			document.getElementById(new_id).style.display = "none";
     		}
     		count++;
     	}
    }	


    function handleErrors(){
	   if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
	     alert("No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: " + gdir.getStatus().code);
	   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("An unknown error occurred.");	   
	}

	function onGDirectionsLoad(){ 
		// Use this function to access information about the latest load()
        // results.
	   	//document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
	  	// and yada yada yada...
	}

     function place(origen) {
	    document.getElementById("fromAddress").value = origen;
	     document.getElementById("message").innerHTML = "";
	     hay_origen =true;
	     Dir_correcta();
     }

     function placeDest(origen) {
	    document.getElementById("toAddress").value = origen;
	     document.getElementById("message_destino").innerHTML = "";
	     hay_destino =true;
	     Dir_correcta();
     }

    function setDirections(fromAddress, toAddress, locale) {
    document.getElementById("itinerario").style.display="";
    //getmenuname('menu3');
      gdir.load("from: " + fromAddress + " to: " + toAddress,
                { "locale": locale });
    }
    
    
    
    // ====== Geocoding ======
      function showAddressDest() {
        var searchDestino = document.getElementById("toAddress").value; 
        //if (searchDestino!="") searchDestino=searchDestino + ", Spain";    
        // ====== Perform the Geocoding ======        
        geo.getLocations(searchDestino, function (result)
          {
            //map.clearOverlays(); 

            if (result.Status.code == G_GEO_SUCCESS) {
              // ===== If there was more than one result, "ask did you mean" on them all =====
              if (result.Placemark.length > 1) { 
	            document.getElementById("details_258741").innerHTML ="";
                document.getElementById("message_destino").innerHTML = "<b>Las sugerencias son: <b></br></br>";
                // Loop through the results
                for (var i=0; i<result.Placemark.length; i++) {
                  var p = result.Placemark[i].Point.coordinates;
                  var dir = result.Placemark[i].address;
                  document.getElementById("message_destino").innerHTML += (i+1)+": <a style='font-size:13px;' href='javascript:placeDest(\""+dir+"\")'>"+ result.Placemark[i].address+"</a></br>";
                }
              }
              // ===== If there was a single marker, is the returned address significantly different =====
              else {
                document.getElementById("message_destino").innerHTML = "";
                if (different(searchDestino, result.Placemark[0].address)) {
                  document.getElementById("message_destino").innerHTML = "<b>El unico resultado de la consulta es: </b></br>";
                  var p = result.Placemark[0].Point.coordinates;
                  var dir = result.Placemark[0].address;
                  document.getElementById("message_destino").innerHTML += "<a href='javascript:placeDest(\""+dir+"\")'>"+ result.Placemark[0].address+"</a>";
                } else {
                  document.getElementById("message_destino").innerHTML = "<b>Punto geolocalizado</b></br>";
                	document.getElementById("toAddress").value = searchDestino;
	     		  	    hay_destino =true;
				        	Dir_correcta();
                }
              }
            }
            // ====== Decode the error status ======
            else {
              var reason="Codigo "+result.Status.code;
              if (reasons[result.Status.code]) {
                reason = reasons[result.Status.code]
              } 
              alert('Direccion Destino: "'+searchDestino+ '" ' + reason);
            }
          }
        );
      }

    
    // ====== Geocoding ======
      function showAddressOrigen() {
        var search = document.getElementById("fromAddress").value;
        //if (search!="") search=search + ", Spain";   
                 
        // ====== Perform the Geocoding ======        
        geo.getLocations(search, function (result)
          {
            //map.clearOverlays(); 

            if (result.Status.code == G_GEO_SUCCESS) {
              // ===== If there was more than one result, "ask did you mean" on them all =====
              if (result.Placemark.length > 1) { 
	            document.getElementById("details_25874").innerHTML ="";
                document.getElementById("message").innerHTML = "<b>Las sugerencias son: <b></br></br>";
                // Loop through the results
                for (var i=0; i<result.Placemark.length; i++) {
                  var p = result.Placemark[i].Point.coordinates;
                  var dir = result.Placemark[i].address;
                  document.getElementById("message").innerHTML += (i+1)+": <a style='font-size:13px;' href='javascript:place(\""+dir+"\")'>"+ result.Placemark[i].address+"</a></br>";
                }
              }
              // ===== If there was a single marker, is the returned address significantly different =====
              else {
                document.getElementById("message").innerHTML = "";
                if (different(search, result.Placemark[0].address)) {
                  document.getElementById("message").innerHTML = "<b>El único resultado de la consulta es: </b></br>";
                  var p = result.Placemark[0].Point.coordinates;
                  var dir = result.Placemark[0].address;
                  document.getElementById("message").innerHTML += "<a href='javascript:place(\""+dir+"\")'>"+ result.Placemark[0].address+"</a>";
                } else {
                  var p = result.Placemark[0].Point.coordinates;
                  var dir = result.Placemark[0].address;                  
                  //document.getElementById("fromAddress").value = result.Placemark[0].address;
                  document.getElementById("message").innerHTML = "<b>Punto geolocalizado</b></br>";
                  document.getElementById("fromAddress").value = search;
                  hay_origen=true;
			      Dir_correcta();
                  //document.getElementById("message").innerHTML += "<b>Resultado: </b>"+result.Placemark[0].address;
                }
              }
            }
            // ====== Decode the error status ======
            else {
              var reason="Codigo "+result.Status.code;
              
              if (reasons[result.Status.code]) {
                reason = reasons[result.Status.code]
              } 
              alert('Direccion Origen: "'+search+ '" ' + reason);              
            }
          }
        );
      }

	function Dir_correcta() { 

		var origen = document.getElementById("fromAddress").value;
		var destino = document.getElementById("toAddress").value;
		//var locale = document.getElementById("locale").value;
		locale="es";
		//alert("Origen:"+hay_origen);alert("Destino:"+hay_destino);
		if ((!hay_origen) || (!hay_destino)) {
			//alert('Dir NOO completa');
			if (!hay_origen)
				showAddressOrigen();
			if  (!hay_destino)
				showAddressDest();
		}
		else {
			//alert('Dir completa');
	    	setDirections(origen,destino , locale);
	    	hay_origen=false;
	    	hay_destino=false;
	    	}
	}
////////////////////////////////////		////////////////////////////////////
					// FIN SUGERENCIAS EN LAS BUSQUEDAS
////////////////////////////////////		/////////////////////////////////////


function showAddressAux(lat,lng) {
    //document.getElementById("msg_cat0").style.visibility='hidden';

	var point = new GLatLng(lat,lng);
	if(markerSearch){
		map.removeOverlay(markerSearch);
		markerSearch = null;
	}
	markerSearch = new GMarker(point);
	map.addOverlay(markerSearch);	
	map.setCenter(point, 15);

	map.enableContinuousZoom();
	map.enableDoubleClickZoom();
	map.enableScrollWheelZoom();

	//reconstruir_todo()

    
 }
 
 function mostrarRandom(lat,lng){
 	var point = new GLatLng(lat,lng);
	map.addOverlay(new GMarker(point));
 }
 
 function aleatorio(lat, lng, num){
 	
 	map.clearOverlays();
 	alert("Mostramos " + num);
 	for (var i = 0; i < num; i++) {
 		/*var point = new GLatLng(lat+(Math.random()/5),lng+(Math.random()/5));
		map.addOverlay(new GMarker(point));*/
		setTimeout("mostrarRandom(" + (lat+(Math.random()/5)) + "," + (lng+(Math.random()/5)) + ");",100);	
	}
	//alert("Fin de mostrar");	
 }
 
 function showPointAux(lat,lng) {
   	var point = new GLatLng(lat,lng);
   	var zoom = map.getZoom();

   	if (zoom>=17) zoom=17;
	else if(zoom>=15) zoom = zoom+1;
	else zoom=15;	
	map.setCenter(point, zoom);
	//map.enableContinuousZoom();
	//map.enableDoubleClickZoom();
	//map.enableScrollWheelZoom();    
 }
 
 function showMarker(marker) {
 	//alert(marker.name);
   	var point = marker.getLatLng();	
	map.setCenter(point, 15);
	map.enableContinuousZoom();
	map.enableDoubleClickZoom();
	map.enableScrollWheelZoom();  
	marker.openInfoWindow(marker.description);  
 }
 

function cargarPunto(){
	var cadena=document.location.search;
	if(cadena.indexOf("id=")>=0){
		var id = cadena.substring(cadena.indexOf("id=")+3);
		var cadenas = id.split("&");
		id = cadenas[0];
		verMarker(id);
	}
}
 
