﻿leftNavLeftMargin = 4;
leftNavWidth = 160;
leftNavRightMargin = 8;
leftNavMarginTop = 4;
leftNavMarginBottom = 4;
contentRightMargin = 8;
contentWidth = leftNavLeftMargin + leftNavWidth + leftNavRightMargin + contentRightMargin;

minimumWidth = 960;
minimumWidth = 800;

bannerTopMargin = 8;
bannerHeight = 96;
bannerBottomMargin = 8;
pageContentPadding = 116;
pageContentPadding = 96;
minimumHeight = 410;
minimumHeight = bannerTopMargin + bannerHeight + bannerBottomMargin 

function scrollbar() {
    var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();

    if (jQuery.browser.msie) {
        if (parseInt(jQuery.browser.version) == 7) {
            viewportHeight -= 3;
        }
    }

//    if (viewportHeight <= $('#wrapper').height()) {
    if (viewportHeight <= $('html').height()) {
        return true;
    } else {
        return false;
    }
}

function VerticalScrollbar() {
    var viewportHeight = window.innerHeight ? window.innerHeight : $(window).height();

    if (jQuery.browser.msie) {
        if (parseInt(jQuery.browser.version) == 7) {
            viewportHeight -= 3;
        }
    }

    if (viewportHeight < $(document.body).height()) {
        return true;
    } else {
        return false;
    }
}

function resizeLeftNavigation() {
    $("#leftNav").height(0);
    $('#footer').css({ 'display': 'block', 'top': 0});
    var footerHeight = $('#footer').height();
    var leftNavHeight = $('#innerLeftNav').height() + leftNavMarginTop;
    if ($(document.body).height() < leftNavHeight) {
        $('#pageContent').height(leftNavHeight - pageContentPadding + 12);
        resizeLeftNavigation();
    }

    var wh = $(window).height();
    var dh = $(document.body).height() + 8 + 8;
    dh = $(document.body).height() + 4 + 8 + 4;
//    var bottom = ((dh > wh) ? dh : wh) - 8;
    var bottom = ((dh > wh) ? dh : wh);
    bottom = Math.max(dh, wh);
    //    bottom = Math.max(bottom, 410) - 8;
    bottom = Math.max(bottom, leftNavHeight) - 4 + (VerticalScrollbar() ? 4 : 0);
    $("#leftNav").height(bottom - 4);
    $('#footer').css({ 'display': 'block', 'top': bottom - footerHeight });
    var documentWidth = $(document.body).width();
    documentWidth = $(document).width();
//    documentWidth = $(document.body).outerWidth(true);
    //    pw = Math.max(870, $(window).width() - 184);
//    var pw = Math.max(Math.max(documentWidth, $(window).width()), minimumWidth) - contentWidth;
//1    var pw = Math.max(Math.max(documentWidth, $(window).width()), minimumWidth) - 184;
    //    pw = Math.max(Math.max(documentWidth, $().outerWidth()), 768) - 184;
    var pw = Math.max(Math.max($('#mainContent').width() + contentWidth + 20, $(window).width()), minimumWidth) - contentWidth;
    $('#footer').css('width', pw);
    $('#banner').css({ 'width': pw, 'left': 176 });
}

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null)
        return "";
    else
        return decodeURIComponent(results[1].replace(/\+/g, " "));
}
