var NFB = NFB || {};

NFB.Splash = {
    __supportsCSS3: ($.browser.webkit && parseFloat($.browser.version) > 400), // || ($.browser.mozilla && parseFloat($.browser.version) >= 2),
    init: function () {
        $('#sites a').hover(this.fadeInactiveImagesOut, this.fadeInactiveImagesIn);
    },
    fadeInactiveImagesOut: function (e) {
        var current = $(this).prevAll().size();
        
        if(NFB.Splash.__supportsCSS3) {
            $(this).addClass('current');
            $('#sites a:not(a:eq(' + current + '))').addClass('off');
        } else {
            $('img', this).animate({
                top: -5
            }, 250);
            $('#sites a:not(a:eq(' + current + '))').addClass('css2-off').animate({
                opacity: 0.75
            }, 350);
        }
    },
    fadeInactiveImagesIn: function (e) {
        if(NFB.Splash.__supportsCSS3) {
            $(this).removeClass('current');
            $('#sites a.off').removeClass('off');
        } else {
            $('img', this).animate({
                top: 0
            }, 250);
            $('#sites a.css2-off').animate({
                opacity: 1
            }, 350);
        }
    }
};

NFB.Blog = {
    init: function () {
        var self = this;
        setTimeout(function () {
            $('.post .left').css('overflow', 'auto').jScrollPane({
                showArrows: true,
                mouseWheelSpeed: 1
            });
            $('#content').jScrollPane({
                showArrows: true,
                horizontalDragMinWidth: 124,
                horizontalDragMaxWidth: 124,
                mouseWheelSpeed: 1
            });
            self.resizeMainContent();
        }, 10);
        // Facebook needs to load
        setTimeout(function () {
            $('.post .left').data('jsp').reinitialise();
        }, 1000);
    },
    resizeMainContent: function () {
        var width = 0;
        
        var p = function (value) {
            return parseInt(value);
        };
        
        $('.post').each(function () {
            var i = $(this);
            width += p(i.outerWidth());
        });
        
        width += 10;
        // alert(width);
        $('#content .posts').css('width', width);
        $('#content').data('jsp').reinitialise();
    }
};
