var divsite;
var divpag;

window.onload = function(){
 var paginas = window.location.href.slice(window.location.href.indexOf('?')+1);
 var paginainicial = window.location.href.slice(window.location.href.indexOf('?')).split('?');
 //alert(paginainicial[1]+' meu teste');
 if(!paginainicial[1])
 {
  meio();
  fundoSite('0');
  
 }
 else{
  var paginasn = paginas.split('&');
  var num = paginasn[1];
  for(i=1; i<=num;i++){
  
  }

  pagCurso(paginasn[0],i);
  meio();
  //fundoSite(paginasn[1]);
 }


}
function Noticia(){
 document.getElementById("transparente").style.visibility="visible";

 document.getElementById("janelanoticia").style.visibility="visible";
 
 var url = "php/bancaMonografias.php";
 //alert(url);
 requisicaoHTTP("GET",url,true,1);
 
}

function fechaNoticia(){
 document.getElementById("transparente").style.visibility="hidden";

 document.getElementById("janelanoticia").style.visibility="hidden";
}

function trataDados(){
 var resposta = ajax.responseText;
 
 if(menu == 1){
  var pagina = document.getElementById('janelanoticia');
  pagina.innerHTML = resposta;
 }
 else if(menu == 2){
  var pagina = document.getElementById('centro');
  //alert(resposta);
  Aviso(0);
  pagina.innerHTML = resposta;
  fundoSite(divsite);
  //v_salvaEstado();

 }
 else if(menu == 3){
  var pagina = document.getElementById('tabelacurso');
  pagina.innerHTML = resposta;
  Aviso(0);
 }
 else if(menu == 4){
  var pagina = document.getElementById('tabela2');
  pagina.innerHTML = resposta;
  Aviso(0);
 }
 else if(menu == 5){
  var pagina = document.getElementById('tudo');
  pagina.innerHTML = resposta;
  Aviso(0);
  meio();
  fundoSite('0');  
 }
 else if(menu == 6){
     //alert('teste'+divpag);
     var pagina = document.getElementById(divpag);
     //alert(pagina);
     pagina.innerHTML = resposta;
     Aviso(0);
     AvisoPos(0);
 }
 
}

function AlunoLogout(){
    document.cookie = "loginaluno=";
    document.cookie = "senhaaluno=";
    window.location.href = "http://www.faceres.com.br";
}

function ProfessorLogout(){
    document.cookie = "loginprofessor=";
    document.cookie = "senhaprofessor=";
    window.location.href = "http://www.faceres.com.br";
}

function ValidandoAluno(){
    var alunoteste = document.getElementById('alunoteste').value;

    if(alunoteste == 1){
        //alert("Bem Vindo ao sistema FACERES");
        var loginaluno = document.getElementById('loginaluno').value;
        var senhaaluno = document.getElementById('senhaaluno').value;
        document.cookie = "loginaluno="+loginaluno;
        document.cookie = "senhaaluno="+senhaaluno;
        pagaluno('ALUNOS',1,loginaluno,senhaaluno);
    }
    else if(alunoteste == 2){
        alert('Senha Invalida',1);
        //pagCurso('INTRANET',1);
        window.location.href = "http://www.faceres.com.br";
    }
    else if(alunoteste == 4){
	  alert('Login Incorreto! Por gentileza, procure a secretaria!');
	  //pagCurso('INTRANET',1);
	  window.location.href = "http://www.faceres.com.br";
    } 	
    else{
        alert('Aluno Inexistente');
        //pagCurso('INTRANET',1);
        window.location.href = "http://www.faceres.com.br";
    }
}

function ValidandoAlunoPOS(){
    var alunoteste = document.getElementById('alunoteste').value;

    if(alunoteste == 1){
        //alert("Bem Vindo ao sistema FACERES");
        var loginaluno = document.getElementById('loginaluno').value;
        var senhaaluno = document.getElementById('senhaaluno').value;
        document.cookie = "loginaluno="+loginaluno;
        document.cookie = "senhaaluno="+senhaaluno;
        pagaluno('POS_ALUNOS',1,loginaluno,senhaaluno);
    }
    else if(alunoteste == 2){
        alert('Senha Invalida',1);
        pagCurso('intranet_pos',1);
    }
    else{
        alert('Aluno Inexistente');
        pagCurso('intranet_pos',1);
    }
}

