/*
  JNS PORTAL MANAGEMENT - Desenvolvido por Junior Gobira (juniousbr@gmail.com)
  */

function checar_l_pa(theForm)
{
    var NomeSite = "UESP           \n\nAviso          \n\n";

    if (theForm.aluno_matricula.value == "") {
    alert(NomeSite+"Informe a sua Matrícula.         ");
    theForm.aluno_matricula.focus();
    return (false);
    }

    if (theForm.aluno_senha.value == "") {
    alert(NomeSite+"Informe a sua Senha.         ");
    theForm.aluno_senha.focus();
    return (false);
    }

    theForm.submit;
}

function checar_s_e(theForm)
{
    var NomeSite = "UESP           \n\nAviso          \n\n";
    var len = theForm.n_senha.value.length;

    if (theForm.n_senha.value == "") {
    alert(NomeSite+"Informe a Nova Senha.         ");
    theForm.n_senha.focus();
    return (false);
    }

    if (len <= 5) {
    alert(NomeSite+"Informe a Nova Senha. (mínimo 6 caracteres e máximo 10 caracteres)   ");
    theForm.n_senha.focus();
    return (false);
    }

    if (theForm.c_senha.value != theForm.n_senha.value) {
    alert(NomeSite+"Confirme a Nova Senha.         ");
    theForm.c_senha.focus();
    return (false);
    }

    if ( (theForm.email.value == "") && (theForm.emailuesp.value == "") ) {
    alert(NomeSite+"Você precisa informar um E-mail ou solicitar um E-mail da UESP.         ");
    theForm.n_senha.focus();
    return (false);
    }

    if ( (theForm.email.value != "") && (theForm.emailuesp.value != "") ) {
    alert(NomeSite+"Informe apenas uma opção de E-mail.         ");
    theForm.n_senha.focus();
    return (false);
    }

    theForm.submit;
}

function checar_r_e(theForm)
{
    var NomeSite = "UESP           \n\nAviso          \n\n";

    if (theForm.aluno_matricula.value == "") {
    alert(NomeSite+"Informe a sua Matrícula.         ");
    theForm.aluno_matricula.focus();
    return (false);
    }

    if (theForm.aluno_email.value.indexOf("@",0) == -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.aluno_email.focus();
    return (false);
    }

    x = theForm.aluno_email.value.length;
    x = x - 1;

    if (theForm.aluno_email.value.indexOf("@",0) == x) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.aluno_email.focus();
    return (false);
    }

    if (theForm.aluno_email.value.indexOf("@",0) == 0) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.aluno_email.focus();
    return (false);
    }

    if (theForm.aluno_email.value.indexOf(".@",0) != -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.aluno_email.focus();
    return (false);
    }

    if (theForm.aluno_email.value.indexOf("@.",0) != -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.aluno_email.focus();
    return (false);
    }

    theForm.submit;
}

function checar_alt_senha(theForm)
{
    var NomeSite = "UESP           \n\nAviso          \n\n";
    var len = theForm.n_senha.value.length;

    if (theForm.a_senha.value == "") {
    alert(NomeSite+"Informe a Senha Atual.         ");
    theForm.a_senha.focus();
    return (false);
    }

    if (theForm.n_senha.value == "") {
    alert(NomeSite+"Informe a Nova Senha.         ");
    theForm.n_senha.focus();
    return (false);
    }

    if (len <= 5) {
    alert(NomeSite+"Informe a Nova Senha. (mínimo 6 caracteres e máximo 10 caracteres)   ");
    theForm.n_senha.focus();
    return (false);
    }

    if (theForm.c_senha.value != theForm.n_senha.value) {
    alert(NomeSite+"Confirme a Nova Senha.         ");
    theForm.c_senha.focus();
    return (false);
    }

    theForm.submit;
}

function checar_alt_email(theForm)
{
    var NomeSite = "UESP           \n\nAviso          \n\n";

    if (theForm.email.value.indexOf("@",0) == -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    return (false);
    }

    x = theForm.email.value.length;
    x = x - 1;

    if (theForm.email.value.indexOf("@",0) == x) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    return (false);
    }

    if (theForm.email.value.indexOf("@",0) == 0) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    return (false);
    }

    if (theForm.email.value.indexOf(".@",0) != -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    return (false);
    }

    if (theForm.email.value.indexOf("@.",0) != -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    return (false);
    }

    theForm.submit;
}

//

