$(document).ready(function() {

	function updateWidth() {

		var win_height = $(window).height(),
			win_width = $(window).width(),
			win_ratio = win_height/win_width,
			node = $('.bg'),
			img_ratio = node.height()/node.width();

		if (win_ratio > img_ratio) {
			node.css('width',(win_height/img_ratio));
			node.css('height',(win_height));
		
		} else {
			
			node.css('width',(win_width));
			node.css('height',(win_width*img_ratio));
		}
		node.css('left',(win_width - parseInt(node.css('width')))/2);
		node.css('top',(win_height - parseInt(node.css('height')))/2);
	}
	window.onload = function() {
		updateWidth();
	}
	jQuery(window).bind("resize", function(){
		updateWidth();
	});
}); 
