 var HttpReq = null;
 var dest_combo = null;

 function ajaxComboBox2(url, FlagValor ,comboBox){
  	 dest_combo = comboBox;

	    var indice = 0;
	    var sigla = FlagValor;

    url = url + '?id=' + sigla;
    if (document.getElementById) { //Verifica se o Browser suporta DHTML.
        if (window.XMLHttpRequest) {
            HttpReq = new XMLHttpRequest();
            HttpReq.onreadystatechange = XMLHttpRequestChange;
            HttpReq.open("GET", url, true);
            HttpReq.send(null);
        } else if (window.ActiveXObject) {
            HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            if (HttpReq) {
                HttpReq.onreadystatechange = XMLHttpRequestChange;
                HttpReq.open("GET", url, true);
                HttpReq.send();
            }
        }
    }
 }


 function ajaxComboBox(url, OrigemID ,comboBox){
  	 dest_combo = comboBox;

	    var indice = document.getElementById(OrigemID).selectedIndex;
	    var sigla = document.getElementById(OrigemID).options[indice].getAttribute('value');

    url = url + '?id=' + sigla;
    if (document.getElementById) { //Verifica se o Browser suporta DHTML.
        if (window.XMLHttpRequest) {
            HttpReq = new XMLHttpRequest();
            HttpReq.onreadystatechange = XMLHttpRequestChange;
            HttpReq.open("GET", url, true);
            HttpReq.send(null);
        } else if (window.ActiveXObject) {
            HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            if (HttpReq) {
                HttpReq.onreadystatechange = XMLHttpRequestChange;
                HttpReq.open("GET", url, true);
                HttpReq.send();
            }
        }
    }
 }

 function XMLHttpRequestChange() {
    if (HttpReq.readyState == 4 && HttpReq.status == 200){
        var result = HttpReq.responseXML;
        var cidades = result.getElementsByTagName("nome");
        document.getElementById(dest_combo).innerHTML = "";
        for (var i = 0; i < cidades.length; i++) {
            new_opcao = create_opcao(cidades[i]);
            document.getElementById(dest_combo).appendChild(new_opcao);
        }
    }
 }

 function create_opcao(cidade) { 
    var new_opcao = document.createElement("option");
    var texto = document.createTextNode(cidade.childNodes[0].data); 
    new_opcao.setAttribute("value",cidade.getAttribute("id")); 
    new_opcao.appendChild(texto); //Adiciona o texto a OPTION.
    return new_opcao; // Retorna a nova OPTION.
 }

 function ajaxRespostaNA(url, sigla ,comboBox){
  	 dest_combo = comboBox;

    url = url + '?id=' + sigla;
    if (document.getElementById) { //Verifica se o Browser suporta DHTML.
        if (window.XMLHttpRequest) {
            HttpReq = new XMLHttpRequest();
            HttpReq.onreadystatechange = XMLHttpRequestChange2;
            HttpReq.open("GET", url, true);
            HttpReq.send(null);
        } else if (window.ActiveXObject) {
            HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            if (HttpReq) {
                HttpReq.onreadystatechange = XMLHttpRequestChange2;
                HttpReq.open("GET", url, true);
                HttpReq.send();
            }
        }
    }
 }


function ajaxTexto(url, OrigemID ,comboBox){
  	 dest_combo = comboBox;

	    var indice = document.getElementById(OrigemID).selectedIndex;
	    var sigla = document.getElementById(OrigemID).options[indice].getAttribute('value');

    url = url + '?id=' + sigla;
    if (document.getElementById) { //Verifica se o Browser suporta DHTML.
        if (window.XMLHttpRequest) {
            HttpReq = new XMLHttpRequest();
            HttpReq.onreadystatechange = XMLHttpRequestChange2;
            HttpReq.open("GET", url, true);
            HttpReq.send(null);
        } else if (window.ActiveXObject) {
            HttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            if (HttpReq) {
                HttpReq.onreadystatechange = XMLHttpRequestChange2;
                HttpReq.open("GET", url, true);
                HttpReq.send();
            }
        }
    }
 }

 function XMLHttpRequestChange2() {
    if (HttpReq.readyState == 4 && HttpReq.status == 200){
        var result = HttpReq.responseText;
	document.getElementById(dest_combo).innerHTML = result;
    }
 }


