$(document).ready(function(){

    // LINKS EXTERNOS
    $('a.target_blank, .redes a, .banner_blog_twitter a, .menu a, .to_milkiestore, .imagens a').click(function(){
        window.open($(this).attr('href'));
        return false;
    });

    // REDES > HOVER
    $('.redes a').hover(function(){
        $('.a_hover', this).show();
    },function(){
        $('.a_hover').hide();
    });

    if($('#tweets').length > 0){
        twitterAPI({
            'Utilizador':TWITTER_NOME,
            'Tweets':TWITTER_VIEWS,
            'containerID':'#tweets'
        });
    }

var themeViewerState = 'down';
$(function(){
    $('.change-background').click(
        function(){
            $('body').css('background-image', 'url('+$(this).attr('href')+')');
            var t = $(this).attr('rel');
            $.get(BASE_URI+'banners/gravabg/'+t);
            if(themeViewerState == 'up'){
                themeViewerState = 'down';
                $('#change-theme').animate({ top : "-226px" }, 200);
                $('#cancelChangeThemeButton').hide("slow");
                $('#changeThemeButton').show("slow");
                $('#changeThemeButton').animate({ marginLeft: '0px', marginTop: '0px'});
            }else{
                themeViewerState = 'up';
                $('#change-theme').animate({ top : "0px" }, 200);
                $('#changeThemeButton').animate({ marginLeft: '-30px', marginTop: '-30px'});
            }
            return false;
        }
    );
});
     var buttonThemeStatus = 1;
    $('#cancelChangeThemeButton').click(function(){
        $(this).hide("slow");
        $('#changeThemeButton').show("slow");
        $('#changeThemeButton').animate({ marginLeft: '0px', marginTop: '0px'});
        buttonThemeStatus = 1;
        if(themeViewerState == 'up'){
            themeViewerState = 'down';
            $('#change-theme').animate({ top : "-226px" }, 200);
        }else{
            themeViewerState = 'up';
            $('#change-theme').animate({ top : "0px" }, 200);
        }
    });
    $('#changeThemeButton').click(function(){
        $(this).animate({ marginLeft: '-30px', marginTop: '-30px'});
        $(this).hide("slow");
        $('#cancelChangeThemeButton').show("slow");
        buttonThemeStatus = 0;
        if(themeViewerState == 'up'){
            themeViewerState = 'down';
            $('#change-theme').animate({ top : "-226px" }, 200);
        }else{
            themeViewerState = 'up';
            $('#change-theme').animate({ top : "0px" }, 200);
        }
    });
    
    $('#home-eventos .item').hover(
        function(){$(this).find('div.rollover').animate({ top : "10px" }, 200);},
        function(){$(this).find('div.rollover').animate({ top : "200px" }, 400);}
    );
    $('#home-temas .item').hover(
        function(){$(this).find('div.rollover').animate({ top : "10px" }, 200);},
        function(){$(this).find('div.rollover').animate({ top : "200px" }, 400);}
    );


});
