// JavaScript Document
var xmlhttp;

function loadXMLDoc(valor)
{
if(valor!=undefined){

//id de la direccion
document.getElementById("idDir").value = valor;


xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=onResponse;
  xmlhttp.open("GET","cd_catalog.asp?valor="+valor,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Su navegador no soporta XMLHTTP.");
  }
}

function onResponse()
{
if(xmlhttp.readyState!=4) return;
if(xmlhttp.status!=200)
  {
  alert("Ha ocurrido un problema obteniedo los datos XML");
  return;
  }

x=xmlhttp.responseXML.documentElement.getElementsByTagName("DATOS");
for (i=0;i<x.length;i++)
  {
  xx=x[i].getElementsByTagName("direccion");
    {
    try
      {
	  //Nombre de la calle
	  document.getElementById("direccion").value = xx[0].firstChild.nodeValue
      }
    catch (er)
      {
      }
    }
  xx=x[i].getElementsByTagName("poblacion");
    {
    try
      {
	   document.getElementById("poblacion").value = xx[0].firstChild.nodeValue
      }
    catch (er)
      {
      }
    }
	
	
	xx=x[i].getElementsByTagName("cp");
	    {
    try
      {
	   document.getElementById("cp").value = xx[0].firstChild.nodeValue
      }
    catch (er)
      {
      }
    }
	
	

	
	xx =x[i].getElementsByTagName("codigoProvincia");

	    {
    try
      {
	  var codigoProvincia = xx[0].firstChild.nodeValue;
	  for(i=0; i<document.getElementById("lstProvincias").length; i++){
			if(document.getElementById("lstProvincias").options[i].value==codigoProvincia){
				document.getElementById("lstProvincias").selectedIndex=i;	
			}
		}
      }
    catch (er)
      {

      }
    }
		
  }
}
}

