function envie() {
    if (document.getElementById("envio").style.display == "none") {
        document.getElementById("envio").style.display = "";
        document.getElementById("txtnome").focus();
    }
    else {
        document.getElementById("envio").style.display = "none";
    }
}
function validaForm() {
    var msg = "";
    var id = "";
    var retorno = true;

    if (trim($("#txtnome").val()) == "") {
        msg = msg + "\n- Informe seu nome";
        if (id == "") { id = "txtnome"; }
        retorno = false;
    }
    else {
        if (trim($("#txtnome").val()).length < 3 || trim($("#txtnome").val()).length > 100) {
            msg = msg + "\n- Seu nome deve conter entre 3 e 100 caracteres";
            if (id == "") { id = "txtnome"; }
            retorno = false;
        }
    }

    if (trim($("#txtemail").val()) == "") {
        msg = msg + "\n- Informe o seu e-mail";
        if (id == "") { id = "txtemail"; }
        retorno = false;
    }
    else {
        if (trim($("#txtemail").val()).length < 5 || trim($("#txtemail").val()).length > 100) {
            msg = msg + "\n- Seu e-mail deve conter entre 5 e 100 caracteres";
            if (id == "") { id = "txtemail"; }
            retorno = false;
        }
        else {
            if (!validaEmail($("#txtemail").val())) {
                msg = msg + "\n- Seu e-mail está inválido";
                if (id == "") { id = "txtemail"; }
                retorno = false;
            }
        }
    }

    if (trim($("#txtnomeamigo").val()) == "") {
        msg = msg + "\n- Informe o nome do seu amigo";
        if (id == "") { id = "txtnomeamigo"; }
        retorno = false;
    }
    else {
        if (trim($("#txtnomeamigo").val()).length < 3 || trim($("#txtnomeamigo").val()).length > 100) {
            msg = msg + "\n- O nome do seu amigo deve conter entre 3 e 100 caracteres";
            if (id == "") { id = "txtnomeamigo"; }
            retorno = false;
        }
    }

    if (trim($("#txtemailamigo").val()) == "") {
        msg = msg + "\n- Informe o e-mail do seu amigo";
        if (id == "") { id = "txtemailamigo"; }
        retorno = false;
    }
    else {
        if (trim($("#txtemailamigo").val()).length < 5 || trim($("#txtemailamigo").val()).length > 100) {
            msg = msg + "\n- O e-mail do seu amigo deve conter entre 5 e 100 caracteres";
            if (id == "") { id = "txtemailamigo"; }
            retorno = false;
        }
        else {
            if (!validaEmail($("#txtemailamigo").val())) {
                msg = msg + "\n- O e-mail do seu amigo está inválido";
                if (id == "") { id = "txtemailamigo"; }
                retorno = false;
            }
        }
    }
    if (!retorno) {
        alert('Ops! Algumas informações estão incorretas: ' + msg);
        $("#" + id).focus();
    }
    return retorno;
}
function abrirComentario() {
    if (document.getElementById("formcomentario").style.display == "none") {
        document.getElementById("formcomentario").style.display = "";
        document.getElementById("btnAbreComentario").style.display = "none";
        document.getElementById("txtnomecomentario").focus();
    }
    else {
        document.getElementById("formcomentario").style.display = "none";
        document.getElementById("btnAbreComentario").style.display = "";
    }
}
function validaComentario() {
    var msg = "";
    var id = "";
    var retorno = true;

    if (trim($("#txtnomecomentario").val()) == "") {
        msg = msg + "\n- Informe seu nome";
        if (id == "") { id = "txtnomecomentario"; }
        retorno = false;
    }
    else {
        if (trim($("#txtnomecomentario").val()).length < 3 || trim($("#txtnomecomentario").val()).length > 100) {
            msg = msg + "\n- Seu nome deve conter entre 3 e 100 caracteres";
            if (id == "") { id = "txtnomecomentario"; }
            retorno = false;
        }
    }

    if (trim($("#txtemailcomentario").val()) == "") {
        msg = msg + "\n- Informe o seu e-mail";
        if (id == "") { id = "txtemailcomentario"; }
        retorno = false;
    }
    else {
        if (trim($("#txtemailcomentario").val()).length < 5 || trim($("#txtemailcomentario").val()).length > 100) {
            msg = msg + "\n- Seu e-mail deve conter entre 5 e 100 caracteres";
            if (id == "") { id = "txtemailcomentario"; }
            retorno = false;
        }
        else {
            if (!validaEmail($("#txtemailcomentario").val())) {
                msg = msg + "\n- Seu e-mail está inválido";
                if (id == "") { id = "txtemailcomentario"; }
                retorno = false;
            }
        }
    }

    if (trim($("#txtcomentario").val()) == "") {
        msg = msg + "\n- Informe o seu comentário";
        if (id == "") { id = "txtcomentario"; }
        retorno = false;
    }
    else {
        if (trim($("#txtcomentario").val()).length < 3 || trim($("#txtcomentario").val()).length > 140) {
            msg = msg + "\n- Seu comentário deve conter entre 3 e 140 caracteres";
            if (id == "") { id = "txtcomentario"; }
            retorno = false;
        }
    }
    if (!retorno) {
        alert('Ops! Algumas informações estão incorretas: ' + msg);
        $("#" + id).focus();
    }
    return retorno;
}
