﻿function AdjustLeftMainRightHeight()
{
    /*
    
    Description:
        - Enforces min height
        - Adjusts the height of left, main, and right section of the page to be the same.
    
    MODs:
        - 2007-??-??: Initial script.
        - 2007-08-24: Add the ability to re-adjust heights of the containers in the array
    */

    var arrContainerNames = new Array("PublicLeftContent", "PublicMainContent", "PublicRightContent");

    var intMininumHeightAllowed = 0;                // 0 means no minimum height being enforced
    var intMinimumHeight = intMininumHeightAllowed; // the mininum height of the containers in the array
    var intMaximumHeight = intMininumHeightAllowed; // the maximum height of the containers in the array

    for(i=0;i<arrContainerNames.length;i++)
    {
        var obj = document.getElementById(arrContainerNames[i]);
        if(obj != null)
        {
            obj.style.height = "auto";  // reset height that was previously set (by this script)
            
            var intCurrentHeight = obj.offsetHeight;
            
            // find minimum height
            if(intCurrentHeight > intMininumHeightAllowed   // must be at least greater than the height allowed
                && intCurrentHeight < intMinimumHeight)
            {
                intMinimumHeight = intCurrentHeight;
            }
            
            // find maximum height
            if(intCurrentHeight > intMaximumHeight)
            {
                intMaximumHeight = intCurrentHeight;
            }
        }
    }

    // by now, min and max height have been found    

    for(i=0;i<arrContainerNames.length;i++)
    {
        var obj = document.getElementById(arrContainerNames[i]);
        if(obj != null)
        {
            obj.style.height = intMaximumHeight + "px";
        }
    }    
}