function ValidandoProfessor(){
    var alunoteste = document.getElementById('alunoteste').value;

    if(alunoteste == 1){
        //alert("Bem Vindo ao sistema FACERES");
        var loginaluno = document.getElementById('loginaluno').value;
        var senhaaluno = document.getElementById('senhaaluno').value;
        document.cookie = "loginprofessor="+loginaluno;
        document.cookie = "senhaprofessor="+senhaaluno;
        pagaluno('POS_PROFESSORES_principal',1,loginaluno,senhaaluno);
    }
    else if(alunoteste == 2){
        alert('Senha Invalida',1);
        pagCurso('intranet',1);
    }
    else if(alunoteste == 3){
        alert('Problemas no login do usuario');
        pagCurso('intranet',1);
    }
    else{
        alert('Professor nao possui cadastro na POS');
        pagCurso('intranet',1);
    }
}

function LoginAluno(){
    var loginaluno = document.getElementById('loginaluno').value;
    var senhaaluno = document.getElementById('senhaaluno').value;
    if(loginaluno > 9999){
        alert("Esse Cadastro é de aluno da Pós-Graduação\nPor favor acesse o Sistema de Pós-Graduação\nObrigado");
        exit();
    }
    pagaluno('ALUNOS_loga',1,loginaluno,senhaaluno);
    //alert('Teste de login');
}

function LoginAlunoPOS(){
    var loginaluno = document.getElementById('loginaluno').value;
    var senhaaluno = document.getElementById('senhaaluno').value;
    if(loginaluno < 9999){
        alert("Esse Cadastro é de aluno da Graduação\nPor favor acesse o Sistema de Graduação\nObrigado");
        exit();
    }
    pagaluno('POS_ALUNOS_loga',1,loginaluno,senhaaluno);
    //alert('Teste de login');
}

function LoginProfessor(){
    var loginaluno = document.getElementById('loginaluno').value;
    var senhaaluno = document.getElementById('senhaaluno').value;
    pagaluno('POS_PROFESSORES_loga',1,loginaluno,senhaaluno);
}

function LancaNota(codigo,nota,campo,div){
    divsite=0;
    divpag=div;
    var url = "php/POS_PROFESSORES_notas_lanca.php?codigo="+codigo+"&&nota="+nota+"&&campo="+campo+"&&idx="+div;
    requisicaoHTTP("GET",url,true,6);
    AvisoPos(1);

}

function POS_alterar_senha(div,dvsite,codigo){
    divsite = dvsite;
    divpag = div;
    var senhaantes = document.getElementById('pwdantes').value;
    var senhanova = document.getElementById('pwdnovo').value;
    var confirmasenha = document.getElementById('pwdcnovo').value;

    if((!senhaantes) || (!senhanova)){
        alert("Senha não foi digitada por favor digite a senha");
        exit();
    }

    if(senhanova != confirmasenha){
        alert("Nova senha está digitada errada digite novamente a nova senha e a confirmação");
    }
    else{
        var url = "php/POS_PROFESSORES_senha_alt.php?codigo="+codigo+"&&senhaantiga="+senhaantes+"&&senhanova="+senhanova;
        requisicaoHTTP("GET",url,true,6);
        AvisoPos(1);
    }
}

function LancaNotaIE(codigo,nota,campo,div){
    divsite=0;
    divpag=div;
    var url = "php/POS_PROFESSORES_notas_lanca_ie.php?codigo="+codigo+"&&nota="+nota+"&&campo="+campo+"&&idx="+div;
    requisicaoHTTP("GET",url,true,6);
    AvisoPos(1);

}

