/* Stretch short pages to full height, keep footer at bottom. */

/* Set a compensation value to fix browser differences and an overall
	misalignment with this method */
if (jQuery.browser.msie) {
	var bfacompensate = 11;
} else if (jQuery.browser.safari) {
	var bfacompensate = 11;
} else {
	var bfacompensate = 0;
}

/* Fix a jQuery/Opera 9.5+ bug with determining the window height */
var windowheight = ((jQuery.browser.opera) && (jQuery.browser.version > "9.5") && (jQuery.fn.jquery <= "1.2.6")) ? document.documentElement["clientHeight"] : jQuery(window).height();

/* Top and bottom padding may have been set on the BODY */
var paddingtop = parseInt(jQuery("body").css("padding-top"));
var paddingbottom = parseInt(jQuery("body").css("padding-bottom"));

/* Get the height of the header, footer, and the layout as a whole */
var headerheight = jQuery("td#header").height();
var footerheight = jQuery("td#footer").height();
var layoutheight = jQuery("div#wrapper").height();
var middleheight = jQuery("td#middle").height();
var pagemiddleheight = windowheight - paddingtop - headerheight - footerheight - paddingbottom -  bfacompensate;

/* Adjust height of middle column if (layout height + body padding-top + body padding-bottom) is smaller than height of browser viewport */

/*	Check the height of the middle row of the layout table - if it is greater than 430px
	then there is room to display the ofsted and matrix badges without looking too cramped.
	
	Current content (hotlink buttons):
	5 images with 60 px height - 10 px top and 10 px bottom padding  = 400px + 15 px top padding = 415 px

	height of badges  = 64px + 10px (padding-top) + 10px (padding-bottom) = 84px

	Therefore 500px is required to display all.  Factor in an extra 20px for some white space.
	
	*/

if ( ( windowheight > (layoutheight + paddingtop + paddingbottom) ) || ( middleheight < 530 ) )
{
	middleheight = (pagemiddleheight>530)?pagemiddleheight:530;
	jQuery("td#middle").css({height: middleheight + "px"});
}



/*
	Only do all of this if there is a valid footer
	*/

if (footerheight)
{	/* position the link to PCC halfway up the footer (accounting for 10px
	bottom margin */

	// pcc_link_bottom = Math.round(footerheight / 2) - 5;
	// jQuery("a#pcc_link_footer").css({bottom: pcc_link_bottom + "px"})

	if ((jQuery.browser.msie) && (jQuery.browser.version == "6.0"))
	{
		jQuery("P#badges").css({bottom: "0px"});
		jQuery("P#badges").show();			
	}
	else
	{
		jQuery("P#badges").css({bottom: footerheight + "px"});
		jQuery("P#badges").show();
	}

}

