var naturalWidth = 1000;
var naturalHeigth = 580;
function resize() {
    var de = document.documentElement;
    var x = window.innerWidth || self.innerWidth || (de && de.clientWidth) || document.body.clientWidth;
    var y = window.innerHeight || self.innerHeight || (de && de.clientHeight) || document.body.clientHeight;

    var img = $("[id$='backgroundImage']");
    if (!img.length) return;

    img = img.get(0);
    var width = img.naturalWidth || naturalWidth;
    var height = img.naturalHeight || naturalHeigth;

    var xFactor = x / width;
    var yFactor = (y - 120) / height;

    if (xFactor > yFactor) {
        width = width * xFactor;
        height = height * xFactor;
    } else {
        width = width * yFactor;
        height = height * yFactor;
    }

    img.width = width;
    img.height = height;
}
window.onload = resize;
window.onresize = resize;