function resize() {
	var bg = document.getElementById('bg_image');
	if (bg) {
		if (!bg.aspectRatio) {
			bg.style.display = 'block';
			if (bg.offsetWidth && bg.offsetHeight) {
				bg.aspectRatio = bg.offsetWidth / bg.offsetHeight;
			} else {
				return;
			}
		}
		var w = window.innerWidth || document.body.clientWidth;
		var h = window.innerHeight || document.body.clientHeight;
		if ((w/h) > bg.aspectRatio) {
			bg.style.width = '100%';
			bg.style.height = '';
		} else {
			bg.style.width = '';
			bg.style.height = '100%';
		}
	}
}
//setInterval('resize()', 100);
window.onload = resize;
window.onresize = resize;