$.fn.bgResize = function(options) {
	
	var defaults = {  
		imagewidth: 800,
		imageheight: 600
	};
	
	var options = $.extend(defaults, options);
	
	var obj = $(this);
	
	function doResize(){
		
		var screenheight = document.documentElement.clientHeight;
		var screenwidth = document.documentElement.clientWidth;
		
		var imageheight = options.imageheight;
		var imagewidth = options.imagewidth;
		
		var ratio = imagewidth/imageheight;
		
		var testwidth = screenheight * ratio;
		var testheight = screenwidth / ratio;
		
		if (testheight < screenheight){
			obj.width(testwidth);
			obj.height(testwidth/ratio);
			var finalheight = Math.round(testwidth/ratio);
			var finalwidth = testwidth;
			var topoffset = (finalheight - screenheight)/2;
			var leftoffset = (finalwidth - screenwidth)/2;
			newdivisionx = (((finalwidth*(divisionx/100))-leftoffset)/screenwidth)*100;
		}
		
		else if (testheight > screenheight){
			obj.height(testheight);
			obj.width(testheight * ratio);
			var finalwidth = Math.round(testheight * ratio);
			var finalheight = testheight;
			var topoffset = (finalheight - screenheight)/2;
			var leftoffset = (finalwidth - screenwidth)/2;
			newdivisionx = divisionx;
		}
		
		else {}
		
		obj.css("top", -topoffset);
		obj.css("left", -leftoffset);
		$('.pageCenter').css("left",newdivisionx+"%");
		
	}
	
	doResize();
	
	$(window).resize(function(){
		doResize();
	});

	
	return this;

};
