jQuery(document).ready( function($) {
    
    // welcome
    var splash = $('#splash');
    var welcomeWrap = $('.welcome');
    var welcomeH1 = $('.welcome h1');

    welcomeWrap.hide();
    splash.hide();

    splash.fadeIn(2000).fadeOut(2000, function() {
        splash.remove();
        welcomeWrap.fadeIn(2000);
        welcomeH1.animate({
            'margin-bottom': '2em'
        }, 2000);
    });
    
    
    // fade in
    $('.page #content').hide().fadeIn(1500);


    // fancybox
    $('.fancybox').fancybox({
        padding: 0
    });
    
    
    // batcher
    var articleBatcher = function () {
        $('.article').not(':first').hide();
    
        $('.article .prev').click( function() {
            var thisArticle = $(this).parent();
            var prevArticle = thisArticle.prev();
    
            thisArticle.fadeOut(1000, function() {
                prevArticle.fadeIn(1000);
            });
        });
        $('.article .next').click( function() {
            var thisArticle = $(this).parent();
            var nextArticle = thisArticle.next();
    
            thisArticle.fadeOut(1000, function() {
                nextArticle.fadeIn(1000);
            });
        }); 
    };
    
    var galleryBatcher = function () {
        $('.gallery').not(':first').hide();
    
        $('.gallery .prev').click( function() {
            var thisGallery = $(this).parent();
            var prevGallery = thisGallery.prev();
    
            thisGallery.fadeOut(1000, function() {
                prevGallery.fadeIn(1000);
            });
        });
        $('.gallery .next').click( function() {
            var thisGallery = $(this).parent();
            var nextGallery = thisGallery.next();
    
            thisGallery.fadeOut(1000, function() {
                nextGallery.fadeIn(1000);
            });
        });
    };
        
    articleBatcher();
    galleryBatcher();
});
