

// adjusts the page height to fill the available space.
var fncHeightFix = function() {
    // get elements we need to work with.
    var struc_container = document.getElementById("struc_container");
    var struc_body = document.getElementById("struc_bodyInner");
    
    // before we continue make sure we actually have those elements
    if (struc_container && struc_body)
    {
        var contentHeight = struc_container.offsetHeight;
        var viewHeight = getViewportHeight();
        var resizeBy = viewHeight - contentHeight;

        if (resizeBy > 0)
        {
            struc_body.style.height = struc_body.offsetHeight + resizeBy + "px";
        }
    }
}

addEvent(window, "load", fncHeightFix, false); // load event

// UTILITIES

// add event to the document
function addEvent(elm, evType, fn, useCapture) {
	if (elm.addEventListener)
	{
		elm.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (elm.attachEvent)
	{
		var r = elm.attachEvent('on' + evType, fn);
		return r;
	}
	else
	{
		elm['on' + evType] = fn;
	}
}

// viewable screen area : height
function getViewportHeight()
{
	if (window.innerHeight != window.undefined) return window.innerHeight;
	if (document.compatMode == 'CSS1Compat') return document.documentElement.clientHeight;
	if (document.body) return document.body.clientHeight; 
	return window.undefined; 
}

// attach stylesheet.
function attachStyleSheet(styleSheetPath)
{
    // check for head tag.
    var headTagSearch = document.getElementsByTagName("head");
    if (headTagSearch[0])
    {
        // create the stylesheet link.
        var styleSheet = document.createElement("link");
        styleSheet.setAttribute("rel", "stylesheet");
        styleSheet.setAttribute("type", "text/css");
        styleSheet.setAttribute("href", styleSheetPath);
    
        // attach to head tag.
        var headTag = headTagSearch[0];
        headTag.appendChild(styleSheet);
    }
}
