function CalcWindowSize(PicWidth, PicHeight, PicDescription) {
	var WinTop;
	var WinLeft;
	var WinWidth;
	var WinHeight;
	var PicChars;
	var NCSize = new Array();
	NCSize = DocumentNonClientArea();
	WinWidth = PicWidth + 40;
	WinHeight = PicHeight + 60;
	if (WinWidth < 550){WinWidth=550};
	PicChars = PicDescription.length;
	// If PicDescription contains text, increase window height to accomodate the text.
	if (PicChars > 0) {
		WinHeight = WinHeight + ((Math.round((PicChars * 9.3) / (WinWidth - 20)) * 14) + 41)
		}
	if (WinWidth+NCWidth>=screen.availWidth) {WinWidth=screen.availWidth-NCWidth}

	if (WinHeight+NCHeight>screen.availHeight) {WinHeight=screen.availHeight-NCHeight}
	WinTop = (screen.availHeight-(WinHeight+NCHeight))/4;
	WinLeft = (screen.availWidth-(WinWidth+NCWidth))/2;
	return Array(WinTop, WinLeft, WinWidth, WinHeight);
	}

function DocumentNonClientArea() {
	var ClientWidth = 0;
	var ClientHeight = 0;
	var WindowWidth = 0;
	var WindowHeight = 0;
	if (typeof(window.innerWidth) == 'number') {
		//Non-IE
		ClientWidth = window.innerWidth;
		ClientHeight = window.innerHeight;
		WindowWidth = window.outerWidth;
		WindowHeight = window.outerHeight;
	} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
		//IE 6+ in 'standards compliant mode'
		ClientWidth = document.documentElement.clientWidth;
		ClientHeight = document.documentElement.clientHeight;
		WindowWidth = document.body.offsetWidth;
		WindowHeight = document.body.offsetHeight;
	} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
		//IE 4 compatible
		ClientWidth = document.body.clientWidth;
		ClientHeight = document.body.clientHeight;
	}
	if (ClientWidth == 0 || WindowWidth == 0) {
		NCWidth = 20;
	} else {
		NCWidth = WindowWidth - ClientWidth;
	}
	if (ClientHeight == 0 || WindowHeight == 0) {
		NCHeight = 20;
	} else {
		NCHeight = document.Height - ClientHeight;
	}
	NCWidth = NCWidth - 8;
	NCHeight = NCHeight + 10;
	if (NCWidth < 0) {NCWidth = 12}
	if (NCHeight < 0) {NCHeight = 0}
	return Array(NCWidth, NCHeight);
	}