/* funcao inativa */
function voltaCamposGT(site_gt,nome_gt,plano_trabalho,plano_trabalho_arquivo,atividades,outras_informacoes){
	document.getElementById("site_gt").value = site_gt;
	document.getElementById("nome_gt").value = nome_gt;
	document.getElementById("plano_trabalho").value = plano_trabalho;
	document.getElementById("plano_trabalho_arquivo").value = plano_trabalho_arquivo;
	document.getElementById("atividades").value = atividades;
	document.getElementById("outras_informacoes").value = outras_informacoes;
}
/* funcao inativa */

function busca_grupo(id) {
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = showContentsVerPub;
		xhr.open("GET", "resposta_script/resposta_script_pub.php?tipo=gt&id=" + id, true);
		xhr.send(null);
	}
	else {
		document.getElementById("mostra_ver_pub").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
	}
}
function showContentsVerPub() {
	if (xhr.readyState == 1) {
		document.getElementById("mostra_ver_pub").innerHTML = "Carregando";
	}
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			var outMsg = xhr.responseText;
		}
		else {
			var outMsg = "There was a problem with the request " + xhr.status;
		}
		document.getElementById("mostra_ver_pub").innerHTML = outMsg;
	}
}

function limpaArea() {
	document.getElementById("mostra_ver_pub").innerHTML = "<table width='100%' cellpadding='0' cellspacing='0' border='0'><tr><td>&nbsp;</td><td><div align='center'><img src='estilo/anpoll.jpg' /></div></td></tr></table>";
}

function busca_noticia(id,volta) {
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = showContentsVerNoticiaPub;
		xhr.open("GET", "resposta_script/resposta_script_pub.php?tipo=noticia&id=" + id + "&volta=" + volta, true);
		xhr.send(null);
	}
	else {
		document.getElementById("mostra_ver_pub").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
	}
}
function showContentsVerNoticiaPub() {
	if (xhr.readyState == 1) {
		document.getElementById("mostra_ver_pub").innerHTML = "Carregando";
	}
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			var outMsg = xhr.responseText;
		}
		else {
			var outMsg = "There was a problem with the request " + xhr.status;
		}
		document.getElementById("mostra_ver_pub").innerHTML = outMsg;
	}
}

function listar_noticias(gt) {
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = showContentsVerNoticiaPub;
		xhr.open("GET", "resposta_script/resposta_script_pub.php?tipo=listatodasnoticias&id=" + gt, true);
		xhr.send(null);
	}
	else {
		document.getElementById("mostra_ver_pub").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
	}
}
function showContentsVerNoticiaPub() {
	if (xhr.readyState == 1) {
		document.getElementById("mostra_ver_pub").innerHTML = "Carregando";
	}
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			var outMsg = xhr.responseText;
		}
		else {
			var outMsg = "There was a problem with the request " + xhr.status;
		}
		document.getElementById("mostra_ver_pub").innerHTML = outMsg;
	}
}

//busca pelo filtro de noticias
function busca_filtro(gt,volta) {
	if(document.getElementById("palavra").value == 0){
		document.getElementById("verificaCampo").innerHTML = "Preencha campo de busca!&nbsp;";
	}else{
		palavra = document.getElementById("palavra").value;
		busca_filtro2(gt,palavra,volta);
	}
}

function busca_filtro2(gt,palavra,volta) {
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = showContentsVerNoticiaPub;
		xhr.open("GET", "resposta_script/resposta_script_pub.php?tipo=buscaFiltroNoticias&gt=" + gt + "&palavra=" + palavra + "&volta=" + volta, true);
		xhr.send(null);
	}
	else {
		document.getElementById("mostra_ver_pub").innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";
	}
}
function showContentsVerNoticiaPub() {
	if (xhr.readyState == 1) {
		document.getElementById("mostra_ver_pub").innerHTML = "Carregando";
	}
	if (xhr.readyState == 4) {
		if (xhr.status == 200) {
			var outMsg = xhr.responseText;
		}
		else {
			var outMsg = "There was a problem with the request " + xhr.status;
		}
		document.getElementById("mostra_ver_pub").innerHTML = outMsg;
	}
}
