/*************************************************************************
	sub_win.js 
	version date: June 2002
	code for opening sub-window centered on screen 
	used for presenting example documents at dyn-web.com 
	
	This code is from Dynamic Web Coding 
  at http://www.dyn-web.com/
  See Terms of Use at http://www.dyn-web.com/bus/terms.html
  Permission granted to use this code 
  as long as this notice is included.
*************************************************************************/


/*************************************************************************
	These variables can be set in html document
	before the script tags for this file
	or use default values provided below.
var subWinWd = 550;	// width of sub-window
var subWinHt = 350;	// height of sub-window
var subWinChrome = "menubar,resizable,scrollbars";

This is how you set up the link to open the sub-window:
<a href="javascript://" onclick="getSubWin('hi.html')" onmouseover="window.status='opens sub-window with example'; return true" onmouseout="window.status=''">Open</a>

*************************************************************************/

var screenWidth = screen.availWidth;
var screenHeight = screen.availHeight;
// defaults
if (typeof subWinWd=="undefined") var subWinWd=550;
if (typeof subWinHt=="undefined") var subWinHt=350;
if (typeof subWinChrome=="undefined") 
	var subWinChrome="menubar,resizable,scrollbars";
var subWinTop = Math.round((screenHeight-subWinHt)/2);
var subWinLeft = Math.round((screenWidth-subWinWd)/2);

// opens sub-window 
var newWin = null;
function getSubWin(url) {
 	if (newWin && !newWin.closed) newWin.focus();
	newWin = window.open(url, "subwin", subWinChrome+",height="+subWinHt+",width="+subWinWd+",top="+subWinTop+",left="+subWinLeft);
}

// close window when page unloads
function closeWin() {
	if (newWin && !newWin.closed) newWin.close();
}
window.onunload=closeWin;
