function popupImage(pagePath, src, width, height, frameWidth, frameColorIdx, displayTitle, title, subtitle) {
	/*
		- sPagePath: a path to a page that will display an image
		- sPath: a path to the image itself
		- iWidth, iHeight: dimentions of the image w/o a frame
		- iFrameWidth: ...
		- iFrameColorIdx: an index of the frame color in 'aImgFrameColors' array {0=black, 1=dark, ...}
		- displayTitle: whether or not to display a title and a subtitle
		- sTitle, sSubtitle: ...
	*/
	
	var subtitleHeight;
	var iWinWidth;
	var iWinHeight;
	var sScrollbars;
	
	if (displayTitle == 1)
		subtitleHeight = 50;  // how much space will be left for the subtitle
	else
		subtitleHeight = 0;
	
	// Calculating the width of the popup window - taking care if the image is too big to fit on the screen:
	if (width + frameWidth*2 + 20 > screen.width) {
		iWinWidth = screen.width - 40;
		sScrollbars = "1";
	}
	else {
		iWinWidth = width + frameWidth*2 + 2;  // 2 for black one-pixel frame
		sScrollbars = "0";
	}
	
	// Calculating the height of the popup window - taking care if the image is too big to fit on the screen:
	if (height + frameWidth*2 + subtitleHeight + 30 > screen.height) {
		iWinHeight = screen.height - 80;
		sScrollbars = "1";
	}
	else {
		iWinHeight = height + frameWidth*2 + subtitleHeight + 2;  // 2 for black one-pixel frame
		sScrollbars = "0";
	}
	
	// Calculating coordinates of the upper-left corner of the popup window:
	var x1 = Math.floor((screen.width / 2) - (iWinWidth / 2));
	var y1 = Math.floor((screen.height / 2) - (iWinHeight / 2)) - 25;
	
	// Poping-up the window:
	var sArgs =
		"?" +
		"src=" + src +
		"&width=" + width +
		"&height=" + height +
		"&frameWidth=" + frameWidth +
		"&frameColoridx=" + frameColorIdx +
		"&displayTitle=" + displayTitle +
		"&title=" + title +
		"&subtitle=" + subtitle;
	
	window.open(pagePath + sArgs, "", "title=1,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + sScrollbars + ",resizable=1,width=" + iWinWidth + ",height=" + iWinHeight + ",left=" + x1 + ",top=" + y1);
}

