function initFixSize(img,l,t,r,b,vis) {
	if (vis) {
		img.style.visibility = "visible";
	}
	if (img.style.display == "none") img.style.display = "inline";
	fixSize(img,l,t,r,b);
	img.parentNode.style.overflow = "visible";
	fix_images.push({img:img,l:l,t:t,r:r,b:b});
}

function fixSizes() {
	var empty = document.getElementById("empty");
	empty.style.width = "10px";
	empty.style.height = "10px";
	for (var i=0;i<fix_images.length;i++) fixSize(fix_images[i].img,fix_images[i].l,fix_images[i].t,fix_images[i].r,fix_images[i].b);
}

function fixSize(img,l,t,r,b) {
	var winWidth = windowWidth();
	var winHeight = windowHeight();
	img.style.width = "auto";
	img.style.height = "auto";
	var imgHeight = img.offsetHeight;
	var imgWidth = img.offsetWidth;

	var faqW = (winWidth-(l+r))/imgWidth;
	var faqH = (winHeight-(t+b))/imgHeight;
	var faq = Math.min(faqW,faqH);
	
	
	img.style.width = Math.max(Math.round(imgWidth * faq), 40) + "px";
	img.style.height = Math.max(Math.round(imgHeight * faq), 40) + "px"; //window.innerHeight - 260;

	var empty = document.getElementById("empty");
	empty.style.width = Math.max(parseInt(img.style.width)  , parseInt(empty.style.width) )+"px";
	empty.style.height = Math.max(parseInt(img.style.height)  , parseInt(empty.style.height) )+"px";

}

function windowWidth() {
	var winWidth = window.innerWidth;
	if (winWidth == undefined) winWidth = document.body.clientWidth;
	return winWidth;
}
function windowHeight() {
	var winHeight = window.innerHeight;
	if (winHeight == undefined) winHeight = document.body.clientHeight;
	return winHeight;
}