function EnviaArquivo(div,status,grade){
    var navegador = navigator.appName;
    if(navegador == "Microsoft Internet Explorer"){
        var Versao = navigator.appVersion;
        var version = Versao.split(";");
        var vIE = version[1].split(" ");
        if(vIE[2] >= 8){
            divsite = 0;
            divpag = div;
            divMostra(div,1);
            var url = "php/POS_PROFESSORES_arquivos_upload.php?grade="+grade;
            requisicaoHTTP("GET",url,true,6);
        }
        else{
            alert("Seu navegador não suporta o sistema de envio de arquivos\nAtualize seu navegador para Internet Explorer 8");
            divsite = 0;
            divpag = div;
            divMostra(div,1);
            var url = "php/ATUALIZA_ie.php";
            requisicaoHTTP("GET",url,true,6);
        }
    }
    else{
        divsite = 0;
        divpag = div;
        divMostra(div,1);
        var url = "php/POS_PROFESSORES_arquivos_upload.php?grade="+grade;
        requisicaoHTTP("GET",url,true,6);
    }

    
}

function MudaStatusArq(div,codigo,status){
    divsite = 0;
    divpag = div;
    var stat = document.getElementById('stat'+div).value;
    var url="php/POS_PROFESSORES_arquivos_status.php?codigo="+codigo+"&&status="+status+"&&stat="+stat+"&&idx="+div;
    //alert(url);
    requisicaoHTTP("GET",url,true,6);
}

function FechaJanela(div,divpega,grade){
    divMostra(div,0);
    var obj = "arquivos";
    PosLanca('lancaconteudo',divpega,obj,grade);
}

function PosLanca(div,divpega,obj,grade){
    divsite = divpega;
    divpag = div;
    var url;
    if(obj == "registros"){
        url = "php/POS_PROFESSORES_registros_geral.php?grade="+grade;
    }
    else if(obj == "notas"){
        var navegador = navigator.appName;
        if(navegador == "Microsoft Internet Explorer"){
            url = "php/POS_PROFESSORES_notas_geral_ie.php?grade="+grade;
        }
        else{
            url = "php/POS_PROFESSORES_notas_geral.php?grade="+grade;
        }

    }
    else if(obj == "arquivos"){
        url = "php/POS_PROFESSORES_arquivos_geral.php?grade="+grade;
    }
    else if(obj == "alunosarquivos"){
        url = "php/POS_ALUNOS_arquivos_geral.php?grade="+grade;
    }
    else{
        url = "php/POS_PROFESSORES_aviso.php";
    }
    
    divMostra(div,1);
    
    requisicaoHTTP("GET",url,true,6);
    AvisoPos(1);
}

function PosRegistro(div,divpega,grade,data){
    divsite = divpega;
    divpag = div;
    //alert(data);
    var url = "php/POS_PROFESSORES_registros_lanca.php?grade="+grade+"&&data="+data;

    divMostra(div,1);

    requisicaoHTTP("GET",url,true,6);
    AvisoPOS(1);
}

function PosGravaConteudo(div,divpega,grade,data,professor){
    divsite = divpega;
    divpag = div;

    var conteudo = document.getElementById('conteudo').value;
    var carga = document.getElementById('cargaHoraria').value;
    if(!conteudo){
        alert('Preencha o Conteudo');
        document.getElementById('conteudo').focus();
    }
    else{
        //alert(conteudo);
        var url = "php/POS_PROFESSORES_registros_grava.php?grade="+grade+"&&data="+data+"&&professor="+professor+"&&carga="+carga+"&&conteudo="+conteudo;
        divMostra(div,0);
        requisicaoHTTP("GET",url,true,6);
        AvisoPOS(1);
    }

}

function PosExcluiConteudo(div,divpega,codigo,conteudo,grade){
    divsite = divpega;
    divpag = div;

    if(confirm("Deseja Realmente Excluir "+conteudo)){
        var url="php/POS_PROFESSORES_registros_exclui.php?codigo="+codigo+"&&grade="+grade;
        requisicaoHTTP("GET",url,true,6);
        AvisoPOS(1);
    }
}

function AvancaMes(div,divpega,mes,ano,grade){
    divsite = divpega;
    divpag = div;
    var url = "php/POS_PROFESSORES_registros_calendario.php?mes="+mes+"&&ano="+ano+"&&grade="+grade;
    requisicaoHTTP("GET",url,true,6);
    AvisoPos(1);
}

function divMostra(div,status){
    if(status == 1){
        document.getElementById(div).style.visibility = "visible";
    }
    else{
        document.getElementById(div).style.visibility = "hidden";
    }
}

