// Functions for creating the Popup Windows

//**********************************************************************
function drawPopup(url, popupWidth, popupHeight)
/***********************************************************************

	Description: Creates a popup window and positions it in the horizontal
	center of the browser window.

	Specify:

	url					specify the HTML/PHP file to popup
	popupWidth	popup window width
	popupHeight popup window height

 **********************************************************************/
{
	var x, y;

	/* center the popup window horizontally between the edges of the
	   parent browser window, and down a fixed arbitrary valued */
	if (self.screenTop) { // Explorer returns coordinates of viewport
		x = self.screenLeft + (document.documentElement.clientWidth - popupWidth)/2;
		y = self.screenTop - 50;
	}
	else { // Gecko returns coordinates of browser window
		x = self.screenX + (self.outerWidth - popupWidth)/2;
		y = self.screenY + 100;
	}

	var pf=window.open(url,"popupWindow","width="+popupWidth+",height="+popupHeight+",resizable=0,scrollbars=0,status=0");

	pf.moveTo(x,y);
	pf.focus();
}

//**********************************************************************
function popupViewport(url, popupWidth, popupHeight)
/***********************************************************************

	Description: Creates a popup window and positions it in the horizontal
	center of the browser window.

  NOTE: Only supported by Gecko browsers (no, no even Opera)

	Specify:

	url					specify the HTML/PHP file to popup
	popupWidth	desired width of the viewport
	popupHeight desired height of the viewport

 **********************************************************************/
{
	var x, y;

	/* center the popup window horizontally between the edges of the
	   parent browser window, and down a fixed arbitrary valued */
	if (self.screenTop) { // Explorer returns coordinates of viewport
		x = self.screenLeft + (document.documentElement.clientWidth - popupWidth)/2;
		y = self.screenTop - 50;
	}
	else { // Gecko returns coordinates of browser window
		x = self.screenX + (self.outerWidth - popupWidth)/2;
		y = self.screenY + 100;
	}

	var pf=window.open(url,"popupWindow","innerwidth="+popupWidth+",innerheight="+popupHeight+",resizable=0,scrollbars=0,status=0");

	pf.moveTo(x,y);
	pf.focus();
}


//**********************************************************************
function drawImgPopup(img, imgWidth, imgHeight, imgTitle, background)
/***********************************************************************

	Description: Creates the popup for an image.
	
	Specify:
	
	img					specify name *and* extension, plus the path relative to the /gfx/figure/ directory.
	imgWidth		width of the image
	imgHeight		height of the image
	imgTitle    this is used for the popup window's title
	background	background-color value. Any valid CSS value works

 **********************************************************************/
{
	var popupWidth = imgWidth + 20;				/* account for left and right borders, plus 10px padding around image */
	var popupHeight = imgHeight + 82;			/* account for top and bottom borders, plus 10px padding around image */

	var x, y;

	/* center the popup window horizontally between the edges of the 
	   parent browser window, and down a fixed arbitrary valued */
	if (self.screenTop) { 			// Explorer returns coordinates of viewport
		x = self.screenLeft + (document.documentElement.clientWidth - popupWidth)/2;
		y = self.screenTop - 50;
	} 
	else {  										// Gecko returns coordinates of browser window
		x = self.screenX + (self.outerWidth - popupWidth)/2;
		y = self.screenY + 100;
	}
	
	var url="template/image_popup.php?img="+img+"&imgTitle="+imgTitle+"&background="+background;
	/* var url="gfx/figure/tech/"+img;         -- this is for debug -- */
	var pf=window.open(url,"popupImg","width="+popupWidth+",height="+popupHeight+",resizable=0,scrollbars=0,status=0");

	pf.moveTo(x,y);
	pf.focus();
}