(function($){
    var ratio = [];
    $.fn.supersize = function() {
        var parent = $("#background");
        $(document).ready(function() {            
            parent.children().each(function (i) {                
                //ratio[i] = $(this).height() / $(this).width();                
                ratio[i] = 900 / 1200;                
            });
            parent.resizenow();
        });        
        $(window).bind('resize', function () {
           parent.resizenow();
        });
    };
    $.fn.resizenow = function() {
        var parent = $("#background");
        var browserwidth = $(window).width();
        var browserheight = $(window).height();

        parent.height(browserheight);
        parent.width(browserwidth);
        parent.children().each(function (i) {            
            if ((browserheight/browserwidth) > ratio[i]) {
                $(this).height(browserheight);
                $(this).width(browserheight / ratio[i]);
            } else {
                $(this).width(browserwidth);
                $(this).height(browserwidth * ratio[i]);
            }
            $(this).css('left', (browserwidth - parent.width())/2);
            $(this).css('top', (browserheight - parent.height())/2);
        });   
    };
})(jQuery);

