// Janelas pop-up
function abrejanela(a_source, a_window, a_width, a_height)
{
    var screen_width = 800, screen_height = 600;
    if (document.getElementById || document.layers)
    {
        screen_width = screen.availWidth;
        screen_height = screen.availHeight;
    }
    var left_pos = Math.round((screen_width - a_width) / 2), top_pos = Math.round((screen_height - a_height) / 2);

    window.open(a_source, a_window, 'toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,width=' + a_width + ',height=' + a_height + ',left=' + left_pos + ',top=' + top_pos);
}

// Valida o formulário
function verifica()
{
    ema = document.forms[0].email.value.length;

    var v_tel = document.forms[0].telefones.value;
    t_tel = (v_tel.replace(/^\W+/,'')).replace(/\W+$/,'');
    tel = t_tel.length;

    if (ema < 1 && tel < 7)
    {
        alert('Por favor, informe um e-mail ou telefone.');
        document.forms[0].email.focus();
        return false;
    }
    else if (ema > 0)
    {
        var expressao = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;

        if (!expressao.test(document.forms[0].email.value))
        {
            alert('O e-mail parece não ser válido. Por favor, verifique.');
            document.forms[0].email.focus();
            return false
        }
        else
        {
            return true;
        }
    }
    else
    {
        return true;
    }
}
