function verificaTipoUsuario(tipoUsuario) {
    var urlBase = "http://www.aspescola.com.br/appl/";
   
    getElement("txt_IdModulo").value = tipoUsuario;
    //gestÃ£o
    if (tipoUsuario == 1) {
        getElement("txt_IdTipoUsuario").value = 1;
        getElement("senha_esquecida").value = urlBase + "portal/html/w_senha_esquecida.jsp";
    //aluno
    } else if (tipoUsuario == 2) {
        getElement("txt_IdTipoUsuario").value = getElement("cboAreaAluno").value;
        getElement("senha_esquecida").value = urlBase + "aluno/w_senha_esquecida.jsp";
    //professor
    } else if (tipoUsuario == 3) {
        getElement("txt_IdTipoUsuario").value = 2;
        getElement("senha_esquecida").value = urlBase + "professor/w_senha_esquecida.jsp";
    //diretor
    } else if (tipoUsuario == 4) {
        getElement("txt_IdTipoUsuario").value = 1;
        getElement("senha_esquecida").value = urlBase + "portal/html/w_senha_esquecida.jsp";
    //Biblioteca
    } else if (tipoUsuario == 5) {
        getElement("txt_IdTipoUsuario").value = 1;
        getElement("senha_esquecida").value = urlBase + "/biblioteca/w_senha_esquecida.jsp";
    }
    getElement("cb_IdTipoUsuario").value  = getElement("txt_IdTipoUsuario").value;
}

function verificaAluno(tipoAluno) {
    getElement("txt_IdTipoUsuario").value = tipoAluno;
    getElement("cb_IdTipoUsuario").value  = getElement("txt_IdTipoUsuario").value;
}







function verifica_sistema() {

    var modulo = getElement("txt_IdModulo").value;
    var escolheuModulo = (modulo != "" && modulo != "0");
    var cdInstituicaoLogin = getElement("txt_CdInstituicao").value;
    var nmLogin = getElement("txt_NmLogin").value;
    var nmLogin = nmLogin.toLowerCase();

    if (escolheuModulo) {
        if ((modulo == 1 || modulo == 2 || modulo == 3) && cdInstituicaoLogin != 5001 && cdInstituicaoLogin != 5002) {
            // Nova url autenticaÃ§Ã£o
            // MÃ³dulos: 1 - Edecacional, 2 - Aluno, 3 - Professor
            document.log.action="http://www.aspescola.com.br/app/appAuth";
        } else if (modulo == 5) {
            document.log.action="http://www.aspescola.com.br/aspescola/biblioteca/frm_verifica_login.jsp";
        } else {
            document.log.action="http://www.aspescola.com.br/aspescola/portal/html/frm_verifica_login.jsp";
        }
        document.log.submit();
    } 
}







function senhaEsquecida() {
    var modulo = getElement("txt_IdModulo").value;
    var escolheuModulo = (modulo != "" && modulo != "0");
    var url = "http://www.aspescola.com.br/aspescola/";
    
    if (escolheuModulo && getElement("txt_CdInstituicao").value != "" && getElement("txt_NmLogin").value != "") {
        document.log.target="_top";
        getElement("senha_esquecida").value = "1";

        if (getElement("txt_IdModulo").value == 1) {
            url = url + "portal/html";
        } else if (getElement("txt_IdModulo").value == 2) {
            url = url + "aluno";
        } else if (getElement("txt_IdModulo").value == 3) {
            url = url + "professor";
        } else if (getElement("txt_IdModulo").value == 4) {
            url = url + "portal/diretor";
        } else {
            url = url + "biblioteca";
        }
        url = url + "/w_senha_esquecida.jsp";
        document.log.action=url;
        document.log.submit();
    } else {
        alert("Selecione a InstituiÃ§Ã£o, Login e o ServiÃ§o");
        getElement("senha_esquecida").value = "1";
    }
}

function getURLParam(strParamName){
   var strReturn = "";
   var strHref = window.location.href;
   if ( strHref.indexOf("?") > -1 ){
     var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
     var aQueryString = strQueryString.split("&");
     for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
       if (
 				 aQueryString[iParam].indexOf(strParamName.toLowerCase() + "=") > -1 ){
         var aParam = aQueryString[iParam].split("=");
         strReturn = aParam[1];
         break;
       }
     }
   }
   strReturn = unescape(strReturn);

   for ( var iParam = 0; strReturn.indexOf("+") > -1; iParam++ ){
	   strReturn = strReturn.replace("+"," ");
   }
	   strReturn = strReturn.replace("\\n"," ");
   return strReturn;
 }

function falhaLogin() {
  var mensagem = getURLParam("txt_MsgErro");
  if (getURLParam("txt_MsgErro") != '') {
		alert(mensagem);
  }
}

function isNumber(valor){
  if (isNaN(valor) || valor.indexOf(' ') >= 0) {
    alert ("Valor InvÃ¡lido - SÃ³ Ã© permitido NÃšMEROS");
    return ('');
  } else {
    return (valor)
  }
}


function getElement(nmElement) {
    var element = undefined;
    if(document.all) {
        element = document.all[nmElement];
    } else {
        element = document.getElementById(nmElement);
        if (element == null || element == undefined || element == "") {
            element = document.getElementsByName(nmElement)[0];
        }
    }
    return element;
}

function recarrega() {

    if (document.log.cboArea.value == '2') {
        getElement("textoProfessor").style.display = 'none';
        getElement("textoPlantao").style.display = 'none';
        getElement("titComboAluno").style.display = '';
        getElement("comboAluno").style.display = '';
        getElement("textoAluno").style.display = '';
    }
    else if (document.log.cboArea.value == '3') {
        getElement("titComboAluno").style.display = 'none';
        getElement("comboAluno").style.display = 'none';
        getElement("textoAluno").style.display = 'none';
        getElement("textoPlantao").style.display = 'none';
        getElement("textoProfessor").style.display = '';
    }
    else {
        getElement("titComboAluno").style.display = 'none';
        getElement("comboAluno").style.display = 'none';
        getElement("textoAluno").style.display = 'none';
        getElement("textoProfessor").style.display = 'none';
        getElement("textoPlantao").style.display = 'none';
    }
}

function mostra_info_plantao() {
	 getElement("textoAluno").style.display = 'none';
     getElement("textoProfessor").style.display = 'none';
     getElement("textoPlantao").style.display = '';
}

function info_plantao(opcao) {
	if (opcao==1||opcao==5){
	getElement("btnPlantao").style.display = '';
	}else{
	getElement("btnPlantao").style.display = 'none';
	}
	 
}

function f_Maiusculo (param){
    param = param.toUpperCase();
    return (param);
}

