try{
  //Handles a fraction of behavior like css flex, specifically for a set of boxes to fill the vertical space of a containing box
  
  (function($){
    function sizePanels(){
      // Determine the min-height of the .body - which the background image covers. This avoids empty white-space at the bottom on tall, skinny viewports
      var windowHeight = $(window).height();
      var headerHeight = $('header').outerHeight(true);
      $('header + .body').css('min-height', Math.round( windowHeight - headerHeight )+'px');
      
      $('.panel-container').each(function(){
        
        var heights = [];
        var flexHeight = 0;
        //Determine a weighting for the height of flexible panels, based on their current relative heights. Then size them.
        //Cache the current heights of flex panels because when we incrementally resize panels they may be able to affect each other
        $('.panel.flex', this).each(function(index){
          heights[index] = $(this).outerHeight() || 1;
            //Impose a minimum height of 1 (the result will not be negative). This prevents division by zero if all flex planels have natural height 0.
            //It is probably wise to use css to ensure this is not the case anyway, but the contingency exists.
          flexHeight += heights[index];
        });
        // $('.panel.flex', this).each(function(index){
        //   $(this).height(0);
        // });
        
        //Total up the height of the panels that use a "fixed" height. By fixed height we mean whatever the browser computes
        //based on css rules should be used.
        var fixedHeight = 0;
        $('.panel.fixed', this).each(function(){
          fixedHeight += $(this).outerHeight();
        });
        var availableHeight = $(this).height() - fixedHeight;
  
        $('.panel.flex', this).each(function(index){
          $(this).css('height', Math.round( heights[index]*availableHeight/flexHeight )+'px');
            //Ideally we would truncate availableHeight and apportion the pixels instead of using division. This is good enough though.
        });
        
      });
    }
    
    $(document).ready(function(){
      sizePanels();
      $(window).on( 'throttledResize updatePanels', sizePanels )
    });
  })(jQuery);
  
  }catch(ex){
    console.error(ex);
  }