﻿function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}
function getWindowWidth() {
	var windowWidth = 0;
	if (typeof(window.innerWidth) == 'number') {
	    // firefox scrollbar is 18px width
		windowWidth = window.innerWidth - 18;
	}
	else {
	    // internet explorer
		if (document.documentElement && document.documentElement.clientWidth) {
			windowWidth = document.documentElement.clientWidth;
		}
		else {
			if (document.body && document.body.clientWidth) {
				windowWidth = document.body.clientWidth;
			}
		}
		windowWidth-=  1;
	}
	return windowWidth;
}
function SetFooter() {
	if (document.getElementById) {
		var windowHeight  = getWindowHeight();
		var bodyHeight    = document.body.offsetHeight;
		var headerElement = document.getElementById('Header');
		var footerElement = document.getElementById('Footer');
		var middleElement = document.getElementById('PublicMainContent');
		var footerHeight  = footerElement.offsetHeight;
		var headerHeight  = headerElement.offsetHeight;
		if (bodyHeight <= windowHeight) {
		    if (document.getElementById('ctl00_pnlContentHeader')) {
		        middleElement.style.height = (windowHeight - footerHeight - headerHeight - 63) + "px"
		    }
		    else //home page
		    {
		        middleElement.style.height = (windowHeight - footerHeight - headerHeight - 5) + "px"    
            }
            //alert("bodyHeight " + windowHeight + ", headerHeight " + headerHeight + ", footerHeight " + footerHeight + " = " + middleElement.style.height)
            //alert("middleElement" + middleElement.offsetHeight);
		}
		else
		{
		}
	}
}
function SetMainRightWidth() {

    var BodyWidth = getWindowWidth();

    var LeftContentElement = document.getElementById('PublicLeftContent');
    var MainRightContentElement = document.getElementById('PublicMainRightContent');
    
    var LeftContentWidth = LeftContentElement.offsetWidth;
    
    //alert("bodyWidth: " + BodyWidth + " Left: " + LeftContentWidth)
    
    MainRightContentElement.style.width = (BodyWidth - LeftContentWidth) + "px";	
}
function SetBorderHeights()
{
    /*
    - Enforces min height
    - Adjusts the height of left, main, and right section of the page to be the same.
    */

    var arrContainerNames = new Array("FeaturedCategory", "FeaturedCaseStudy", "StaticHomePageText");

    var intMininumHeightAllowed = 0;
    var intMinimumHeight = intMininumHeightAllowed; // the mininum height out of the three sections
    var intMaximumHeight = intMininumHeightAllowed; // the maximum height out of the three sections

    for(i=0;i<arrContainerNames.length;i++)
    {
        var obj = document.getElementById(arrContainerNames[i]);
        if(obj != null)
        {
            var intCurrentHeight = obj.offsetHeight;
            //alert(intCurrentHeight);
            
            // 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 are found    

    for(i=0;i<arrContainerNames.length;i++)
    {
        var obj = document.getElementById(arrContainerNames[i]);
        if(obj != null)
        {
            obj.style.height = intMaximumHeight + "px";
            //alert(arrContainerNames[i] + intMaximumHeight);
        }
    }    
}