function TAjax() {   this.conectar = function () {     this.http = null;     if (window.XMLHttpRequest) {       this.http = new XMLHttpRequest();     } else if (window.ActiveXObject) {       try {         this.http = new ActiveXObject("Msxml12.XMLHTTP");       } catch (e) {         try {           this.http = new ActiveXObject("Microsoft.XMLHTTP");         } catch (e) {}       }     }   } } function buscaEstados(codpai,codest,form) {     var selest = eval("document." + form + ".codest");     selest.options.length = 0;     var msg = new Option("aguarde","0",true,true);     selest.add(msg);     var selcid = eval("document." + form + ".codcid");     if (selcid) {selcid.options.length = 0}     var Ajax = new TAjax;       Ajax.conectar();       Ajax.http.onreadystatechange = carrega_regiao;       Ajax.http.open("POST","/scripts/rh.exe/xml_estados", true);       Ajax.http.send("codpai="+codpai);       function carrega_regiao() {         if (Ajax.http.readyState == 4) {           if (Ajax.http.status == 200) {             var xmldoc = Ajax.http.responseXML;             if (xmldoc.hasChildNodes()) {               var nos = xmldoc.getElementsByTagName("estado");               selest.options.length = 0;               for (var i = 0 ; i < nos.length ; i++ ) {                 var no = nos[i];                 var cod = no.childNodes[0].firstChild.nodeValue;                 var des = no.childNodes[1].firstChild.nodeValue;                 var sel = ( codest == cod ) ? true : false;                 var opt = new Option(des,cod,sel,sel);                 try {                   selest.add(opt);                 } catch (e) {                 }               }             }           }         }       } } function buscaCidades(codest,codcid,form) {     var selcid = eval("document." + form + ".codcid");     selcid.options.length = 0;     var msg = new Option("aguarde","0",true,true);     selcid.add(msg);     var Ajax = new TAjax;       Ajax.conectar();       Ajax.http.onreadystatechange = carrega_regiao;       Ajax.http.open("POST","/scripts/rh.exe/xml_cidades", true);       Ajax.http.send("codest="+codest);       function carrega_regiao() {         if (Ajax.http.readyState == 4) {           if (Ajax.http.status == 200) {             var xmldoc = Ajax.http.responseXML;             if (xmldoc.hasChildNodes()) {               var nos = xmldoc.getElementsByTagName("cidade");               selcid.options.length = 0;               for (var i = 0 ; i < nos.length ; i++ ) {                 var no = nos[i];                 var cod = no.childNodes[0].firstChild.nodeValue;                 var des = no.childNodes[1].firstChild.nodeValue;                 var sel = ( codcid == cod ) ? true : false;                 var opt = new Option(des,cod,sel,sel);                 try {                   selcid.add(opt);                 } catch (e) {                 }               }             }           }         }       } } function teste(codcli) {   if (codcli > 0) {     var Ajax = new TAjax;       Ajax.conectar();       Ajax.http.onreadystatechange = carrega;       Ajax.http.open("POST","http://www.webactions.com.br/scripts/pms.exe/lista_contatos", true);       Ajax.http.send("codcli="+codcli);       function carrega() {         if (Ajax.http.readyState == 4) {           if (Ajax.http.status == 200) {             var resultado = Ajax.http.responseText.split(";");             var msg = "";               for (var i = 0 ; i < resultado.length ; i++ ) {                 msg = msg + resultado[i] + "\n";               }               alert( msg );           }         }       }   } } 