﻿$(window).load(function () {
    var theWindow = $(window),
    $bg = $('#bg'),
    aspectRatio = $bg.width() / $bg.height();
    function resizeBg() {
        $('#bg').hide()
        if ((theWindow.width() / theWindow.height()) < aspectRatio) {
            $bg.removeClass().addClass('bgheight').show();
        } else {
            $bg.removeClass().addClass('bgwidth').show();
        }
    }
    theWindow.resize(function () {
        resizeBg();
    }).trigger("resize");
});

