function backgroundImageActions() {
	jQuery('#page-canvas').css("height", jQuery(window).height())
	setupBodyHeight();
}

function centerBackgroundImage(target) {	
	target = jQuery(target);
	var the_window = jQuery(window);
	
	target.css({
		'width'		: 'auto',
		'height'	: the_window.height()
	});

	// if the window width is wider than the resized image we need to set the image width to the window width
	
	if (target.attr("width") < the_window.width()) {
		target.css({
			'width'		: the_window.width(),
			'height'	: 'auto'
		});
	}
	
	var margin_top = (the_window.height()/2) - (target.height() / 2);
	var margin_left = Math.floor(the_window.width()/2 - (target.width() / 2));
	
	jQuery(target).css({
		// 'margin-top' : margin_top + 'px',
		'margin-left' : margin_left + 'px'
	});
}

function setupBodyHeight() {
	body = jQuery('body');

	body.height('auto');
	
	if (jQuery('#page-canvas').height() < body.height())
	{
		body.height('100%');
	}
	else if (jQuery('#page-canvas').height() != body.height())
	{
		body.height('auto');
	}
}

jQuery(document).ready(
	function() {
		centerBackgroundImage(jQuery('#page-canvas img.fullscreen-background'));
		backgroundImageActions();
	}
);

jQuery(window).resize(function() {
	centerBackgroundImage(jQuery('#page-canvas img.fullscreen-background'));
	backgroundImageActions();
});

jQuery(document).ready(function() {
	jQuery(window).bind('scroll resize', function() {
		var conHeight = jQuery('#container').outerHeight(true);
		var winHeight = jQuery(this).height();
		
		if (winHeight < conHeight) {
			jQuery('#footer_container').css('bottom', 20 + (winHeight - conHeight)); 
		}
	});
	jQuery(window).resize();
});


/* Activate Cufon font replacement */

Cufon.replace('h1', { fontFamily: 'futura-light' });