function av_curso(theForm)
{
    var NomeSite = "UESP           \n\nAviso          \n\n";

    if ( (theForm.nota1.value == undefined) && (theForm.nota2.value == undefined) && (theForm.nota3.value == undefined) && (theForm.nota4.value == undefined) && (theForm.nota5.value == undefined) && (theForm.nota6.value == undefined) && (theForm.nota7.value == undefined) && (theForm.nota8.value == undefined) && (theForm.nota9.value == undefined) && (theForm.nota10.value == undefined) && (theForm.nota11.value == undefined) && (theForm.nota12.value == undefined) && (theForm.nota13.value == undefined) && (theForm.nota14.value == undefined) && (theForm.nota15.value == undefined) && (theForm.nota16.value == undefined) && (theForm.nota17.value == undefined) )
    {
    alert(NomeSite+"Você precisa informar todas as Notas.         "+theForm.nota2.value);
    return (false);
    }

    theForm.submit;
}

function clean(theForm)
{
    theForm.login.value = theForm.Plogin.value;
    theForm.Plogin.value = '';
    theForm.pass.value = theForm.Ppass.value;
    theForm.Ppass.value = '';
}

// Vestibular

function validacpf(s){
    var i;
    var c = s.substr(0,9);
    var dv = s.substr(9,2);
    var d1 = 0;

    for (i = 0; i < 9; i++) {
    d1 += c.charAt(i)*(10-i);
    }

    if (d1 == 0){
    return "err";
    }

    d1 = 11 - (d1 % 11);
    if (d1 > 9) d1 = 0;

    if (dv.charAt(0) != d1) {
    return "err";
    }

    d1 *= 2;
    for (i = 0; i < 9; i++) {
    d1 += c.charAt(i)*(11-i);
    }

    d1 = 11 - (d1 % 11);
    if (d1 > 9) d1 = 0;

    if (dv.charAt(1) != d1) {
    return "err";
    }

    return "ok";
}

