var gwViewer = null;

/*============================================================
 OBJECT: imgRef
 Holds all file and size info about a pair of images, one
 for display and one for viewing in a popup window.
 Images sizes are included for sizing & display purposes.
 ============================================================*/
function imgRef(pFile1, pFile2, pImg1w, pImg1h, pImg2w, pImg2h ) {
	this.img1	= pFile1;
	this.img2	= pFile2;
	this.img1w	= pImg1w;
	this.img1h	= pImg1h;
	this.img2w	= pImg2w;
	this.img2h	= pImg2h;
}

/*============================================================
 FUNCTION: viewImg
 Will open and format a popup window to view an image.
 Full "imgRef" object is passed in to describe image.
 ============================================================*/
function viewImg(pImgRef)
{
var nWidth    = pImgRef.img2w + 40;
var nHeight   = pImgRef.img2h + 40;
var winprops  = 'resizable=yes,status=no,toolbar=no';
var sizepos   = 'top=0,left=0,width=' + nWidth + ',height=' + nHeight;
var sHTML     = new String('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> \n');

	if (gwViewer) gwViewer.close(0);
	gwViewer = window.open('', '_viewer', winprops + sizepos);

	sHTML += '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> \n';
	sHTML += '<head><title>Image Viewer</title> \n';
	sHTML += '<style type="text/css"> \n';
	sHTML += 'body, * {text-align:center;background-color:#ffffff} \n';

	sHTML += 'img {border:1px solid #fff; width:' + pImgRef.img2w + '; height:' + pImgRef.img2h + ' }\n';
	sHTML += '</style> \n';
	sHTML += '</head> \n';
	sHTML += '<body> \n';
	sHTML += '<img src="' + pImgRef.img2 + '" width=' + pImgRef.img2w + ' height=' + pImgRef.img2h + ' /> \n';
	sHTML += '</body> \n';
	sHTML += '</html> \n';

	gwViewer.document.write(sHTML);
	return(0);
}

/*============================================================
 FUNCTION: genClickableImage
 Will generate a line of HTML for an image that shows ONE
 version, clickable, that will show a 2ND version in a popup
 window.  Includes all image sizing as drawn from the "imgRef"
 object passed in.
 ============================================================*/
function genClickImage(pArrayIndex,pImgRef)
{
var sHTML     = new String('<img style="cursor:hand" ');

	sHTML += 'src="' + pImgRef.img1 + '" width=' + pImgRef.img1w + ' height=' + pImgRef.img1h + ' onClick="viewImg(imgArray[' + pArrayIndex + ']);"';
	sHTML += ' />\n';
	document.write(sHTML);
	return(0);
}
