//  CARREGANDO COMBOS 
function list_dados(valor) {
	http.open("GET", "seleciona_certidao.php?id=" + valor, true);
	http.onreadystatechange = handleHttpResponse;
	http.send(null);
}

function handleHttpResponse() {
	campo_select = document.forms[0].t_certidao;
	if (http.readyState == 4) {
		campo_select.options.length = 0;
		results = http.responseText.split(",");
		for (i = 0; i < results.length-1; i++) {
			string = results[i].split("|");
			campo_select.options[i] = new Option(string[0], string[1]);
		}
	}
}

function getHTTPObject() {
	var req;
	try {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			if (req.readyState == null) {
				req.readyState = 1;
				req.addEventListener("load", function() {
					req.readyState = 4;
					if (typeof req.onReadyStateChange == "function")
						req.onReadyStateChange();
				}, false);
			}
			return req;
		}

		if (window.ActiveXObject) {
			var prefixes = [ "MSXML2", "Microsoft", "MSXML", "MSXML3" ];
			for ( var i = 0; i < prefixes.length; i++) {
				try {
					req = new ActiveXObject(prefixes[i] + ".XmlHttp");
					return req;
				} catch (ex) {
				}
				;
			}
		}
	} catch (ex) {
	}
	alert("XmlHttp Objects not supported by client browser");
}
var http = getHTTPObject();
//CARREGANDO COMBOS



// UMA PAGINA DENTRO DE OUTRA
function ajax(url,dados)
{
	req = null;
	// Procura por um objeto nativo (Mozilla/Safari)
	if (window.XMLHttpRequest)
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = CarregaPagina;
		req.open("POST",url,true);
		
		//Send the proper header information along with the request
		req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		req.setRequestHeader("Content-length", dados.length);
		req.setRequestHeader("Connection", "close");
		
		req.send(dados);
	}
	// Procura por uma versão ActiveX (IE)
	else if (window.ActiveXObject)
	{
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req)
		{
			req.onreadystatechange = CarregaPagina;
			req.open("POST",url,true);
			
			//Send the proper header information along with the request
			req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			req.setRequestHeader("Content-length", dados.length);
			req.setRequestHeader("Connection", "close");
			
			req.send(dados);
		}
	}
}


function CarregaPagina()
{
	if (req.readyState == 1)
	{
		document.getElementById('pagina').innerHTML = '<b>Carregando Conteúdo - Aguarde...</b><br /><img src=imagens/spinner.gif />';
	}
	//else if (req.readyState == 2)
	//{
	//	document.getElementById('pagina').innerHTML = '';
	//}
	// apenas quando o estado for "completado"
	if (req.readyState == 4)
	{
		// apenas se o servidor retornar "OK"
		if (req.status ==200)
		{
			// procura pela div id="pagina" e insere o conteudo
			// retornado nela, como texto HTML
			document.getElementById('pagina').innerHTML = req.responseText;
		}
		else
		{
			alert("Houve um problema ao obter os dados:n" + req.statusText);
		}
	}
}
//UMA PAGINA DENTRO DE OUTRA
