function fitImageSize( toMax ){
	
	if( typeof toMax == "undefined" )
		toMax = true;

	$("img.super-bg").css("width", '').css("height", '');
	
	var winW = $(window).width();
	var winH = $(window).height();

	var kx = winW/$("img.super-bg").width();
	var ky = winH/$("img.super-bg").height();
	var h;
	var w;
	
	var resizetype;
	if( toMax )
		resizetype = kx > ky;
	else
		resizetype = kx < ky;
	
	if( resizetype ) {
		h = kx*$("img.super-bg").height();
		w = kx*$("img.super-bg").width();
	} else {
		h = ky*$("img.super-bg").height();
		w = ky*$("img.super-bg").width();
	}
	$("img.super-bg").css("width", w).css("height", h).css("top", (winH - h)/2 );
}

$(function(){
	$("img.super-bg").load(fitImageSize);

	$(window).resize(function(){
	    fitImageSize();
	});
	
	fitImageSize();
})
