var HttpReq = null;

var dest_combo = null;



function ajaxComboBox(url, comboBox, categoria_freela){

    dest_combo = comboBox;

	





	

    var indice = document.getElementById('estado').selectedIndex;

    var sigla = document.getElementById('estado').options[indice].getAttribute('value');

	

	

	

	 var categoria = document.getElementById('categoria_freela').selectedIndex;

    var categoria_freela = document.getElementById('categoria_freela').options[categoria].getAttribute('value');

	

	 var esp_indice = document.getElementById('especialidades').selectedIndex;

    var esp_nome = document.getElementById('especialidades').options[esp_indice].getAttribute('value');















if (esp_nome=="especialidades") {

	

esp_nome = "";	

	}

    url = url + '?estado=' + sigla + '&categoria_freela=' + categoria_freela + '&esp='+esp_nome;

	



    if (document.getElementById) { //Verifica se o Browser suporta DHTML.

        if (window.XMLHttpRequest) {

            HttpReq = new XMLHttpRequest();

			

			

			

				if (HttpReq.readyState!="4"){  

			

			

		document.getElementById('carregando').style.visibility='visible'; 

			

				}



            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_preserva(url, comboBox, categoria_freela, conserva){

    dest_combo = comboBox;

	





	

    var indice = document.getElementById('estado').selectedIndex;

    var sigla = document.getElementById('estado').options[indice].getAttribute('value');

	

	

	

	 var categoria = document.getElementById('categoria_freela').selectedIndex;

    var categoria_freela = document.getElementById('categoria_freela').options[categoria].getAttribute('value');

	

	 var esp_indice = document.getElementById('especialidades').selectedIndex;

    var esp_nome = document.getElementById('especialidades').options[esp_indice].getAttribute('value');















if (esp_nome=="especialidades") {

	

esp_nome = "";	

	}

    url = url + '?estado=' + sigla + '&categoria_freela=' + categoria_freela + '&esp='+esp_nome+'&conserva='+conserva;

	






    if (document.getElementById) { //Verifica se o Browser suporta DHTML.

        if (window.XMLHttpRequest) {

            HttpReq = new XMLHttpRequest();

			

			

			

				if (HttpReq.readyState!="4"){  

			

			

		document.getElementById('carregando').style.visibility='visible'; 

			

				}

			

			

			

			

			

            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_refaz(url, comboBox, categoria_freela){

    dest_combo = comboBox;

	

	



	

    var indice = document.getElementById('especialidades').selectedIndex;

    var sigla = document.getElementById('especialidades').options[indice].getAttribute('value');

	



	

	 var categoria = document.getElementById('categoria_freela').selectedIndex;

    var categoria_freela = document.getElementById('categoria_freela').options[categoria].getAttribute('value');

	 

	



    url = url + '?estado=' + sigla + '&categoria_freela=' + categoria_freela;







    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 ajaxComboBox2(url, comboBox, categoria_freela){

    dest_combo = comboBox;

	

	



	

    var indice = document.getElementById('estado').selectedIndex;

    var sigla = document.getElementById('estado').options[indice].getAttribute('value');

	

		 var categoria = document.getElementById('categoria_freela').selectedIndex;

    var categoria_freela = document.getElementById('categoria_freela').options[categoria].getAttribute('value');

	

		 var cidades_1 = document.getElementById('cidades').selectedIndex;

    var cidades_2 = document.getElementById('cidades').options[cidades_1].getAttribute('value');

	

	



    url = url + '?estado=' + sigla + '&categoria_freela=' + categoria_freela + '&cid=' +cidades_2 ;



	

    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){  //Verifica se o arquivo foi carregado com sucesso.

        

		document.getElementById('carregando').style.visibility='hidden'; 

	

		

		var result = HttpReq.responseXML;

		//document.getElementById(palavras).innerHTML = "Pais";

		

        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 XMLHttpRequestChange2() {

    if (HttpReq.readyState == 4 && HttpReq.status == 200){  //Verifica se o arquivo foi carregado com sucesso.

        var result = HttpReq.responseXML;

	

	document.getElementById('carregando').style.visibility='hidden'; 



		

        var cidades2 = result.getElementsByTagName("nome");

        document.getElementById(cidade2).innerHTML = "";

	

        for (var i = 0; i < cidades2.length; i++) {

            new_opcao = create_opcao2(cidades2[i]);

            document.getElementById(cidade2).appendChild(new_opcao);

        }

    }

}











function create_opcao(cidade) { //Cria um novo elemento OPTION.

    //return opcao.cloneNode(true);

    var new_opcao = document.createElement("option"); //Cria um OPTION.

    var texto = document.createTextNode(cidade.childNodes[0].data); //Cria um texto.

    new_opcao.setAttribute("value",cidade.getAttribute("value")); //Adiciona o atributo de valor a nova opção.

    new_opcao.appendChild(texto); //Adiciona o texto a OPTION.

    return new_opcao; // Retorna a nova OPTION.

}









function create_opcao2(cidade2) { //Cria um novo elemento OPTION.

    //return opcao.cloneNode(true);

    var new_opcao = document.createElement("option"); //Cria um OPTION.

    var texto = document.createTextNode(cidade2.childNodes[0].data); //Cria um texto.

    new_opcao.setAttribute("value",cidade2.getAttribute("value")); //Adiciona o atributo de valor a nova opção.

    new_opcao.appendChild(texto); //Adiciona o texto a OPTION.

    return new_opcao; // Retorna a nova OPTION.

}















function ajaxComboBox_2(url, comboBox, categoria_freela, atual){

    dest_combo = comboBox;

	

	



	

    var indice = document.getElementById('estado').selectedIndex;

    var sigla = document.getElementById('estado').options[indice].getAttribute('value');

	

	

	

	 var categoria = document.getElementById('categoria_freela').selectedIndex;

    var categoria_freela = document.getElementById('categoria_freela').options[categoria].getAttribute('value');

	

	

	

    var esp_nome = document.getElementById('especialidades').value;







    url = url + '?estado=' + sigla + '&categoria_freela=' + categoria_freela+ '&cid=' + atual + '&esp=' +esp_nome ;



	

    if (document.getElementById) { //Verifica se o Browser suporta DHTML.

        if (window.XMLHttpRequest) {

            HttpReq = new XMLHttpRequest();

			

			

			

				if (HttpReq.readyState!="4"){  

			

			

		document.getElementById('carregando').style.visibility='visible'; 

			

				}

			

			

			

			

			

            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();

            }

        }

    }

}











