 var HttpReq = null;
 var dest_combo = null;

 function ajaxComboBox(url, comboBox){
  	 dest_combo = comboBox;
    var indice = document.getElementById('categoria').selectedIndex;
    var sigla = document.getElementById('categoria').options[indice].getAttribute('value');
    url = url + '?categoriacd=' + 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 subcategoria = result.getElementsByTagName("nome");
        document.getElementById('subcategoria').innerHTML = "";
        for (var i = 0; i < subcategoria.length; i++) {
            new_opcao = create_opcao(subcategoria[i]);
            document.getElementById('subcategoria').appendChild(new_opcao);
        }
		LiberaCampos(1);
    }
 }

 function create_opcao(subcategoria) { 
    var new_opcao = document.createElement("option"); 
    var texto = document.createTextNode(subcategoria.childNodes[0].data); 
    new_opcao.setAttribute("value",subcategoria.getAttribute("id")); 
    new_opcao.appendChild(texto); //Adiciona o texto a OPTION.
    return new_opcao; // Retorna a nova OPTION.
}



function LiberaCampos(opcao){
	//alert(opcao);
	if(opcao == 1){
		document.getElementById("subcategoria").style.display = "block";
		document.getElementById("imgBuscar").style.display = "block";
	}else{
		document.getElementById("subcategoria").style.display = "none";
		document.getElementById("imgBuscar").style.display = "none";
	}
}
