function show_hide(elmnt_id)
{
      var element = document.getElementById(elmnt_id);
      if(element.style.display == 'none')
      {
         element.style.display = 'block';
      }
      else
      {
         element.style.display = 'none';
      }
      return false;
}

function Excluir(arg)
{
       var exclusao = window.confirm('ATENÇÃO: Deseja realmente excluir?');
       if(exclusao)
       {
          document.forms[0].op.value = arg;
          document.forms[0].submit();
       }
}

function fDATA(arg)
{
      nChar = document.getElementById(arg);
      switch(nChar.value.length)
      {
        case 2: nChar.value += "/";

        break;

        case 5: nChar.value += "/";
        break;
      }
}

function Editar(arg, arg1, arg2, arg3, arg4)
{
       document.forms[0].op.value = arg;
       document.forms[0].Disciplina.value = arg1;
       document.forms[0].Turma.value = arg2;
       document.forms[0].Ano.value = arg3;
       document.forms[0].Serie.value = arg4;
       document.forms[0].submit();
}

function Faltas(arg, arg1, arg2, arg3, arg4, arg5)
{
       document.forms[0].op.value = arg;
       document.forms[0].Disciplina.value = arg1;
       document.forms[0].Turma.value = arg2;
       document.forms[0].Ano.value = arg3;
       document.forms[0].Serie.value = arg4;
       document.forms[0].Mes.value = arg5;
       document.forms[0].submit();
}

function Notas(arg, arg1, arg2, arg3, arg4, arg5, arg6)
{
       document.forms[0].op.value = arg;
       document.forms[0].Disciplina.value = arg1;
       document.forms[0].Turma.value = arg2;
       document.forms[0].Ano.value = arg3;
       document.forms[0].Serie.value = arg4;
       document.forms[0].Nota.value = arg5;
       document.forms[0].Bimestre.value = arg6;  
       document.forms[0].submit();
}

function Detalhes(arg, arg1)
{
       document.forms[0].op.value = arg;
       document.getElementById("Id").value=arg1;
       document.forms[0].submit();
}

function ADDLista(arg1)
{
    if(adicionaLista(document.forms[0]))
    {
       document.forms[0].op.value = arg1;
       document.forms[0].submit();
    }
}

function EnviaMSG(arg1)
{
    if(enviarMSG(document.forms[0]))
    {
       document.forms[0].op.value = arg1;
       document.forms[0].submit();
    }
}


function Submit(arg)
{
       document.forms[0].op.value = arg;
       document.forms[0].submit();
}

function Enviar(arg)
{
       document.forms[0].op.value = arg;
       document.forms[0].submit();
}

function Senha(arg1)
{
    if(versenha(document.forms[0]))
    {
       document.forms[0].op.value = arg1;
       document.forms[0].submit();
    }
}

function fCPF(arg)
{
      nChar = document.getElementById(arg);
      switch(nChar.value.length)
      {
        case 3: nChar.value += ".";
        break;

        case 7: nChar.value += ".";
        break;

        case 11: nChar.value += "-";
        break;
      }
}

function Verifica_Campo(string)
{
       var temp = "";
       comprimento = string.length;
       for (a=0;a <= (comprimento-1);a++)
       {
          valor = string.substr(a,1);
          if(valor=="'")
          {
            temp += "";
          }
          else
          {
            temp += valor
          }
       }
       return temp;
}

function Login(arg)
{
     if(verlogin(document.forms[0]))
     {
       document.forms[0].op.value = arg;
       document.forms[0].submit();
     }
}

function Campo_Branco(campo)
{
     if(campo.value=="")
     {
       return true;
     }
     else
     {
       return false;
     }
}

function Campo_Zero(campo)
{
  if(campo.selectedIndex==0)
  {
    return true;
  }
  else
  {
    return false;
  }
}

function IniciaAjax()
{
        var ajax;
        if(window.XMLHttpRequest)
        {       // Mozilla, Safari,...
                ajax = new XMLHttpRequest();
        }
        else if (window.ActiveXObject)
        {       // IE
                ajax = new ActiveXObject("Msxml2.XMLHTTP");
                if (!ajax)
                {
                  ajax = new ActiveXObject("Microsoft.XMLHTTP");
                }
        }
        else
        {
           alert("Seu navegador não possui suporte a essa aplicação!");
        }
        return ajax;
}

function versenha(form)
{
      if(Campo_Branco(form.Senha_atual)==true)
      {
            alert("Por Favor, Digite a sua Senha Atual!");
            form.Senha_atual.focus();
            return false;
       }

       if((Campo_Branco(form.Senha_nova)==true))
       {
            alert("Por Favor, Peencha sua nova Senha pessoal!");
            form.Senha_nova.focus();
            return false;
       }

       if((Campo_Branco(form.Senha_confirma)==true))
       {
            alert("Por Favor, Repita a nova Senha pessoal!");
            form.Senha_confirma.focus();
            return false;
       }
       if(form.Senha_nova.value != form.Senha_confirma.value)
       {
            alert("Por Favor, O valor digitado no campo Confirma Senha deve ser igual ao valor digitado no campo Nova Senha!");
            form.Senha_nova.focus();
            return false;
       }
       return true;
}

function verlogin(form)
{
      if(Campo_Branco(form.User)==true)
      {
            alert("Por Favor, Preencha o campo Usuário!");
            form.User.focus();
            return false;
       }

       if((Campo_Branco(form.Pwd)==true))
       {
            alert("Por Favor, Peencha o campo Senha pessoal!");
            form.Pwd.focus();
            return false;
       }

       if((Campo_Branco(form.Cod)==true))
       {
            alert("Por Favor, Repita o código da imagem ao lado!");
            form.Cod.focus();
            return false;
       }
       return true;
}

function enviarMSG(form)
{
      if((Campo_Branco(form.Email)==true))
      {
            alert("Por Favor, informe o seu email para receber a resposta desta mensagem!");
            form.Email.focus();
            return false;
      }

      return true;
}