function ini_bg() {
	var theWindow = $(window);
	theWindow.resize(function() { resizeBg(); }).trigger("resize");			
}

function resizeBg() {
	
	var theWindow = $(window);
	var container_height = $("#feature").height() + $("#feature_info").height();
	var bottom_height = $("#coming_up").height();
	
	// account for scroll bars
	var newW = (theWindow.width() < 950) ? "950px" : "100%";
	var newH = getDocHeight()-bottom_height;
	$("#bg_container").css("width",newW);
	$("#bg_container").css("height",newH+"px");
	$("#wrapper").css("width",newW);
	// set width or height class
	if ( (newW / newH) < aspectRatio ) {
		$("#bg")
			.removeClass()
			.addClass('bgheight');
	} else {
		$("#bg")
			.removeClass()
			.addClass('bgwidth');
	}
}

function getDocHeight() {
    var D = document;
    return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
        Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
        Math.max(D.body.clientHeight, D.documentElement.clientHeight)
    );
}
