// JavaScript Document
function setEnquete(tipo){
	var resp = document.getElementById('resp').value;
	var idenq = document.getElementById('idref').value;
	nav.open('GET','enquete.php?opt='+resp+'&idref='+idenq,true);
	nav.onreadystatechange = function(){
	if (nav.readyState==4){
	window.open('paginas/enquete_resul.php?id='+idenq+'&tipo='+tipo,'Enquete','width=360,height=340');
	}
}
	nav.send(null);
}

function getBairro(cit){
	nav.open("GET","getBairro.php?cit="+cit,true);
	nav.onreadystatechange=fazBairro;
	nav.send(null);
}

function getValor(val){
	nav.open("GET","getValor.php?val="+val, true);
	nav.onreadystatechange = fazValor;
	nav.send(null);
}

function fazValor(){
	var v = document.getElementById('valores');
		result = nav.responseText;
		v.innerHTML = result;
}

function fazBairro(){
	campo=document.formbusca.bairro;
	if (nav.readyState==4){
		campo.options.length=1;
		resultado = nav.responseText.split(",");
		for (i=0; i<(resultado.length-1); i++){
			string = resultado[i].split( "|" );
			campo.options[i] = new Option( string[0], string[1]);
		}
	}
}

function getAjax(){
	var ajax = null;
	try{
		ajax = new XMLHttpRequest();
	}catch(e){
		try{
			ajax = new ActiveXObject("Microsoft.XMLHttp");
		}catch(e){
			try{
				ajax = new ActiveXObject("MSXML2.XMLHttp");
			}catch(e){
				alert("Seu navegador não suporta AJAX");
			}
		}
	}
	return ajax;
}


nav = getAjax();

