/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$(document).ready(function() {
        if($("#msg").val() == "erroCampos"){
            $("#alertCadastro").html("Preencha o e-mail para receber seus dados de acesso.");
            $("#alertCadastro").show();
        }else if($("#msg").val() == "naoExisteEmail"){
            $("#alertCadastro").html("O email informado não se encontra cadastrado.");
            $("#alertCadastro").show();
        }else if($("#msg").val() == "sucesso"){
            $("#alertSucesso").show();
        }else if($("#msg").val() == "erro"){
            $("#alertCadastro").html("Erro no cadastro, por favor tente novamente mais tarde.");
            $("#alertCadastro").show();
        }

       $("#enviar").click(function() {
           if(validaCadastro()){
               $("#frmEsqueciSenha").submit();
            }
       });
});


function validaCadastro(){
    try{
        limpaAlert();
        if($("#email").val() == ""){
            $("#alertCadastro").html("Infome seu email");
            $("#alertCadastro").show();
            $("#email").focus();
            return false;
        }else if(!isEmail($("#email").val())){
            $("#alertCadastro").html("O email é inválido");
            $("#alertCadastro").show();
            $("#email").focus();
            return false;
        }else{
            return true;
        }
    }catch(err){
        alert(err.description);
        return false;
    }
}

function limpaAlert() {
   $("#alertCadastro").hide();
   $("#alertSucesso").hide();
}