function checar_vest(theForm)
{
    theForm.bt_conf.disabled = true;
    theForm.bt_conf.value = 'AGUARDE CARREGANDO...';

    var NomeSite = "Vestibular UESP          \n\nAviso          \n\n";

    if (theForm.nome.value == '') {
    alert(NomeSite+"Informe o Nome Completo.         ");
    theForm.nome.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.rg.value == '') {
    alert(NomeSite+"Informe o Número do seu RG.         ");
    theForm.rg.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.rg_orgao.value == '') {
    alert(NomeSite+"Informe o Órgão Expedidor do seu RG.         ");
    theForm.rg_orgao.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.rg_uf.value == 0) {
    alert(NomeSite+"Informe a UF do seu RG.         ");
    theForm.rg_uf.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.datanasc.value == '') {
    alert(NomeSite+"Informe sua Data de Nascimento.         ");
    theForm.datanasc.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.motora[0].checked == false) && (theForm.motora[1].checked == false) ) {
    alert(NomeSite+"Informe a sua Habilidade Motora.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    z = validacpf(theForm.cpf.value);
    if (z == 'err') {
    alert(NomeSite+"Informe o seu CPF corretamente.         ");
    theForm.cpf.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.sexo[0].checked == false) && (theForm.sexo[1].checked == false) ) {
    alert(NomeSite+"Informe o seu Sexo.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.nacionalidade[0].checked == false) && (theForm.nacionalidade[1].checked == false) ) {
    alert(NomeSite+"Informe a sua Nacionalidade.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.lingua[0].checked == false) && (theForm.lingua[1].checked == false) ) {
    alert(NomeSite+"Informe o sua Opção de Língua Estrangeira.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.curso1.value == 0) {
    alert(NomeSite+"Informe a sua 1.ª Opção de Curso.         ");
    theForm.curso1.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.curso2.value == 0) {
    alert(NomeSite+"Informe a sua 2.ª Opção de Curso.         ");
    theForm.curso2.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.curso2.value == theForm.curso1.value) {
    alert(NomeSite+"A sua 2.ª Opção de Curso deve ser diferente da 1.ª Opção.         ");
    theForm.curso2.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.endereco.value == '') {
    alert(NomeSite+"Informe o seu Endereço.         ");
    theForm.endereco.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.bairro.value == '') {
    alert(NomeSite+"Informe o seu Bairro.         ");
    theForm.bairro.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.listEstados.value == '0') {
    alert(NomeSite+"Selecione o Estado.         ");
    theForm.listEstados.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.listCidades.value == '0') {
    alert(NomeSite+"Selecione a Cidade.         ");
    theForm.listCidades.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.cep.value == '') {
    alert(NomeSite+"Informe o CEP.         ");
    theForm.cep.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.tel_resid.value == '') && (theForm.tel_com.value == '') && (theForm.celular.value == '') ) {
    alert(NomeSite+"Informe pelo menos um Telefone.         ");
    theForm.tel_resid.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }
    
    if (theForm.email.value != "" ) {
    
    if (theForm.email.value.indexOf("@",0) == -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    x = theForm.email.value.length;
    x = x - 1;

    if (theForm.email.value.indexOf("@",0) == x) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.email.value.indexOf("@",0) == 0) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if (theForm.email.value.indexOf(".@",0) != -1) {
    alert(NomeSite+"Informe o E-mail corretamente.         ");
    theForm.email.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    }
    
    if (theForm.escola_medio.value == '') {
    alert(NomeSite+"Informe a Escola onde você concluiu o Ensino Médio.         ");
    theForm.escola_medio.focus();
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest01[0].checked == false) && (theForm.quest01[1].checked == false) && (theForm.quest01[2].checked == false) && (theForm.quest01[3].checked == false) && (theForm.quest01[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 1.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest02[0].checked == false) && (theForm.quest02[1].checked == false) && (theForm.quest02[2].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 2.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest03[0].checked == false) && (theForm.quest03[1].checked == false) && (theForm.quest03[2].checked == false) && (theForm.quest03[3].checked == false) && (theForm.quest03[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 3.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest04[0].checked == false) && (theForm.quest04[1].checked == false) && (theForm.quest04[2].checked == false) && (theForm.quest04[3].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 4.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest05[0].checked == false) && (theForm.quest05[1].checked == false) && (theForm.quest05[2].checked == false) && (theForm.quest05[3].checked == false) && (theForm.quest05[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 5.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest06[0].checked == false) && (theForm.quest06[1].checked == false) && (theForm.quest06[2].checked == false) && (theForm.quest06[3].checked == false) && (theForm.quest06[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 6.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest07[0].checked == false) && (theForm.quest07[1].checked == false) && (theForm.quest07[2].checked == false) && (theForm.quest07[3].checked == false) && (theForm.quest07[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 7.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest08[0].checked == false) && (theForm.quest08[1].checked == false) && (theForm.quest08[2].checked == false) && (theForm.quest08[3].checked == false) && (theForm.quest08[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 8.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest09[0].checked == false) && (theForm.quest09[1].checked == false) && (theForm.quest09[2].checked == false) && (theForm.quest09[3].checked == false) && (theForm.quest09[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 9.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest10[0].checked == false) && (theForm.quest10[1].checked == false) && (theForm.quest10[2].checked == false) && (theForm.quest10[3].checked == false) && (theForm.quest10[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 10.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest11[0].checked == false) && (theForm.quest11[1].checked == false) && (theForm.quest11[2].checked == false) && (theForm.quest11[3].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 11.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest12[0].checked == false) && (theForm.quest12[1].checked == false) && (theForm.quest12[2].checked == false) && (theForm.quest12[3].checked == false) && (theForm.quest12[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 12.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest13[0].checked == false) && (theForm.quest13[1].checked == false) && (theForm.quest13[2].checked == false) && (theForm.quest13[3].checked == false) && (theForm.quest13[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 13.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest14[0].checked == false) && (theForm.quest14[1].checked == false) && (theForm.quest14[2].checked == false) && (theForm.quest14[3].checked == false) && (theForm.quest14[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 14.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest15[0].checked == false) && (theForm.quest15[1].checked == false) && (theForm.quest15[2].checked == false) && (theForm.quest15[3].checked == false) && (theForm.quest15[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 15.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest16[0].checked == false) && (theForm.quest16[1].checked == false) && (theForm.quest16[2].checked == false) && (theForm.quest16[3].checked == false) && (theForm.quest16[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 16.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest17[0].checked == false) && (theForm.quest17[1].checked == false) && (theForm.quest17[2].checked == false) && (theForm.quest17[3].checked == false) && (theForm.quest17[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 17.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest18[0].checked == false) && (theForm.quest18[1].checked == false) && (theForm.quest18[2].checked == false) && (theForm.quest18[3].checked == false) && (theForm.quest18[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 18.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest19[0].checked == false) && (theForm.quest19[1].checked == false) && (theForm.quest19[2].checked == false) && (theForm.quest19[3].checked == false) && (theForm.quest19[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 19.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.quest20[0].checked == false) && (theForm.quest20[1].checked == false) && (theForm.quest20[2].checked == false) && (theForm.quest20[3].checked == false) && (theForm.quest20[4].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta da Questão 20.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    if ( (theForm.relacao_2grau[0].checked == false) && (theForm.relacao_2grau[1].checked == false) && (theForm.relacao_2grau[2].checked == false) ) {
    alert(NomeSite+"Informe a sua Resposta sobre o seu Ensino Médio.         ");
    theForm.bt_conf.disabled = false;
    theForm.bt_conf.value = 'CONFIRMAR INSCRIÇÃO';
    return (false);
    }

    theForm.submit;
}

/* JNS */