//inicio das funções do protocolo aluno
function LancaDisciplina(div,divpega,linha,valor,item,aluno){
    var n = 0;
    var disciplinaTotal="";
    var disciplinaCkd;
    var disciplina;
    for(var i=0;i<linha;i++){
        disciplinaCkd = document.getElementById('opt'+i).checked;
        disciplina = document.getElementById('opt'+i).value;
        if(disciplinaCkd == true){
            disciplinaTotal = disciplinaTotal+disciplina+";";
            n = n + 1;
        }
    }
    var url = "php/ALUNOS_protocolo_valor_prg1.php?qtde="+n+"&&aluno="+aluno+"&&item="+item+"&&valor="+valor+"&&disciplina="+disciplinaTotal;
    divsite = divpega;
    divpag = div;
    //alert(url);
    requisicaoHTTP("GET",url,true,6);
}

function PrecoProtocolo(div,divpega){
    var item = document.getElementById('protocolo').value;
    //alert(item);

    var url;
    if(item == '25'){
        //var res = prompt("Digite a Quantidade de Disciplinas\n",'1');
        url = "php/ALUNOS_protocolo_valor_prg.php?item="+item;
    }
    else{
        url = "php/ALUNOS_protocolo_valor.php?item="+item;
    }

    divsite = divpega;
    divpag = div;
    //alert(divpag);
    requisicaoHTTP("GET",url,true,6);
    Aviso(1);
}

function ConfirmaProtocolo(div,divpega){
    var item = document.getElementById('pditem').value;
    var aluno = document.getElementById('pdaluno').value;
    var valor;
    var disciplina;
    if(item == 25){
        valor = document.getElementById('pdvalor').value;
        disciplina = document.getElementById('pddisciplina').value;
    }
    else{
        valor = 0;
        disciplina = "";
    }
    var url = "php/ALUNOS_protocolo_motivo.php?item="+item+"&&aluno="+aluno+"&&valor="+valor+"&&disciplina="+disciplina;
    divsite = divpega;
    divpag = div;
    alert("AVISO:\nEste Protocolo só terá validade após pagamento na Tesouraria\n");
    requisicaoHTTP("GET",url,true,6);
    Aviso(1);
    Motivo(1);
}

function ConfirmarMotivo(div,divpega){
    var item = document.getElementById('pditem').value;
    var aluno = document.getElementById('pdaluno').value;
    var txtmotivo = document.getElementById('txtmotivo').value;
    var valor = document.getElementById('vlprod').value;
    var disciplina = document.getElementById('disciplina').value;
    txtmotivo = txtmotivo+"|"+disciplina;
    var url = "php/ALUNOS_protocolo_motivo_grava.php?item="+item+"&&aluno="+aluno+"&&valor="+valor+"&&motivo="+txtmotivo;
    divsite = divpega;
    divpag = div;
    requisicaoHTTP("GET",url,true,6);
    Aviso(1);
    Motivo(0);
}

function TextoMotivo(){
    var txtarea = document.getElementById('txtmotivo').value.length;
    var contachr = document.getElementById('contachr').value;
    //alert(txtarea);
    if(txtarea <= 150){
        //alert(contachr);
        contachr = 150 - txtarea;
        //alert(contachr);
        document.getElementById('contachr').value = contachr;
    }
    else{
        var txtatual = document.getElementById('txtmotivo').value;
        //alert(txtatual);
        var txtnovo = txtatual.substr(0,150);
        //alert(txtnovo);
        document.getElementById('txtmotivo').value = txtnovo;
    }
}

//final das funções do protocolo aluno

