$(document).ready(function() {
	/* Height Fixes */
	var document_height = $(document).height();
	var header_height = $('#header_bgnd_wrapper').height();
	var body_height = $('#body_bgnd_wrap').height();
	var footer_height = document_height - (header_height + body_height);
	
	$('#footer_bgnd_wrap').height(footer_height);	
	
	$(window).resize(function() {
		var document_height = $(document).height();
		var header_height = $('#header_bgnd_wrapper').height();
		var body_height = $('#body_bgnd_wrap').height();
		var footer_height = document_height - (header_height + body_height);
		
		$('#footer_bgnd_wrap').height(footer_height);	
		
	});
	
	/* Home Page Enhancements */
	if ($("body.home").size()) {
		/* News Cycle */
		$("#latest_news div.latest_news").accessNews({
            newsHeadline: "Latest News",
            newsSpeed: "normal"
        });
	}
	
	/* Print style switcher */
	/**
	 * Print Page
	 *
	 * Print this page stylesheet switcher
	 */
	
	// Insert print button removed
	
	var printSheet = $("link[title='print preview']");
	var screenSheet = $("link[media='screen']");
	var printButton = $("a[title='Print friendly version']");
	
	// Print Preview
	printButton.click( function() {	
		// Switch to print
		$("body").fadeOut("fast", function() {
			screenSheet.each(function() {
				this.disabled = true;
			});
			printSheet.each(function() {
				this.disabled = true;
				this.disabled = false;
			});
			$(this).fadeIn("slow");
			
			$('html, body').animate({scrollTop:0}, 'fast');

			// Create Print Preview Heading
			$("body").prepend('<div id="preview-message"><h3>Print preview</h3><p><a href="#" id="preview-print">Print this page</a> | <a href="#" id="turnoff-print">Return to the normal view</a></p></div>');
			$("#preview-message").hide().slideDown("slow");
			
			// Switch Back
			$("a#turnoff-print").bind("click", function(){
				$("body").fadeOut("fast", function() {
					$("#preview-message").remove();
					// Switch to screen
					screenSheet.each(function() {
						this.disabled = false;
					});
					printSheet.each(function() {
						this.disabled = true;
					});
					$(this).fadeIn("slow");
				});
				return false;
			});
			
			// Print this page
			$("a#preview-print").bind("click", function(){
				window.print();
				return false;
			});
		});
		
		return false;
	});
	
	// Dont print preview message
	$("head").append(
		'<style type="text/css" media="print" title="Hide print preview message on print">' +
			'#preview-message {' +
					'display: none;' +
			'}' +
		'</style>'
	);
	
});