//variables to handle size of the background image
var imgW = 771;
var imgH = 500;
var imgRatio = imgW/imgH;

//calls the resizeImg() function when the window is resized			
window.onresize = resizeImg;

//resizes the background image according to the ratio
function resizeImg(){
	w = window.innerWidth;
	h = window.innerHeight;
	if(!h){
		w = document.body.offsetWidth;
		h = document.documentElement.clientHeight;
	}
	ratio = w/h;
	newScale = ratio/imgRatio;
	
	if(newScale > 1){
		document.getElementById('bgImg').width = w;
		document.getElementById('bgImg').height = Math.round(h*newScale);
	}else {
		document.getElementById('bgImg').width = Math.round(w/newScale);
		document.getElementById('bgImg').height = h;
	}
}
