//On load an on window resize set background image to fullscreen



var rand_no = Math.floor(9*Math.random());
Stamp = new Date();
today = Stamp.getDate();
//put the img of the day in each img[x] string
//change images each month, automatically switches every day

//write todays img so that the img number matches with the day
//imgaddr="http://tabun.com.pl/img/bg/"+rand_no+".jpg";
imgaddr="http://tabun.com.pl/img/bg/bg.jpg";
//insert image before container (background)
document.whenReady (insertion);
function insertion() {
	document.body.insert({ top: '<img id="bg" src='+imgaddr+' width='+document.viewport.getWidth()+'px  height:'+document.viewport.getHeight()+'px alt="tabun - konie z naszej stadniny" />' }).delay(1);
	}






function adjustRatio() {
	var img = $('bg');
	window.width = document.viewport.getWidth();
	window.height = document.viewport.getHeight();
	var imageratio = img.height / img.width; 
	var winratio = window.height / window.width;


	if(winratio < imageratio) {
		img.setStyle('width:'+window.width+'px; height: auto;');

		}
	else {
		img.setStyle('width: auto; height:'+window.height+'px;');
		}
	}

		Event.observe(window,"resize", adjustRatio);

		

	
