﻿$(document).ready(function() {
    verificarBrowser();
    goFocus();
    // Traduz frases do componente reCaptcha do Google
    $("#recaptcha_instructions_image, #recaptcha_instructions_error").html("Digite as palavras acima:");
    $("#recaptcha_reload").parent().attr("title", "Obter nova imagem");
    $("#recaptcha_switch_audio").parent().attr("title", "Ouvir palavras");
    $("#recaptcha_whatsthis").parent().attr("title", "Conheça mais sobre o reCaptcha (inglês)");
});

function verificarBrowser()
{
    if(!($.browser.msie) && !($.browser.mozilla))
        browserIncompativelAviso();
}

function browserIncompativelAviso()
{
    $("#browserName").html("Você está utilizando o navegador <strong>'"+ getBrowserFullname() + 
        "'</strong>. <br /><br />O Anapro não foi homologado nesse navegador e por conta disso você poderá "+
        "ter problemas. <br /><br />Recomendamos que você instale outro navegador para "+
        "utilizar o Anapro. <br /><br />Confira abaixo a lista de navegadores homologados para o Anapro:");
    $("#browserWarning").show("slow");
    $("#container").hide();
    $(".rodape").hide();
    $("#btnWarningOk").click(function(){
        $("#browserWarning").hide();
        $("#container").show("slow");
        $(".rodape").show("slow");
        goFocus();
    });
}

function getBrowserFullname()
{
    var fullname;
    var versao;
    
    versao = $.browser.version;
    fullname = "unknow";
    
    if($.browser.msie)
        fullname = "Internet Explorer";
    if($.browser.mozilla)
        fullname = "Firefox";
    if($.browser.opera)
        fullname = "Opera";
    if($.browser.safari)
        fullname = "Safari";
    
    return fullname + " " + versao;
}

function goFocus()
{
    var txtEmail = document.getElementById("txtEmail");
    var txtSenha = document.getElementById("txtSenha");
        
    try
    {
        if(txtEmail.value == "")
            txtEmail.focus();
        else
            txtSenha.focus();
    }
    catch(e) {}
}
