$(function() {
    Shadowbox.init({
        players: ['swf']
    });

    $('#blog-page-next').click(function() {
        $('.blog').animate({ scrollTop: $('.blog').scrollTop() + 212 });
        return false;
    });

    $('#blog-page-back').click(function() {
        $('.blog').animate({ scrollTop: $('.blog').scrollTop() - 212 });
        return false;
    });

    $('.frontpage').mouseover(function() {
        $('.frontpage .play').css({ visibility: 'visible' });
    });

    $('.frontpage').mouseout(function() {
        $('.frontpage .play').css({ visibility: 'hidden' });
    });

    $('.frontpage a').click(function() {
        var id = $('.frontpage').attr('id');
        Shadowbox.open({
            content: '<iframe src="http://player.vimeo.com/video/' + id + '?autoplay=1" width="800" height="450" frameborder="0"></iframe>', 
            width: 800,
            height: 450,
            player: 'html',
            options: {
                overlayOpacity: 0.8
            }
        });
        return false;
    });

    $('.videos img').click(function() {
        var title = $(this).attr('alt');
        var src = $(this).attr('src');
        var id = $(this).attr('id');

        $('.frontpage .thumb').fadeOut(300, function() {
            $('.frontpage .thumb').attr('src', src);
            $('.frontpage .thumb').fadeIn(300);
            $('.frontpage').attr('id', id);
        });

        $('.frontpage .title').fadeOut(300, function() {
            $('.frontpage .title').html(title);
            $('.frontpage .title').fadeIn(300);
        });
    });
});
