function buscarGraduacao() {
with(document.forms['frm_busca_graduacao']) {
if (trim(xpr.value) == '') {
alert("Informe uma ou mais palavras para a busca");
xpr.focus();
return false;
}
if (optBusca[optBusca.selectedIndex].value == 'c') {
action = "busca_cursos.php";
submit();
} else {
action = "busca_faculdades.php";
submit();
}
}
}
function postaSimulado() {
w = window.open("","_simulado","width=500,height=400");
return true;
}
idxFonte = 2;
arrFonteSize = Array("xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large");
function dimensionaFonte(op) {
objDiv = document.getElementById("Texto");
if (!objDiv)
return;
objSPAN = objDiv.getElementsByTagName("span");
objPs = objDiv.getElementsByTagName("p");
objLi = objDiv.getElementsByTagName("li");
if (op == "+")
idxFonte = (idxFonte > 4) ? idxFonte : idxFonte+1;
else
idxFonte = (idxFonte < 1) ? idxFonte : idxFonte-1;
for (i = 0; i < objSPAN.length; i++) {
objSPAN[i].style.fontSize = arrFonteSize[idxFonte];
}
for (i = 0; i < objPs.length; i++) {
objPs[i].style.fontSize = arrFonteSize[idxFonte];
}
for (i = 0; i < objLi.length; i++) {
objLi[i].style.fontSize = arrFonteSize[idxFonte];
}
}
function darNota(id, n) {
function retorno(b) {
msg = b;
msg = msg.split("#");
votos = msg[0];
nota = msg[1];
msgTxt= msg[2];
if (votos == -1)
{
alert(msgTxt);
return;
}
objSpam = document.getElementById("campoNota");
objSpam.innerHTML = votos + " votos. " + msgTxt;
for (i = 1; i <= 5; i++) {
if (i <= nota)
document.images['estrela'+i].src = "imagens/estrela-on.gif";
else
document.images['estrela'+i].src = "imagens/estrela-off.gif";
}
}
url = "conteudo_votar.php?id=" + id + "&n=" + n;
RPCGet(url, retorno);
}
function carregaNoticia(id) {
url = "noticias_ler.php?id=" + id;
location.href = url;
}
function carregaEvento(id) {
url = "/novosite/agenda_ler.php?id=" + id;
location.href = url;
}
function filtrarBoxAgenda(id) {
function retorno(b) {
arrEventos = b.split("@");
strHTML = '';
for (i = 0; i < arrEventos.length; i++) {
evento = trim(arrEventos[i]);
if(evento != "") {
evento = evento.split("#");
strHTML += '
' + evento[1] + '';
}
}
if (strHTML == '') {
strHTML = 'Não foi encontrado nenhum evento na agenda para esta região';
} else {
strHTML = '';
}
document.getElementById("boxEventos").innerHTML = strHTML;
}
idCat = 0;
if (document.getElementById("boxAgendaCategoria"))
idCat = document.getElementById("boxAgendaCategoria").value;
document.getElementById("boxEventos").innerHTML = "Aguarde. Consultando...";
url = "agenda_busca_rpc.php?r=" + id + "&c=" + idCat + "&d=" + new Date();
RPCGet(url, retorno);
}
function filtrarAgendaPorRegiao(id) {
function retorno(b) {
arrEventos = b.split("@");
strHTML = '';
for (i = 0; i < arrEventos.length; i++) {
evento = trim(arrEventos[i]);
if(evento != "") {
evento = evento.split("#");
strHTML += '' + evento[1] + '';
}
}
if (strHTML == '') {
strHTML = 'Não foi encontrado nenhum evento na agenda para esta região';
} else {
strHTML = '';
}
document.getElementById("eventos").innerHTML = strHTML;
}
idCat = 0;
if (document.getElementById("CodCategoria"))
idCat = document.getElementById("CodCategoria").value;
document.getElementById("eventos").innerHTML = "Aguarde. Consultando...";
url = "agenda_busca_rpc.php?r=" + id + "&c=" + idCat + "&d=" + new Date();
RPCGet(url, retorno);
}
function filtrarAgendaPorRegiao2(reg) {
with(document.forms['paginacao']) {
p.value = 1;
r.value = reg;
submit();
}
}
function filtrarNoticiasCategoria(id) {
if (id >= 0) {
url = "noticias.php?cid=" + id;
location.href=url;
}
}
function filtrarDicasAjax(id) {
function retorno(b) {
objDiv = document.getElementById("boxDicaPortugues");
objDiv.innerHTML = b;
}
RPCGet("includes/portugues_inteligente_box.php?c=" + id, retorno);
}
function paginarDicasAjax(d) {
function retorno(b) {
objDiv = document.getElementById("boxDicaPortugues");
objDiv.innerHTML = b;
}
with(document.forms['paginacao']) {
pagina = parseInt(p.value);
total = parseInt(tp.value);
if (d == 'a') {
if (pagina <= 1)
return;
else {
RPCGet("includes/portugues_inteligente_box.php?c="+c.value+"&p="+(pagina-1), retorno);
}
} else {
if (pagina >= total)
return;
else {
RPCGet("includes/portugues_inteligente_box.php?c="+c.value+"&p="+(pagina+1), retorno);
}
}
}
}
function irPara(pag) {
with(document.forms['paginacao']) {
if (p.value == pag) return;
p.value = pag;
submit();
}
}
function paginaAnterior() {
with(document.forms['paginacao']) {
pagina = parseInt(p.value);
if (pagina <= 1)
return;
else
p.value = pagina -1;
submit();
}
}
function paginaSeguinte() {
with(document.forms['paginacao']) {
pagina = parseInt(p.value);
total = parseInt(tp.value);
if (pagina >= total)
return;
else
p.value = pagina + 1;
submit();
}
}
function resultadoEnquete(enqueteID) {
url = "enquete_resultado.php?id=" + enqueteID;
abreJanela(url, 450, 300, true);
}
function votarEnquete(enqueteID) {
objForm = document.forms['frmEnquete'+enqueteID];
if(!objForm)
return false;
objOpcoes = objForm.opcao_id;
votou = false;
contOpcoes = (objOpcoes.length) ? objOpcoes.length : 0;
i = 0;
while(!votou && i < contOpcoes) {
if (objOpcoes[i].checked)
votou = true;
i++;
}
if (!votou) {
alert("Escolha uma opção de voto");
return false;
}
w = window.open("","_voto","width=450,height=300");
return true;
}
function trim(texto) {
while (texto.substring(0,1) == ' ') {
texto = texto.substring(1, texto.length);
}
while (texto.substring(texto.length-1, texto.length) == ' ') {
texto = texto.substring(0,texto.length-1);
}
return texto;
}
function validaFormDOM(formName) {
var f;
if (typeof(formName) == 'object')
f = formName;
else
f = document.getElementById(formName);
if (!f)
return false;
var i, fElementos;
fElementos = f.elements;
for (i = 0; i < fElementos.length; i++) {
_valor = fElementos[i].value;
_regex = fElementos[i].getAttribute("regex");
_etiqueta = fElementos[i].getAttribute("etiqueta") ? fElementos[i].getAttribute("etiqueta") : "o valor do campo" ;
if ((fElementos[i].type != "hidden" && fElementos[i].type == "text" || fElementos[i].type == "textarea") && fElementos[i].getAttribute("obrigatorio") == "S") {
if(_regex) {
_r = new RegExp(_regex);
if (!_r.test(_valor)) {
alert ("Informe " + _etiqueta + " corretamente");
fElementos[i].focus();
return false;
}
} else if (trim(_valor) == "") {
alert("Entre com " + _etiqueta);
fElementos[i].focus();
return false;
}
} else if ((fElementos[i].type == "select-one" || fElementos[i].type == "select-multiple") && fElementos[i].getAttribute("obrigatorio") == "S") {
if (!(fElementos[i].selectedIndex >= 0 && fElementos[i][fElementos[i].selectedIndex].value != "")) {
alert("Selecione uma opção para " + _etiqueta);
fElementos[i].focus();
return false;
}
}
}
return true;
}
function abreJanela(url, w, h, barras) {
var width = w;
var height = h;
var left = parseInt((screen.availWidth/2) - (width/2));
var top = parseInt((screen.availHeight/2) - (height/2));
var windowFeatures = "width=" + width + ",height=" + height + ",status,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
windowFeatures = (barras) ? windowFeatures + ",scrollbars=1, toolbar=1" : windowFeatures;
myWindow = window.open(url, "subWind", windowFeatures);
}
function GetXMLHTTP()
{
var xmlhttp;
if (typeof XMLHttpRequest != "undefined")
{
try
{ xmlhttp = new XMLHttpRequest(); }
catch (e)
{ xmlhttp = false; }
}
else
{
try
{ xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
catch (e)
{ xmlhttp = false; }
}
return xmlhttp;
}
function RPCGet(url, handler, data)
{
var xmlhttp = GetXMLHTTP();
if (!xmlhttp) return false;
if (!data) data = null;
xmlhttp.open("GET", url, true);
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && handler)
eval(handler(xmlhttp.responseText))
};
xmlhttp.send(data);
}