/* FUNCOES */

jQuery.noConflict();
jQuery(document).ready(function(){

    // fechar caixa de feedback (mensagem)
    jQuery('#msg .fechar').click(function(){
        jQuery(this).parent().fadeOut(1000);
    })

    // validar e enviar contato
    jQuery('#enviarContato').click(function(){
        if (
            !jQuery('#nome').val() ||
            !jQuery('#email').val() ||
            !jQuery('#assunto').val() ||
            !jQuery('#mensagem').val()
        ) {
            jQuery('#msgCorpo').html('Todos os campos são de preenchimento obrigatório.');
            jQuery('#msg').show();
        } else {
            loading();
            jQuery('#formContato').submit();
        }
    })

    // recuperar senha
    jQuery('#recuperarSenha').click(function(){

        var email   = jQuery('#email2').val();
        if (!email) {
            jQuery('#msgCorpo').html('Forneça o e-mail!');
            jQuery('#msg').show();
            return false;
        }

        loading();

        jQuery.post(
            'ajax/recuperarSenha.php',
            {
                email : email
            },
            function(retorno){
                jQuery('#msgCorpo').html(retorno);
                jQuery('#msg').show();
            }
        )
    })

    // agenda de obrigacoes
    jQuery('.categorias .categoria').click(function(){
        var a = jQuery(this).siblings('.arquivos');
        if (a.is(':hidden')) {
            a.slideDown()
        } else {
            a.slideUp()
        }
    })

    // validação no formulario de contato
    jQuery('#formularioContato #submit').click(function(){
        if (
            !jQuery('#nome').val() ||
            !jQuery('#email').val() ||
            !jQuery('#assunto').val() ||
            !jQuery('#mensagem').val()
        ) {
            alert('Preencha todos os campoas antes de enviar.');
            return false;
        }
    })

})


/*  */
function loading(){
    var html    = 'Aguarde por favor... ';
    html        += '<img src="/hs/imgs/loading.gif" />';
    jQuery('#msgCorpo').html(html);
    jQuery('#msg').show();
}