
function criaXMLHttpRequest()
{
var XMLHTTPREQUEST_IE = new Array(
  "Msxml2.XMLHTTP.6.0",
  "Msxml2.XMLHTTP.5.0",
  "Msxml2.XMLHTTP.4.0",
  "Msxml2.XMLHTTP.3.0",
  "Msxml2.XMLHTTP",
  "Microsoft.XMLHTTP"
);
  var oXMLhttp = null;

  // Cria o HttpRequest para o respectivo navegador.
  if (window.XMLHttpRequest != null)
    oXMLhttp = new window.XMLHttpRequest();
  else if (window.ActiveXObject != null)
  {
    // Percorre no IE a procura do objeto ActiveX na biblioteca mais recente
    var bCriado = false;
    for (var ind = 0;
         ind < XMLHTTPREQUEST_IE.length && ! bCriado; ind++)		
    {
      try
      {
        oXMLhttp = new ActiveXObject(XMLHTTPREQUEST_IE[ind]);
        bCriado = true;
      }
      catch (ex)
      {}
    }
  }

  // Tratamento de erro caso não encontre nenhum.
  if (oXMLhttp == null)
    alert("Falha no HttpRequest():\n\n"
      + "Objeto XMLHttpRequest não foi criado.");

  // Retorna o objeto instanciado ou não
  return oXMLhttp;
}


var oAjax = criaXMLHttpRequest();
function escrevemensagem(sMsg) {
document.getElementById('respostafinal').innerHTML = sMsg;
}

function ChecaDominio() {
var Dominio = document.getElementById('Dominio');
var ExtDominio = document.getElementById('extensaodominio');
var sURL = "dominio.php?dominio=" + Dominio.value + ExtDominio.value ;
oAjax.open("GET", sURL, true);
oAjax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
oAjax.onreadystatechange = trataHttpResponse;
oAjax.send(null);
}

function trataHttpResponse() {

var exibeResultado = document.getElementById('respostafinal');
exibeResultado.style.display='';

if(oAjax.readyState == 2 || oAjax.readyState == 3 || oAjax.readyState == 1) {
                                exibeResultado.innerHTML = "<div id='carregando'><img src='ajax-loader.gif' alt='Carregando' />Pesquisando....</div>";
} else {

if(oAjax.readyState == 4) {
                                if(oAjax.status == 200) {
                                        var resultado = oAjax.responseText;
                                        exibeResultado.innerHTML = resultado;
                                } else {
                                        exibeResultado.innerHTML = "Ocorreu um erro. Tente novamente mais tarde. ";
                                }
                         } 
						 }
}



