function getHTTPObject() {
 var xmlhttp = null;
 if (typeof XMLHttpRequest != 'undefined') {  // if ECMA version of object is available
  try {    
    xmlhttp = new XMLHttpRequest();          // instantiate it
  } catch (err) {
    alert("Error initializing XMLHttpRequest.\n"+
          err); // show error
  }
  } else {                                     // else assume this is IE and
   var msobj = new Array("Msxml2.XMLHTTP.6.0",
                        "Msxml2.XMLHTTP.4.0",
                        "Msxml2.XMLHTTP.3.0",
                        "Msxml2.XMLHTTP",
                        "Microsoft.XMLHTTP");
   var x, len = msobj.length;
   for(x=0; x<len; ++x) {                     // try each MS ActiveX object in turn
     try {
      xmlhttp = new ActiveXObject(msobj[x]);
      break;
     } catch (err) {};
   }
 }
 return xmlhttp; 
} 


function mostrarContenidoDiv(id,mensaje) {
	document.getElementById(id).innerHTML = mensaje;
}

function mostrarContenido(id) {	
	switch (id) {
	case 0:		
                var http = getHTTPObject(); // We create the HTTP Object 
                http.open("GET", "includes/mapa.php?op=1", false); 
		http.onreadystatechange = function(){
                  if (http.readyState == 4) {
                    mostrarContenidoDiv('derecha',http.responseText);
                  }
                };
		http.send(null);
                //document.getElementById("jscript").src = "includes/mapa.php?op=0";
		break;
	}
}



function buscarDireccion(dire) {  
  //LEER EL FICHERO
  var direccion = "http://juaxix.trap17.net/localiza.php?a=" +  escape(dire);
  document.getElementById('jscript').src = direccion;  
  document.getElementById('derecha').innerHTML = "Realizando la b&uacute;squeda,espere por favor...";
  setTimeout('leerXML()',5000);
}

function leerXML(){
var xmlhttp = getHTTPObject();
  try {
    xmlhttp.open("GET", "includes/filtrado.php", true);
  } catch (err) {
    alert("XMLHttpRequest.open() ha fallado.Añada este sitio a sus sitios de confianza para realizar búsquedas!.\n"+
          err);
    return;
  }
  xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
    //escape(dire)
    document.getElementById("derecha").innerHTML = xmlhttp.responseText;
   }
  }
  xmlhttp.send(null);
  //POSICIONAR EN EL MAPA:
  document.getElementById('jscript').src = 'includes/mapa.php?op=2';
}

