$(document).ready(function(){
	
	var page_width = $('body').width();
	var page_height = $.viewportHeight();
	
	$('#extra').append('<img src="http://www.jackshedd.com/static/images/background.png" id="background" />');
	$('#extra').height(page_height).width(page_width);
	$('#background').height(page_height).width(page_width);
	
	var img_height = $($('#extra img').get(0)).height();
	var img_width = $($('#extra img').get(0)).width();
	
	$(window).resize(function(e) {

		new_page_width = $('body').width();
		new_page_height = $.viewportHeight();
		$('#extra').height(new_page_height).width(new_page_width);
		
		if(img_width != new_page_width){
			ratio = img_width/new_page_width;
			img_width = new_page_width;
			img_height = img_height/ratio;			
			$('#background').height(img_height).width(img_width);			
		}
		/*if (new_page_height > page_height) {
			page_height = new_page_height;
			$('#background').height(page_height).width(page_width);			
		}
		if (new_page_width > page_width) {
			page_width = new_page_width;
			$('#background').height(page_height).width(page_width);			
		}
		*/
	});
});

$.viewportHeight = function() { 
     return self.innerHeight || 
        jQuery.boxModel && document.documentElement.clientHeight || 
        document.body.clientHeight;
};

$.viewportWidth = function() { 
     return self.innerHeight || 
        jQuery.boxModel && document.documentElement.clientWidth || 
        document.body.clientWidth;
};