function scrollbarWidth() {
    var div = $('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div>');
    // Append our div, do our calculation and then remove it
    $('body').append(div);
    var w1 = $('div', div).innerWidth();
    div.css('overflow-y', 'scroll');
    var w2 = $('div', div).innerWidth();
    $(div).remove();
    return (w1 - w2);
}

function checkWindowHeight() {
    var windowHeight = $(window).height();
    var windowWidth = $(window).width();
    var contentHeight = $('#box-content').height();

    var scrollbar = 0;

    if(windowHeight-56 < contentHeight) {
        scrollbar = scrollbarWidth();
    }

    $('div#overlay').width(windowWidth-20-scrollbar).height(windowHeight-20);

    if(contentHeight < windowHeight-56) {
        $('#box-content').css('top','auto');
        $('#box-content').css('bottom','33px');
    }
    if(windowHeight <= 583) {
        $('#box-content').css('top','56px');
        $('#box-content').css('bottom','auto');
    }
}

function resizeSpacerBox() {
    var windowWidth = $(window).width();
    var contentHeight = $('#box-content').height();
    
    if(windowWidth > 1001){
        var spacerWidth = windowWidth - 1001 + 'px';
        $('#box-spacer').width(spacerWidth);
    }
}


