/*
	Resizes a sequence of padding elements to ensure that they make their corresponding
	content elements appear to be the same height as each other.  Optionally, they can
	be resized to be at least as tall as the page as well.
	
	The paddingIds array must contain the id of the element which will act as padding
	for the correspondingly-identified element in the contentIds array.  The paddingIds array 
	may be shorter than or of the same size as the contentIds array.
	
	For each element in the contentIds and paddingIds arrays, there must be exactly one element
	on the page which uses that id.  Additionally, all identified elements should have absolute 
	positioning.
	
	contentIds: An array containing the ids of the content elements.
	paddingIds: A parallel array containing the ids of the padding elements.
	pageHeight:   True if page height should be considered; false otherwise.
*/
function resizePage(contentIds, paddingIds, pageHeight)
{
	maxHeight = 0;
	// Determine maximum height
	for (var index = 0; index < contentIds.length; index ++)
	{
		maxHeight = Math.max(maxHeight, getDivHeight(document.getElementById(contentIds[index])));
	}
	if (pageHeight)
	{
		maxHeight = Math.max(maxHeight, getWindowHeight());
	}
	
	// Adjust corresponding padding elements
	for (var index = 0; index < paddingIds.length; index ++)
	{
		contentElement = document.getElementById(contentIds[index]);
		paddingElement = document.getElementById(paddingIds[index]);
        targetTop = getDivHeight(contentElement);
        if (targetTop < maxHeight)
        {
            paddingElement.style.top = targetTop;
            paddingElement.style.height = maxHeight - targetTop;
        } else
        {
            paddingElement.style.top = (maxHeight - 1);
            paddingElement.style.height = 1;
        }
/*        
        alert("Content element:\n    top: " + contentElement.style.top + "\n" +
                                "    left: " + contentElement.style.left + "\n" +
              "Padding element:\n    top: " + paddingElement.style.top + "\n" +
                                "    left: " + paddingElement.style.left);
*/
	}
}
function getDivHeight(div)
{
	if (div.offsetHeight) return div.offsetHeight;
	if (div.style.pixelHeight) return div.style.pixelHeight;
}
function getWindowHeight()
{
	if (window.innerHeight) return window.innerHeight;
	if (document.body.offsetHeight) return document.body.offsetHeight;
}