﻿/**
 * This is a dirty work-around for making the left column size to the height of the page.
 * ideally this would be done in CSS, but the layout is not consistent enough to
 * use absolute positioning in CSS.
 */
jQuery(function ($) {
    "use strict";

    //dom node resize event from jquery.ba-resize.min.js
    $('#middleColumn').bind('resize', function () {
        var height;
        height = $('.mainContent').height();
        $('.menuColumn, .leftSideMenu').each(function (index, element) {
            var $this,
            newHeight,
            distFromTop,
            topMargin,
            topPadding,
            botMargin,
            botPadding;
            $this = $(this);

            distFromTop = $this.position().top;
            topMargin = parseInt($this.css('margin-top'));
            topPadding = parseInt($this.css('padding-top'));
            botMargin = parseInt($this.css('margin-bottom'));
            botPadding = parseInt($this.css('padding-bottom'));

            newHeight = height - distFromTop - topMargin - topPadding - botMargin - botPadding;
            $this.css('min-height', newHeight);
        });
    });
    setTimeout(function () {
        $('#middleColumn').trigger('resize');
    }, 0);
});
