/* 
 * custom.js
 */

/*jslint undef: true, browser: true */
/*global jQuery, $ */

$( function() {
	
	/*
	// Debug
	alert(
		"Content height: " + $("#Content").outerHeight(true) + "\n" +
		"window height: " + $(window).height() + "\n" +
		"Difference: " + ($(window).height() - 325 - $("#Content").outerHeight(true) - 25 ) + "\n"
		);
	*/

	// Set correct height for #Content
	// NOTE: it only sizes UP, not DOWN
	function setCorrectHeight() {
		var iContentHeight = $("#Content").height();
		var iWindowHeight = $(window).height();
		var iDelta = 0;
		// Header height = 325px
		// Bottom margin height = 25px
		iDelta = iWindowHeight - 325 - iContentHeight - 25;
		
		if (iDelta > 0) {
			$("#Content").height(iContentHeight + iDelta);
		}
	}
	
	
	// Resize page if browser window is resized
	$(window).resize( function() {
		setTimeout( function() {
			setCorrectHeight();
		}, 100);
	}) 
	
	// Since Google Chrome seems to report ready documents earlier than all images are loaded,
	// some pages set the incorrect (too little) Content height.
	// Therefore we wait a few milliseconds...
	setTimeout( function() {
		setCorrectHeight();
	}, 30);
	
	$.localScroll()
});

