function popUp(URL, width, height) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + "');");

}

function disableCheck(obj)
{
	return !obj.disabled;
}

function fechar() {
opener.location.reload(true);
self.close();
}




/*function valideFormLoginAluno(oForm,matricula,senha)
{
  var msg = valideLoginAluno(matricula,senha)
  if(msg == null) {
    return true;
  }
  else {
    alert(msg);  
    return false;
  }
}*/
 /**
   * Não está sendo validado o dígito verificador!
   */

function valideFormSolicitarSenha(doc)
{
  var matricula = doc.getElementById('form1:matricula');
  var cpf = doc.getElementById('form1:cpf');
  var dataNascimento = doc.getElementById('form1:dataNascimento');
  
  var msg = null;
  
if (!valideMatriculaAluno(matricula.value)) {  
    matricula.focus();
    msg = 'Matrícula Inválida !';
}

if (cpf == null || cpf == '') {  
    cpf.focus();
    cpf = 'Preencha o CPF !';
}

if (dataNascimento == null || dataNascimento == '') {  
    dataNascimento.focus();
    dataNascimento = 'Preencha a Data de Nascimento !';
}
  
  if(msg != null) {
    alert(msg);  
    return false;
  }else{
	  return true;
  }

}

function valideFormLogin(oForm,role)
{
  var usernameText = oForm.username;
  var passwdText = oForm.j_password;
  var msg = 'Tipo de Usuário Inexistente';
  if (role == 'Aluno') 
    msg = valideLoginAluno(usernameText,passwdText);
  else
    if (role == 'Professor')
      msg = valideLoginProfessor(usernameText,passwdText);
    else 
      if (role == 'Administrador')
         msg = valideLoginAdmin(usernameText,passwdText);
      else
        if (role == 'Curso')
          msg = valideLoginCurso(usernameText,passwdText);
        else
         if (role == 'Departamento')
           msg = valideLoginDepartamento(usernameText,passwdText);
  if(msg == null) {
    var newVal = oForm.username.value + '$#' + role;    
    oForm.j_username.value = newVal;    
    return true;
  }
  else {
    alert(msg);  
    return false;
  }
}   
   
function valideLoginAluno(matricula,senha) {
  if (!valideMatriculaAluno(matricula.value)) {  
    matricula.focus();
    return 'Matrícula Inválida!';
  }
  if (!valideSenhaAluno(senha.value)) {
    senha.focus();
    return 'Senha Inválida!';
  }  
  return null;
}

function valideLoginProfessor(matricula,senha) {
  /*if (!valideMatriculaAluno(matricula.value)) {  
    matricula.focus();
    return 'Matrícula Inválida!';
  }
  if (!valideSenhaAluno(senha.value)) {
    senha.focus();
    return 'Senha Inválida!';
  } */ 
  return null;
}

function valideLoginAdmin(matricula,senha) { 
  return null;
}

function valideLoginDepartamento(matricula,senha) { 
  return null;
}

function valideLoginCurso(matricula,senha) { 
  return null;
}
   
function valideMatriculaAluno(matricula) {
  if (matricula == null)
    return false;
  if (matricula.length != 8)
    return false;
  if (!isInteger(matricula))
    return false;
  if (matricula.charAt(2) != '1' && matricula.charAt(2) != '2' && matricula.charAt(2) != '3' && matricula.charAt(2) != '4') // O Semestre deve ser 1 ou 2 ou 3 ou 4.
    return false;
  return true;
}

function valideSenhaAluno(senha) {
  if (senha == null || senha == '')
    return false;
  if (senha.length > 8)
    return false;
  return true;
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

