                        function getXmlHttpRequestObject() {
				if (window.XMLHttpRequest) {
					return new XMLHttpRequest(); //Not IE
				} else if(window.ActiveXObject) {
					return new ActiveXObject("Microsoft.XMLHTTP"); //IE
				} else {
					//Display your error message here. 
					//and inform the user they might want to upgrade
					//their browser.
					alert("Your browser doesn't support the XmlHttpRequest object.  Better upgrade to Firefox.");
				}
			}			
			//Get our browser specific XmlHttpRequest object.
			var receiveReq = getXmlHttpRequestObject();		
			//Initiate the asyncronous request.
			function rellenar(valor) {
                                document.getElementById('cat2').innerHTML = '';
                                document.getElementById('cat3').innerHTML = '';
				//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
				if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
					//Setup the connection as a GET call to SayHello.html.
					//True explicity sets the request to asyncronous (default).
					receiveReq.open("GET", 'aca/obtenerResultado?func='+valor, true);
					//Set the function that will be called when the XmlHttpRequest objects state changes.
					receiveReq.onreadystatechange = rellenarCuadro2; 
					//Make the actual request.
					receiveReq.send(null);
				}			
			}
			//Called every time our XmlHttpRequest objects state changes.
			function rellenarCuadro2() {
				//Check to see if the XmlHttpRequests state is finished.
				if (receiveReq.readyState == 4) {
					//Set the contents of our span element to the result of the asyncronous call.
					document.getElementById('cat1').innerHTML = receiveReq.responseText;
				}
			}
  			function movilesCliente(valor) {
				//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
				if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
					//Setup the connection as a GET call to SayHello.html.
					//True explicity sets the request to asyncronous (default).
					receiveReq.open("GET", 'aca/rellenarMovilesCliente?idc='+valor, true);
					//Set the function that will be called when the XmlHttpRequest objects state changes.
					receiveReq.onreadystatechange = rellenarMovilesCliente; 
					//Make the actual request.
					receiveReq.send(null);
				}			
			}
			//Called every time our XmlHttpRequest objects state changes.
			function rellenarMovilesCliente() {
				//Check to see if the XmlHttpRequests state is finished.
				if (receiveReq.readyState == 4) {
					//Set the contents of our span element to the result of the asyncronous call.
					document.getElementById('cat3').innerHTML = receiveReq.responseText;
				}
			}

                        function movilesCategoria(valor) {
				//If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call.
				if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
					//Setup the connection as a GET call to SayHello.html.
					//True explicity sets the request to asyncronous (default).
					receiveReq.open("GET", 'aca/rellenarMovilesPorCategoria?idc='+valor, true);
					//Set the function that will be called when the XmlHttpRequest objects state changes.
					receiveReq.onreadystatechange = rellenarMovilesPorCategoria; 
					//Make the actual request.
					receiveReq.send(null);
				}			
			}
			//Called every time our XmlHttpRequest objects state changes.
			function rellenarMovilesPorCategoria() {
				//Check to see if the XmlHttpRequests state is finished.
				if (receiveReq.readyState == 4) {
					//Set the contents of our span element to the result of the asyncronous call.
					document.getElementById('cat2').innerHTML = receiveReq.responseText;
				}
			}
 
                       function obtenersubcat(valor, subcat) {

				if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {
                                        
                                        if(subcat=='0') {
					      //receiveReq.open("GET", 'aca/rellenarLugaresPorCategoria?idc='+valor, true);
                                              //alert("Vale 0");
                                              //deberia tambien llamar a rellenar el mapa
                                              
                                        }
                                        else {
                                              //TODO
                                              alert("No implementado aśn");
                                        }
					//Set the function that will be called when the XmlHttpRequest objects state changes.
					receiveReq.onreadystatechange = rellenarLugaresPorCategoria; 
					//Make the actual request.
					receiveReq.send(null);
				}			
			}

			//Called every time our XmlHttpRequest objects state changes.
			function rellenarLugaresPorCategoria() {
				//Check to see if the XmlHttpRequests state is finished.
				if (receiveReq.readyState == 4) {
					//Set the contents of our span element to the result of the asyncronous call.
					document.getElementById('cat2').innerHTML = receiveReq.responseText;
				}
			}



                       function mostrarSubCat(valor, subcat)
                        {
                              if(subcat=='0') {
                                      cargarxml('aca/lugares.xml?ide=' + valor,14);
                              }
                              else {
                                      obtenersubcat(valor, subcat);
                              }
                        }
                        function mostrarGpsPorId(id)
                        {
                            cargarxml("aca/gps.xml?ide="+id,14);
                        }

                        function mostrarGpsPorCliente(id)
                        {
                            cargarxml("aca/gps_cliente.xml?ide="+id,10);
                        }
                        function mostrarGpsPorCat(id)
                        {
                            cargarxml("aca/gps.xml?ide="+id,10);
                        }
    function showAddress(address) {
      geocoder = new GClientGeocoder();
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 14);
              var marker = new GMarker(point);
              map.addOverlay(marker);
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }

      function mostrarCargando()
      {
        div = document.getElementById("cargando");
        div.style.visibility ='visible';
        div.style.display = 'block';
      }
      function esconderCargando()
      {
        div = document.getElementById("cargando");
        div.style.visibility ='hidden';
        div.style.display = 'none';
      }

