const elementos = document.querySelectorAll('[data-anima]');
const animacaoclass = 'animacao';

function animascroll() {
    const topopaginajanela = window.pageYOffset + ((window.innerHeight * 3) / 4);
    elementos.forEach(function (elemento) {
        if (topopaginajanela > elemento.offsetTop) {
            elemento.classList.add(animacaoclass);
        } else {
            elemento.classList.remove(animacaoclass);
        }
    });
}

if (elementos.length) {
    window.addEventListener('scroll', function () {
        animascroll();
    });
}



$(document).ready(function() {
    $('#contact-form').submit(function(e) {
        e.preventDefault();

        $.ajax({
            type: 'POST',
            url: 'send_email.php',
            data: $(this).serialize(),
            success: function(response) {
                $('#response-message').html(response);

                // Clear form fields
                $('#contact-form')[0].reset();

                // Reload captcha
                $('img[alt="CAPTCHA"]').attr('src', 'captcha.php?' + (new Date()).getTime());
            },
            error: function(response) {
                $('#response-message').html('Ocorreu um erro ao enviar sua mensagem. Por favor, tente novamente.');
            }
        });
    });
});


