var ratio = 1986 / 2600;
var minWidth = 740;
var minHeight = 609;

function resizeBGImage() {
	var el = $("#bg img");
	var win_h = Math.max($("#outer").height(), minHeight);
	var win_w = Math.max($("#outer").width(), minWidth);
	
	if(win_h/win_w <= ratio) { // Go by width
		h = win_w * ratio;
		w = win_w;
	} else { // Go by height
		h = win_h;
		w = win_h / ratio;
	}
	
	t = (win_h - h)/2;
	l = (win_w - w)/2;							
	h = Math.floor(h);
	w = Math.floor(w);
	
	el.css({'height':h, 'width':w, 'margin-top': t, 'margin-left': l});
	$('#bg').css({'height':win_h, 'width':win_w});
}

$(document).ready(function() {
	$(window).bind('resize', resizeBGImage);
	resizeBGImage();
	$("#bg").css({"visibility":"visible"});
});
