﻿var arrLenBaileyBackgroundWidths = new Array(1000, 1280, 1440, 1680, 1980);
var arrLenBaileyBackgroundHeights = new Array(768, 760, 885, 998, 1176);
var arrLenBaileyBackgroundFiles = new Array("bg_body.jpg", "bg_body_1280.jpg", "bg_body_1440.jpg", "bg_body_1680.jpg", "bg_body_1980.jpg");

var resizeBak;

function AutoSizing_DoLenBaileyBackground()
{
    var clientWidth = getWindowWidth();
    var clientHeight = getWindowHeight();
    //Find the smallest background that is bigger than the browser bounds
    var index = 0;
    while (clientWidth > arrLenBaileyBackgroundWidths[index] || clientHeight > arrLenBaileyBackgroundHeights[index])
    {
        if (index == arrLenBaileyBackgroundWidths.length-1)
            break;                                              //browser rezolution is larger than any background file
        index++;
    }
    var divElement = document.getElementById("container");
    document.body.style.backgroundImage = "url(images/" + arrLenBaileyBackgroundFiles[index] + ")";
}
