// Resize Images

function imageSize(){
	setTimeout("resize()",100);
}

function resize(){
	imgs = document.getElementById("content").getElementsByTagName("img");
	var browserHeight=0;
	var browserWidth=0;
	if (typeof(window.innerHeight)=='number') {
		browserHeight=window.innerHeight;
		browserWidth=window.innerWidth;
	}else{
		if (document.documentElement&&
			document.documentElement.clientHeight) {
			browserHeight=document.documentElement.clientHeight;
			browserWidth=document.documentElement.clientWidth;
		}else{
			if (document.body&&document.body.clientHeight) {
				browserHeight=document.body.clientHeight;
				browserWidth=document.body.clientWidth;
			}
		}
	}
	
	for(i=0;imgs[i];i++){
		imgHeight = imgs[i].offsetHeight;
		imgWidth = imgs[i].offsetWidth;

		heightRatio = browserHeight/imgHeight;
		widthRatio = browserWidth/imgWidth;
		
		if(imgHeight*widthRatio < browserHeight){
			imgs[i].style.height = imgHeight*heightRatio + "px";
			imgs[i].style.width = imgWidth*heightRatio + "px";
			imgs[i].style.bottom = "50%";
			imgs[i].style.left = "50%";
			imgs[i].style.margin = "0 0 -"+((imgHeight*heightRatio)/2)+"px -"+((imgWidth*heightRatio)/2)+"px";
		}else{
			imgs[i].style.height = imgHeight*widthRatio + "px";
			imgs[i].style.width = imgWidth*widthRatio + "px";
			imgs[i].style.bottom = "50%";
			imgs[i].style.left = "50%";
			imgs[i].style.margin = "0 0 -"+((imgHeight*widthRatio)/2)+"px -"+((imgWidth*widthRatio)/2)+"px";
		}
	}
}

// With Jquery

function initialize(){
	imageSize();
	whenLoaded();
}