/* Repositório de funções utilizadas em aplicaçõs*/
var req; 

/* 	Gera uma nova instância de xmlHttpRequest */
function fXmlHttpRequest(){
	if (window.XMLHttpRequest) { // (Mozilla/Safari)
		req = new XMLHttpRequest(); 
		req.onreadystatechange = processReqChange; 
		req.open("GET", url, true); 
		req.send(null); 
	}else if (window.ActiveXObject) { // (Internet Explorer)
		req = new ActiveXObject("Microsoft.XMLHTTP"); 
		if (req) { 
			req.onreadystatechange = processReqChange; 
			req.open("GET", url, true); 
			req.send(); 
		} 
	}
	//document.getElementById('dvStatus').style.display=''; // div "Carregando..."
}

/* 
	Gera conteúdo para o bloco html que recebe a reposta pela ajax engine 
*/

function processReqChange() {  
	if (req.readyState == 4) { 
		if (req.status == 200) { 
			document.getElementById(par).innerHTML = req.responseText; // retorna para o elemento html o conteúdo da resposta
			
		} else { 
			alert("Houve um problema ao obter os dados:\n" + req.statusText); 
			return false;
		}
	}// document.getElementById('dvStatus').style.display = 'none'; //fecha o div "Carregando..."
}

/* Ajax: Busca */
function fBuscar(pagina,dv){
	url = pagina; req = null; par = dv; 
	fXmlHttpRequest();
} 

/*
 *	Função: fMostraEsconde()
 *	Descrição: Oculta/Exibe um bloco de html.
 *	Atributo:  id [requerido] = atributo 'id' do objeto html a ser ocultado/exibido.
 */

function fMostraEsconde(id){
	obj = document.getElementById(id);
	if(obj.style.display == "none"){
		obj.style.display = "";
	}else{
		obj.style.display = "none"
	}
}

function fEsconde(id){
	obj = document.getElementById(id);
	obj.style.display = 'none';
}

function fMostra(id){
	obj = document.getElementById(id);
	obj.style.display = '';
}