$(document).ready(function () {
    var args = {};
    
    // Animate in the center column
    
    (function () {
        // Animate in the center column
        $('#centerCol').animate({
            opacity : 'show'
        },{
            duration: 1200,
            complete: function () {
                // Animate in the mailing list
                $('#mailingListWidget').slideDown();
            }
        });
    }());
    
    // Do once the DOM is ready.
    $('#nav li span.category').click(function() {
        $(this).parent('li').siblings().find('ul:visible').animate({ height: 'hide' }, 800).animate({ opacity: 'hide' }, 800)
        $(this).parent('li').siblings().find('span.category').css('font-style','normal');
        $(this).parent('li').find('ul:first').animate({ height: 'show', opacity: 'show' }, 800);
        $(this).css('font-style', 'oblique');
    });
    
    $('#nav a').click(function() {
        var url = $(this).attr('href');
        var callback = function() { window.location = url; };
        $('#nav .category').parent('li').find('ul:visible').animate({ height: 'hide' }, 800).animate({ opacity: 'hide' }, 800);
        $('#centerCol:visible').animate({ opacity: 'hide' }, 700, '', callback);
        return false;
    });
    
    // Fading to show focus for top level nav items.
    $('#nav').children().hover(function() {
        $(this).siblings().stop().fadeTo(500, 0.5);
    }, function() {
        $(this).siblings().stop().fadeTo(500, 1);
    });
    
    // Fading to show focus for sub nav items.
    $('#nav li ul').children().hover(function() {
        $(this).siblings().stop().fadeTo(500, 0.5);
    }, function() {
        $(this).siblings().stop().fadeTo(500, 1);
    });
});