/*!
 * jQuery JavaScript Library for PortalNef
 * http://jquery.com/
 *
 * Copyright 2010, Jonathan Pereira
 * Dual licensed under the MIT or GPL Version 2 licenses.
 *
 * Date: 15/10/2010
**/

$(document).ready(function(){

    /*
     *
     * Hide text on focus
     *
     **/

    $('.label').each(function(){

        if($(this).val() == "")
            $(this).val( $(this).attr('title') );

    });

    $('.label').focus(function(){

        if( $(this).val() == $(this).attr('title') ) $(this).val('');
    });

    $('.label').blur(function(){

       if( $(this).val() == '' ) $(this).val( $(this).attr('title') );

    });

    /*
     *
     * Default validation
     *
     **/

    $('.form_validate').validate({

        rules:{

            'data[mail]':{
                email:true
            }

        },

        messages:{
            'data[mail]':''
        }

    });

    /*
     *
     * Button Access Central
     *
     **/

    $('#access_central').click(function(){

        location.href = 'central-nef';

    });

    if( $('#lastTweets').length > 0 ){

        $.post( 'inc/twitter.load.inc.php' ,
                function(a){
                
                    $('#lastTweetsContent').html( a );
                    
                });
        
    }

    if( showSenha == true ){

       $('#central-login').hide();

       $('#esqueci-senha').show();

    }else{

        $('#esqueci-senha').hide();

    }

    

    $('#btn-senha').click(function(){

       $('#central-login').hide();

       $('#esqueci-senha').show();

       return false;

    });

    $('#btn-senha-voltar').click(function(){

       $('#central-login').show();

       $('#esqueci-senha').hide();

       return false;

    });

    $('#senhaForm').validate({

        rules:{

            'data[mail]':{
                email:true
            }

        },

        messages:{
            'data[mail]':''
        }

    });

    $('#newsletterForm').validate({

        rules:{

            'data[mail]':{
                email:true
            },
            'data[name]':{
                diferentTo:'Digite seu nome'
            }

        },

        messages:{
            'data[mail]':'',
            'data[name]':''
        }

    });
    


});
