// Global scripts for brehaut.net

(function ($) {
	
	// The following event handler exists to stretch the page contents to the full height of the 
	// browser window if the content isnt long enough to do that itself.
	var body_height;
	
	function trimPx(str) {
	    return +(str.slice(0, str.length - 2));
	}
	
	function check_content_size() {
		var browser_height = $(window).height();
		body_height = body_height || $(document.body).height();
		
		if (browser_height > body_height) {
			var banner_height = $('#banner').height();
			var footer_height = $('#footer').height();
			var footer_padding = trimPx($('#footer').css('paddingTop')) + 
                                 trimPx($('#footer').css('paddingBottom'))
			// 35 is a magic number that is used to take up the slack caused by padding (i think)
			$('#wrapper-background').height(browser_height - (banner_height + footer_height + footer_padding) );
		}
	}
	
	$(document).ready(check_content_size);
	$(window).resize(check_content_size);
})(jQuery);