// JavaScript para validar la consulta
//funcion para volver los campos a mayusculas
//*************************************funciones para llenar los municipios*********************************************************
var http; var idControl; 
var estado; var municipio; ; var pais; 
function Query(id, archivo,  pais1, estado1, municipio1){
  http = getXmlHttpObject();
  http.open("GET", archivo, true);
  idControl=id; estado=estado1; municipio=municipio1; pais=pais1; 
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

function getXmlHttpObject(){
  var xmlhttp;
     try{
	    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
	 catch (e){
	    try{
		   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
		catch (e){
		   try{
		      xmlhttp = new XMLHttpRequest();}
		   catch (e){
		      xmlhttp = false;
			  alert('error');
		   }
		 }
	   }
	return xmlhttp;
}

function handleHttpResponse(){
   if (http.readyState==1) {
	 // document.getElementById(control_reg).value=0; document.getElementById(control_reg).disabled = true;
	  //document.getElementById(img_reg).style.visibility = "hidden";
  }else if (http.readyState == 4){
     results = http.responseText;
	 document.getElementById(idControl).innerHTML=results;
	 habilitar(); }
}

//deshabilita o habilita el select de regiones
function habilitar(){
  if (document.getElementById(pais).value==0){ document.getElementById(estado).disabled = true; 
  }
  else{ 
    document.getElementById(estado).disabled = false;
  }
  document.getElementById(municipio).value="0"; document.getElementById(municipio).disabled=true;
}

//**********************************************funciones para llenar los municipios***********************************************
var http2; var idControl2;
var estado2; var municipio2;  var comunidad2; 

function Query2(id22, archivo22, estado22, municipio22){  
  http2 = getXmlHttpObject2();
  http2.open("GET", archivo22, true);
  idControl2=id22; estado2=estado22; municipio2=municipio22;  
  http2.onreadystatechange = handleHttpResponse2;
  http2.send(null);
}

function getXmlHttpObject2(){
  var xmlhttp2;
     try{
	    xmlhttp2 = new ActiveXObject("Msxml2.XMLHTTP");}
	 catch (e){
	    try{
		   xmlhttp2 = new ActiveXObject("Microsoft.XMLHTTP");}
		catch (e){
		   try{
		      xmlhttp2 = new XMLHttpRequest();}
		   catch (e){
		      xmlhttp2 = false;
			  alert('error');
		   }
		 }
	   }
	return xmlhttp2;
}

function handleHttpResponse2(){
   if (http2.readyState==1) {
	 // document.getElementById(loc2).value=0; document.getElementById(loc2).disabled = true;
	  //document.getElementById(imgloc2).style.visibility="hidden";
  }else if (http2.readyState == 4){
     results2 = http2.responseText;
	 document.getElementById(idControl2).innerHTML=results2; 
	 habilitar2(); }
}

//deshabilita o habilita el select de municipios 
function habilitar2(){
  if (document.getElementById(estado2).value==0){	document.getElementById(municipio2).disabled=true; 	
  }
  else{
	document.getElementById(municipio2).disabled=false; 
  }
}

