/**
 * Created by JetBrains PhpStorm.
 * User: Johan
 * Date: 2011-10-03
 * Time: 22:44
 * To change this template use File | Settings | File Templates.
 */

$(window).load(function() {

        var theWindow        = $(window),
            $bg              = $("#bg"),
            aspectRatio      = $bg.width() / $bg.height();

        function resizeBg() {

                if ( (theWindow.width() / theWindow.height()) < aspectRatio ) {
                    $bg
                        .removeClass()
                        .addClass('bgheight');
                } else {
                    $bg
                        .removeClass()
                        .addClass('bgwidth');
                }

        }

        theWindow.resize(function() {
                resizeBg();
        }).trigger("resize");

});