function pagAlunoHome(curso,divpega){
    var pegaaluno = getCookie('loginaluno');
    var senhaaluno = getCookie('senhaaluno');
    pagaluno(curso,divpega,pegaaluno,senhaaluno);
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function pagaluno(curso,divpega,loginaluno,senhaaluno){
 
 var url = "php/"+curso+".php?login="+loginaluno+"&&senha="+senhaaluno;
 //alert(divpega);
 divsite = divpega;
 requisicaoHTTP("GET",url,true,5);
 Aviso(1);
}

function pagCurso(curso,divpega){

 var url = "php/"+curso+".php";
 //alert(divpega);
 divsite = divpega;
 requisicaoHTTP("GET",url,true,2);
 Aviso(1);

}

function pagEditora(letra){
 //alert(letra);
 var url = "php/listaeditora.php?letra="+letra;
 requisicaoHTTP("GET",url,true,4);
 Aviso(1);
}


function pagCursoInd(curso,divpega){
 var autor = document.getElementById('autor').value;
 var titulo = document.getElementById('titulo').value;
 var editora = document.getElementById('editora').value;
 var ano = document.getElementById('ano').value;
 var justificativa = document.getElementById('justificativa').value;
 var identificacao = document.getElementById('alunoid').value;
 var nome = document.getElementById('nome').value;
 var ra = document.getElementById('ra').value;
 var cursoind = document.getElementById('curso').value;

 var url = "php/"+curso+".php?autor="+autor+"&&titulo="+titulo+"&&editora="+editora+"&&ano="+ano+"&&justificativa="+justificativa+"&&identificacao="+identificacao+"&&nome="+nome+"&&ra="+ra+"&&curso="+cursoind;
 //alert(url);
 divsite = divpega;
 if(!nome){
     alert("Preencha o campo com seu nome!!!!");
 }
 else if(!ra){
     alert("Preencha seu email!!!");
 }
 else{
     requisicaoHTTP("GET",url,true,2);
     Aviso(1);
 }
}

function AcessaLogin(){
 var login = document.getElementById("login").value;
 var senha = document.getElementById("senha").value;

 //alert(login+" - "+senha);
 //FechaLogin();
 //alert("testa a requisicao");
 var url = "php/alunos/teste.php?login="+login+"&&senha="+senha;
 //alert(url);

 requisicaoHTTP("GET",url,true,1);

}

function fundoSite(divpega){
//alert(divpega+"---");
 if(divpega == '0'){
 //alert("mrp");
 var centroo = document.getElementById('centro');

 var topoendereco = centroo.offsetHeight + 10;

 var endereco = document.getElementById('endereco');
 endereco.style.top = topoendereco;
 document.getElementById('canto_baixo_esq').style.top = centroo.offsetHeight + 1;
 document.getElementById('canto_baixo_dir').style.top = centroo.offsetHeight + 1;
 document.getElementById('borda_baixo').style.top = centroo.offsetHeight + 1;
 //alert(centroo.offsetHeight);
 }
 else{
 var centroo = document.getElementById('centro');
 //alert(centroo.offsetHeight);
 //alert(divpega);
 var topoendereco = centroo.offsetHeight + 10;
 //alert(topoendereco);



 if(navegador == '1'){
 var centro = document.getElementById('centro').style.height;
 //alert (centroo.offsetHeight);
 topoendereco = (topoendereco + divpega);
 var endereco = document.getElementById('endereco');


 document.getElementById('centro').style.height = 431 + divpega;
 endereco.style.top = document.getElementById('centro').offsetHeight + 10;
 //alert(document.getElementById('centro').style.height);
 document.getElementById('borda_esq').style.height = 630 + divpega;
 document.getElementById('borda_dir').style.height = 630 + divpega;
 document.getElementById('canto_baixo_esq').style.top = 432 + divpega;
 document.getElementById('canto_baixo_dir').style.top = 432 + divpega;
 document.getElementById('borda_baixo').style.top = 432 + divpega;

 }
 else{
 var centro = document.getElementById('centro').style.height;
 //alert(topoendereco);
 var endereco = document.getElementById('endereco');
 endereco.style.top = topoendereco;
 if(centro == '1'){
 document.getElementById('borda_esq').style.height = document.getElementById('borda_esq').offsetHeight + divpega - 23;
 document.getElementById('borda_dir').style.height = document.getElementById('borda_dir').offsetHeight + divpega - 23;
 //alert("numero 1");
 }
 else{
 document.getElementById('borda_esq').style.height = centroo.offsetHeight + 200;
 document.getElementById('borda_dir').style.height = centroo.offsetHeight + 200;
 //alert(document.getElementById('borda_dir').style.height+" numero2");
 }
 document.getElementById('canto_baixo_esq').style.top = centroo.offsetHeight + 1;
 document.getElementById('canto_baixo_dir').style.top = centroo.offsetHeight + 1;
 document.getElementById('borda_baixo').style.top = centroo.offsetHeight + 1;
 //document.getElementById('centro').style.height = document.getElementById('centro').offsetHeight;
 //alert (document.getElementById('borda_baixo').style.top+"!!!");
 }
 //alert(divpega);
 }
}

function addFavoritos(){

if (document.all) { //browser= Internet Explorer
var resposta = window.confirm("Quer adicionar este site ao seu Favoritos?");
if (resposta)
{
 window.external.AddFavorite("http://www.uniceres.com","Uniceres uma faculdade diferente");
}
}
else { //browser= Netscape Navigator
alert("Use CTRL+D para adicionar este site ao seu Favoritos!");
}

}

function meio(){
 var resolucao = screen.width;
 //alert(resolucao);
 document.getElementById('borda_dir').style.left = (((resolucao - (resolucao * 0.03)) - 778)/2) + 772;
 document.getElementById('borda_esq').style.left = (((resolucao - (resolucao * 0.03)) - 778)/2);
 document.getElementById('topo').style.left = (((resolucao - (resolucao * 0.03)) - 778)/2) + 7;
 document.getElementById('centro').style.left = (((resolucao - (resolucao * 0.03)) - 778)/2) + 7;
 document.getElementById('chromemenu').style.left = (((resolucao - (resolucao * 0.03)) - 778)/2) + 7;
 
 //alert("legal");
}

function BibSelecao(opcao){


 if(opcao == 1){
  var valores = "<table width=100%><tr><td><input type=hidden value=alunos id=alunoid>Nome: <input type=text id=nome size=60 maxlength=55></td></tr><tr><td>E-mail: <input type=text id=ra size=59 maxlength=55></td></tr><tr><td>Curso: <input type=text id=curso size=40 maxlength=35></td></tr></table>";

  document.getElementById('tab').innerHTML = valores;
 }
 else if(opcao == 2){
  var valores = "<table width=100%><tr><td><input type=hidden value=professores id=alunoid><input type=hidden value=. id=curso>Nome: <input type=text id=nome size=60 maxlength=55></td></tr><tr><td>E-mail: <input type=text id=ra size=59 maxlength=55></td></tr></table>";

  document.getElementById('tab').innerHTML = valores;
 }
 else if(opcao == 3){
  var valores = "<table width=100%><tr><td><input type=hidden value=funcionarios id=alunoid><input type=hidden value=. id=curso>Nome: <input type=text id=nome size=60 maxlength=55></td></tr><tr><td>E-mail: <input type=text id=ra size=59 maxlength=55></td></tr></table>";

  document.getElementById('tab').innerHTML = valores;
 }
 else if(opcao == 4){
  var valores = "<table width=100%><tr><td><input type=hidden value=associados id=alunoid><input type=hidden value=. id=curso>Nome: <input type=text id=nome size=60 maxlength=55></td></tr><tr><td>E-mail: <input type=text id=ra size=59 maxlength=55></td></tr></table>";

  document.getElementById('tab').innerHTML = valores;
 }
 else if(opcao == 5){
  var valores = "<table width=100%><tr><td><input type=hidden value=outros id=alunoid><input type=hidden value=. id=curso>Nome: <input type=text id=nome size=60 maxlength=55></td></tr><tr><td>E-mail: <input type=text id=ra size=59 maxlength=55></td></tr></table>";

  document.getElementById('tab').innerHTML = valores;
 }

}

function AvisoPos(exibir){

   var aviso = document.getElementById('ProgressBar');
   if(exibir == 1)
    aviso.style.visibility='visible';
   else
    aviso.style.visibility='hidden';
   
}

function Aviso(exibir){

   aguardando = exibir;
   var aviso = document.getElementById('aviso');
   if(exibir == 1)
    aviso.style.visibility='visible';
   else
    aviso.style.visibility='hidden';

}

function Motivo(exibir){

   aguardando = exibir;
   var aviso = document.getElementById('valorpd');
   if(exibir == 1)
    aviso.style.visibility='visible';
   else
    aviso.style.visibility='hidden';

}

function cpaPergunta1(avpergunta,div){
    //alert(div);
    divsite = 0;
    divpag = div;
    var url = "php/ALUNOS_cpa_pergunta.php?avpergunta="+avpergunta;
    //alert(url);
    requisicaoHTTP("GET",url,true,6);
}

function cpaResposta1(avpergunta,div){
    divsite = 0;
    divpag = div;
    var linhas = document.getElementById('linhas').value;
    var arquivo = document.getElementById('arquivo').value;
    var pergunta,tiporesp,resposta,tipo,url,campos;
    campos = '';
    for(var i=0;i<linhas;i++){
        
        pergunta = document.getElementById('perg'+i).value;
        tiporesp = document.getElementById('resp'+i).type;
        if(tiporesp == 'radio'){
            tipo = document.getElementsByName('respo'+i);
            for(var t=0;t<tipo.length;t++){
                if(tipo[t].checked)
                    break
            }
            resposta = tipo[t].value;
            
        }
        else{
            resposta = document.getElementById('resp'+i).value;
        }
        campos += '&&pergunta'+i+'='+pergunta+'&&resposta'+i+'='+resposta;
    }
    Aviso(1);
    url = "php/ALUNOS_cpa_resposta.php?arquivo="+arquivo+"&&avpergunta="+avpergunta+"&&linhas="+linhas+campos;
    //alert(campos);
    requisicaoHTTP("GET",url,true,6)
}

function cpaPergunta2(avpergunta,div,arquivo){
    //alert(div);
    divsite = 0;
    divpag = div;
    var url = "php/ALUNOS_cpa_pergunta.php?avpergunta="+avpergunta+"&&arquivo="+arquivo;
    //alert(url);
    requisicaoHTTP("GET",url,true,6);
}

function cpaResposta2(avpergunta,div){
    divsite = 0;
    divpag = div;
    var linhas = document.getElementById('linhas').value;
    var arquivo = document.getElementById('arquivo').value;
    var cadprof = document.getElementById('cadprof').value;
    var pergunta,tiporesp,resposta,tipo,url,campos;
    campos = '';
    for(var i=0;i<linhas;i++){

        pergunta = document.getElementById('perg'+i).value;
        tiporesp = document.getElementById('resp'+i).type;
        if(tiporesp == 'radio'){
            tipo = document.getElementsByName('respo'+i);
            for(var t=0;t<tipo.length;t++){
                if(tipo[t].checked)
                    break
            }
            resposta = tipo[t].value;

        }
        else{
            resposta = document.getElementById('resp'+i).value;
        }
        campos += '&&pergunta'+i+'='+pergunta+'&&resposta'+i+'='+resposta;
    }
    Aviso(1);
    url = "php/ALUNOS_cpa_resposta2.php?cadprof="+cadprof+"&&arquivo="+arquivo+"&&avpergunta="+avpergunta+"&&linhas="+linhas+campos;
    //alert(campos);
    requisicaoHTTP("GET",url,true,6)
}

function cpafilhos(div){
    var nfilhos = document.getElementById('filhos').value;
    divsite = 0;
    divpag = div;
    var url = "php/ALUNOS_cpa_economico_filhos.php?resp="+nfilhos;
    requisicaoHTTP("GET",url,true,6)
}

function cpaTransporte(div){
    divsite = 0;
    divpag = div;
    var tipo = document.getElementsByName('transporte');
            for(var t=0;t<tipo.length;t++){
                if(tipo[t].checked)
                    break
            }
            var transporte = tipo[t].value;
    var url = "php/ALUNOS_cpa_economico_transporte.php?resp="+transporte;
    
    requisicaoHTTP("GET",url,true,6)
}

function cpaTrabalho(div){
    divsite = 0;
    divpag = div;
    var trabalho = document.getElementById('trabalho').value;
    var url = "php/ALUNOS_cpa_economico_trabalho.php?resp="+trabalho;
   
    requisicaoHTTP("GET",url,true,6)
}

function cpaComunidade(div){
    divsite = 0;
    divpag = div;
    var trabalho = document.getElementById('comunidade').value;
    var url = "php/ALUNOS_cpa_economico_comunidades.php?resp="+trabalho;

    requisicaoHTTP("GET",url,true,6)
}

function cpaEmail(div){
    divsite = 0;
    divpag = div;
    var trabalho = document.getElementById('email').value;
    var url = "php/ALUNOS_cpa_economico_email.php?resp="+trabalho;

    requisicaoHTTP("GET",url,true,6)
}

function cpaTempo(ev,input){

    var e = ev || window.event;
    codigo_tecla = e.keyCode?e.keyCode:e.which;
    //alert(codigo_tecla);
    if (((codigo_tecla>=48)&&(codigo_tecla<=57)) || ((codigo_tecla>95)&&(codigo_tecla<106)) || (codigo_tecla == 109) || (codigo_tecla == 191) || (codigo_tecla == 16)){
        var tempo = input.value.split(":");
        var real = tempo[0];
        if(real.length <= 2){
            
        }

    }
    else if(codigo_tecla == 8){

    }
    else{
        var valor_input = input.value;
        var tamanho_input = input.value.length;
        tamanho_input = tamanho_input - 1;
        //alert(tamanho_input);
        var escreve = valor_input.substring(0,tamanho_input);
        //alert(escreve);
        input.value = "";
        input.value = escreve;
        //tamanho_input;
        return false;
    }

}

function cpaGrava(div){
    divsite = 0;
    divpag = div;
   
    var religiao = document.getElementById('religiao').value;
    var estadocivil = document.getElementById('estadocivil').value;
    var filhos = document.getElementById('filhos').value;
    var nfilhos = document.getElementById('nfilhosA').value;
    var tipo = document.getElementsByName('renda');
            for(var t=0;t<tipo.length;t++){
                if(tipo[t].checked)
                    break
            }
    var renda = tipo[t].value;
    var transporte = document.getElementById('vtransporte').value;
    var transpoutro = document.getElementById('transpoutro').value;
    var tempo = document.getElementById('tempo').value;
    var trabalhotano = document.getElementById('trabalhotano').value;
    var trabalhotmes = document.getElementById('trabalhotmes').value;
    var trabalhoEmpresa = document.getElementById('trabalhoEmpresa').value;
    var trabalhoRamo = document.getElementById('trabalhoRamo').value;
    var computador = document.getElementById('computador').value;
    var informatica = document.getElementById('informatica').value;
    var pcfaceres = document.getElementById('pcfaceres').value;
    var social = "";
    var check = document.getElementsByName('redesocial');
        for(var n=0;n<check.length;n++){
            if(check[n].checked)
                social += check[n].value+";";
        }
    var comunidade = document.getElementById('comunidade').value;
    var comunidades = document.getElementById('ncomunidadesA').value;
    var site = document.getElementById('site').value;
    var email = document.getElementById('email').value;
    var nemail = document.getElementById('nemailA').value;
    var tipo1 = document.getElementsByName('saber');
            for(var t1=0;t1<tipo1.length;t1++){
                if(tipo1[t1].checked)
                    break
            }
    var saber = tipo1[t1].value;
    var lider = document.getElementById('lider').value;
    var caracteristica1 = document.getElementById('caracteristica1').value;
    var caracteristica2 = document.getElementById('caracteristica2').value;
    var dados = "?religiao="+religiao+"&&estadocivil="+estadocivil+"&&filhos="+filhos+"&&nfilhos="+nfilhos+"&&renda="+renda+"&&transporte="+transporte+"&&transpoutro="+transpoutro+"&&tempo="+tempo+"&&trabalhotano="+trabalhotano+"&&trabalhotmes="+trabalhotmes;
    dados += "&&trabalhoEmpresa="+trabalhoEmpresa+"&&trabalhoRamo="+trabalhoRamo+"&&computador="+computador+"&&informatica="+informatica+"&&pcfaceres="+pcfaceres+"&&social="+social+"&&comunidade="+comunidade+"&&comunidades="+comunidades+"&&site="+site;
    dados += "&&email="+email+"nemail="+nemail+"&&saber="+saber+"&&lider="+lider+"&&caracteristica1="+caracteristica1+"&&caracteristica2="+caracteristica2;

    var url = "php/ALUNOS_cpa_economico_grava.php"+dados;
    requisicaoHTTP("GET",url,true,6)
    //alert(dados);
}

