// set window size to size of Img + Width & Height
// if Img=="" then set window size to Width & Height
// if WH=="w" then set only Width
// if WH=="h" then set only Height
function WindowSize(Img,Width,Height,WH) {
	if (window.resizeBy) {
		if (window.innerWidth) {
			w = window.innerWidth;
			h = window.innerHeight;
		}
		else if (document.body) {
			if (document.body.clientWidth) {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			}
			else if (document.body.offsetWidth) {
				w = document.body.offsetWidth;
				h = document.body.offsetHeight;
			}
		}
		if (w && h) {
			if (Img) {
				if (document.images[Img]) {
					Width = Width + document.images[Img].width;
					Height = Height + document.images[Img].height;
				}
				else if (document.layers[0] && document.layers[0].document.images[Img]) {
					Width = Width + document.layers[0].document.images[Img].width;
					Height = Height + document.layers[0].document.images[Img].height;
				}
			}
			dw = Width - w;
			dh = Height - h;
			if (WH) {
				if (WH == "w") dh = 0;		// resize width only
				else if (WH == "h") dw = 0;	// resize height only
			}
			if (dw || dh) window.resizeBy(dw,dh);
		}
	}
}
// if there is only 1 image
function FitImg() {
	WindowSize("Img",0,0);
	window.focus();
}

// set:
// <body onLoad="FitImg()">
// <div style="position:absolute; left:0px; top:0px">
// <img name="Img" src="...." alt="" border="0">
// </div>

