var READY_STATE_UNINITIALIZED = 0;
var READY_STATE_LOADING = 1;
var READY_STATE_LOADED = 2;
var READY_STATE_INTERACTIVE = 3;
var READY_STATE_COMPLETE = 4;
function _createXML() {
var xml= null;
if (window.XMLHttpRequest) {
xml = new XMLHttpRequest();} else if (window.ActiveXObject) {
var progIDs = ["MSXML2.XMLHTTP.6.0",
"MSXML2.XMLHTTP.4.0",
"MSXML2.XMLHTTP.3.0",
"MSXML2.XMLHTTP",
"Microsoft.XMLHTTP"];
for (var i = 0; xml== null && i < progIDs.length; i++) {
xml= new ActiveXObject(progIDs[i]);}}
return xml;}/********************************************************************
FUNÇÃO PADRÃO DE ESPERA********************************************************************/
function _esperar(value, div){
if (value){
if(document.getElementById(div)!=null){
document.getElementById(div).innerHTML = "<img src='util/img/loading.gif' border='0'> AGUARDE...";}
else
if (document.getElementById("fncesperar") == null){
var scrTop = parseInt(document.body.scrollTop);
b=document.createElement("DIV");
b.id="fncEsperar";
b.style.top = scrTop+"px";
b.style.right = "20px";
b.innerHTML = "<img src='util/img/loading.gif' border='0'> AGUARDE...";
document.body.appendChild(b);}}else{
if (document.getElementById("fncesperar") != null)
document.body.removeChild(document.body.children("fncesperar"));
if(document.getElementById(div) !=null)
document.getElementById(div).innerHTML = "";}}/********************************************************************
FUNÇÃO QUE ENVIA UMA REQUISIÇÃO ATRAVES DO XMLHTTP********************************************************************/
function _send(metodo, pagina, parametros, metodoCallback){
if (this._carregando){
alert("Aguarde um momento, uma requisição já foi solicitada.");
return false;}
if (this.xmlHTTP==null){
alert("Objeto não instanciado.");}
else{
if (pagina == "" || pagina == null){
alert("Deve ser informado uma página para requisiçao.");
return false;}
if (parametros == "" ||parametros==null){
parametros = null}else{
parametros = parametros.replace(/ /g, "%20");}
metodo = metodo.toUpperCase();
if (metodo == "") metodo = "POST";
if (metodo != "POST" && metodo != "GET"){
alert("Por favor informar o médoto correto. \n POST ou GET).");
return false;}
this.xmlHTTP.onreadystatechange = metodoCallback;
this.xmlHTTP.open(metodo, pagina, true);
this.xmlHTTP.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
this._carregando = true;
try{
this.xmlHTTP.send(parametros);}
catch(E){
if (this.esperar != null) this.esperar(false);
this._carregando = false;}}}/********************************************************************
CLASSE AJAX********************************************************************/
function clsAjax(){
this._carregando = false;
this.esperar= _esperar;
this.xmlHTTP;
this.send = _send;
this.createXML = _createXML;}
