function writeImg(){
	var img = new Array("pic1.jpg","pic2.jpg","pic3.jpg");
	var rand = Math.floor(Math.random() * img.length);
	document.getElementById('bgHolder').innerHTML = '<img src="images/rotate/'+img[rand]+'" width="900" height="598" id="bgImg" alt="background image" />';
}
//variables to handle size of the background image
var imgW = 900;
var imgH = 598;
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;
	}
}

