﻿
function Selecionar() {
    url = '../interfaces/cidade.aspx?CodEstado=' + document.getElementById("ctl00_cphConteudo_estado").selectedIndex;
    if (window.ActiveXObject){
        xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.async=false;
        xmlDoc.load(url);
        carregaCidades();
    }
    else if (document.implementation && document.implementation.createDocument){
        xmlDoc=document.implementation.createDocument("","",null);
        xmlDoc.async=false;
        xmlDoc.load(url);
        xmlDoc.onload = carregaCidades();
    }
}


function carregaCidades() { 
    // Limpa o combo de cidades 
    var select = document.getElementById("cidade");
    while (select.length > 1)
        select.remove(1);

    var select = document.getElementById("cidade");
    var xml = xmlDoc.getElementsByTagName("Cidade");

    for(var i=0;i<xml.length;i++) {
        var opcao = xml[i];
        
        var id_opcao = opcao.getElementsByTagName("CodCidade")[0].firstChild.nodeValue;
        var ds_opcao = opcao.getElementsByTagName("Nome")[0].firstChild.nodeValue;

		select.options[select.options.length] = new Option(ds_opcao,id_opcao);
    }
}