$(document).ready(function(){
	var bg = $('#background img');
	var ratio = bg.height() / bg.width();
	bg.load(function(){	
	
	  var fix_resize = function()
    {
	    var win_w = $(window).width();
      var win_h = $(window).height();
	    if (win_w > bg.width() || true) { resize_width(bg, win_w, ratio); }
	    if (win_h > bg.height()) { resize_height(bg, win_h, ratio); } 
    }
    fix_resize();
	  $(window).resize(fix_resize);	  
	  });
	});
	
function resize_width(img, size, ratio) {
  resize_image(img, Math.floor(ratio * size), size);
}

function resize_height(img, size, ratio) {
  resize_image(img, size, Math.floor(size / ratio));
}

function resize_image(img, height, width) {
  img.height(height);
  img.width(width);
}