function setdigital()
{
  carregar_uf("digital");
}

function setconvencional()
{ 
  carregar_uf("convencional");
}


function carregar_uf(tipo)
{
    document.getElementById("div_cidade").innerHTML = "<div class='defaultParagraph first' id='div_cidade'><p class='first'><select name='cid' onChange='setbusca()' class='input'><option value=''>Selecione</option></select></p></div>";    
    
    if (window.XMLHttpRequest) XMLHttp = new XMLHttpRequest();
    if (window.ActiveXObject)  XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");

    if (XMLHttp)
      {
        XMLHttp.open("GET", "/lojas/asp/lista_uf.asp?tipo=" + tipo, true);
        XMLHttp.onreadystatechange = function ()
          {
            if (XMLHttp.readyState == 1)
              {
                document.getElementById("div_uf").innerHTML = "Carregando...";
              }
            if (XMLHttp.readyState == 4)
              {
                if (XMLHttp.status == 200)
                  {
                    document.getElementById("div_uf").innerHTML = XMLHttp.responseText;
                  }
                else
                  {
                    document.getElementById("div_uf").innerHTML = "Erro!";
                  }
              }
          }
        XMLHttp.send(null);
      }
        
  }
  

function setcidade(tipo, uf)
{
  carregar_cidade(tipo, uf);  
}

function setbairro(tipo, uf, cidade)
{  
  carregar_bairro(tipo, uf , cidade);  
}


function carregar_cidade(tipo, uf)
{
    if (window.XMLHttpRequest) XMLHttp = new XMLHttpRequest();
    if (window.ActiveXObject)  XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");

    if (XMLHttp)
      {
        XMLHttp.open("GET", "/lojas/asp/lista_cidade.asp?tipo=" + tipo + "&uf=" + uf, true);
        XMLHttp.onreadystatechange = function ()
          {
            if (XMLHttp.readyState == 1)
              {
                document.getElementById("div_cidade").innerHTML = "Carregando...";
              }
            if (XMLHttp.readyState == 4)
              {
                if (XMLHttp.status == 200)
                  {
                    document.getElementById("div_cidade").innerHTML = XMLHttp.responseText;
                  }
                else
                  {
                    document.getElementById("div_cidade").innerHTML = "Erro!";
                  }
              }
          }
        XMLHttp.send(null);
      }
        
  }
  

function carregar_bairro(tipo, uf, cidade)
{
    if (window.XMLHttpRequest) XMLHttp = new XMLHttpRequest();
    if (window.ActiveXObject)  XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");

    if (XMLHttp)
      {        
        XMLHttp.open("GET", "/lojas/asp/lista_bairro.asp?tipo=" + tipo + "&uf=" + uf + "&cid=" + cidade, true);
        XMLHttp.onreadystatechange = function ()
          {
            if (XMLHttp.readyState == 1)
              {
                document.getElementById("div_bairro").innerHTML = "Carregando...";
              }
            if (XMLHttp.readyState == 4)
              {
                if (XMLHttp.status == 200)
                  {
                    document.getElementById("div_bairro").innerHTML = XMLHttp.responseText;
                  }
                else
                  {
                    document.getElementById("div_bairro").innerHTML = "Erro!";
                  }
              }
          }
        XMLHttp.send(null);
      }
        
}