// JavaScript Document
//=================================================================
var xmlhttp

function estados(str,pos) {
	document.getElementById('municipios').style.display = 'none';
	if (str.length==0) {
		document.getElementById("municipio").innerHTML="";
		return;
	}
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Seu navegador não suporta XMLHTTP!");
		return;
	}
	var url="getEstado.php";
	url=url+"?e="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	document.body.style.cursor = 'wait';
}

function stateChanged(){
	if (xmlhttp.readyState==4){
		document.getElementById("municipio").innerHTML=xmlhttp.responseText;
	}
	document.body.style.cursor = 'auto';
}

function estados_ent(str) {
	document.getElementById('municipios_ent').style.display = 'none';
	if (str.length==0) {
		document.getElementById("municipio_ent").innerHTML="";
		return;
	}
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null){
		alert ("Seu navegador não suporta XMLHTTP!");
		return;
	}
	var url="getEstado.php";
	url=url+"?m="+str;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=stateChangedMun;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	document.body.style.cursor = 'wait';
}
// Exibe o resultado de municípios
function stateChangedMun(){
	if (xmlhttp.readyState==4){
		document.getElementById("municipio_ent").innerHTML=xmlhttp.responseText;
	}
	document.body.style.cursor = 'auto';
}
// Verifica se o browser suporta
function GetXmlHttpObject(){
	if (window.XMLHttpRequest){
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject){
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

