function checkForInt(evt) {
  //notice that the check is != null now, as the tab key has a value of 0
  var charCode = ( evt.which != null ) ? evt.which : event.keyCode
  //charCodes < 32 include tab, delete, arrow keys, etc
  return (charCode < 32 || (charCode >= 48 && charCode <= 57))
};


//Crea objeto AJAX
function http_request() {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest();
    }
    return xmlhttp
};

function buscacompania(){
  var contenedor;
  var numero_celular;

  contenedor = document.getElementById('resultado_celular');
  numero_celular = document.getElementById('celular-field').value;
  
  if (numero_celular.length < 8){
    alert("El número debe contener 8 digitos");
    return true;
  }
  ajax=http_request();

  ajax.open("GET", "av-modules/microservicios/busca_celular/busca_telco.php?celular="+numero_celular, true);

  ajax.onreadystatechange=function() {
    if (ajax.readyState==1)
    {
      contenedor.innerHTML = '<img src="../../av-includes/images/proceso.gif" />';
    }
    else if(ajax.readyState==4)
    {
      if(ajax.status==200)
      {
        contenedor.innerHTML = ajax.responseText;
      }
      else
      {
        contenedor.innerHTML = "Error: ";
      }
    }
  }

   ajax.send(null)
};
