
var resizeBackground = function() {
    var bg = $('#bg img'),
        content = $('#centered'),
        r1 = $(window).height() / $(window).width(),
        r2 = bg.height() / bg.width(),
        offset;
    if (r1 > r2) {
        offset = ($(window).width() - bg.width()) / 2;
        bg.css({ left: offset, top: 0, height: '100%', width: 'auto' });
    } else {
        offset = ($(window).height() - bg.height()) / 2;
        bg.css({ left: 0, top: offset, height: 'auto', width: '100%' });
    }

    content_top = ($(window).height() / 2) - (content.height() / 2);
    content.css({ top: content_top });
};

$(document).ready(function() {
    resizeBackground();
    // $('#bg').css({ opacity: 0 });
});

$(window).resize(resizeBackground);
$(window).load(function() {
    resizeBackground();
    // $('#bg').css({ opacity: 1.0 });
    resizeBackground();
});

