(function($){
	var origDiv = '#background';
	var origImg = '#background img';

	//resize the image on brower load
	$(document).ready(function() {
		$(origDiv).resizeImg();
	});
	//resize the image on browser resize
	$(window).bind("resize", function() {
		$(origDiv).resizeImg();
	});

	$.fn.resizeImg = function() {
		//define original width and height of the image
		var imgWidth = $(origImg).attr('width');
		var imgHeight = $(origImg).attr('height');
		//define image ratio
		var ratio = imgHeight/imgWidth;
		//get browser dimensions
		var winWidth = $(window).width();
		var winHeight = $(window).height();
	var winRatio = winHeight/winWidth;
		//resize the image
		if (winRatio > ratio) {
			$(origDiv).height(winHeight);
			$(origDiv).width(winHeight / ratio);
			$(origImg).height(winHeight);
			$(origImg).width(winHeight / ratio);
		} else {
			$(origDiv).width(winWidth);
			$(origDiv).height(winWidth * ratio);
			$(origImg).width(winWidth);
			$(origImg).height(winWidth * ratio);
		}

	};
})(jQuery);
