/* -----------------------------------------------------------------------------
 * $Header: /home/cvs/projects/ieee-hawaii/web/js/jsutils.js,v 1.1 2006/04/18 08:34:45 thn Exp $
 *
 * Author: Tri H. Nguyen (thn@ieee.org)
 * Version: $Revision: 1.1 $ $Date: 2006/04/18 08:34:45 $
 *
 * -----------------------------------------------------------------------------
 */

// global window's "handle"
var g_oWindow = null;

/**
 * <p> Opens a new browser window
 *
 * @param strPage valid URL link
 * @param strTitle window's title name
 * @param nWindowWidth window's width in pixels
 * @param nWindowHeight window's height in pixels
 * @param nPosTop window's y-axis location in pixels
 * @param nPosLeft window's x-axis location in pixels
 *
 */
function openWindow(strPage, strTitle, 
                    nWindowWidth, nWindowHeight, 
                    nPosTop, nPosLeft)
{ 
	if (0 == nWindowWidth)
		nWidth   = 640; 
	else
		nWidth  = nWindowWidth; 
	
	if (0 == nWindowHeight) 
		nHeight  = 480; 
	else
		nHeight  = nWindowHeight; 
	
	nLeft    = nPosLeft;
	nTop     = nPosTop;
	
	bNo      = 0; 
	bYes     = 1; 
	
	bResize      = bYes; 
	bScrollbars  = bYes; 
	bStatus      = bNo; 
	bToolbar     = bYes; 
	bMenubar     = bNo; 
	bLocation    = bNo; 
	bDirectories = bNo; 
	
	strConfig  = "left= " + nLeft;
	strConfig += "," + "top="+ nTop; 
	strConfig += "," + "height="+ nHeight; 
	strConfig += "," + "width="+ nWidth; 
	strConfig += "," + "resizable=" + bResize; 
	strConfig += "," + "status="+ bStatus; 
	strConfig += "," + "toolbar="+ bToolbar; 
	strConfig += "," + "menubar="+ bMenubar; 
	strConfig += "," + "location="+ bLocation; 
	strConfig += "," + "scrollbars="+ bScrollbars; 
	
	if (g_oWindow != null)
	{
		if (g_oWindow.closed)
			g_oWindow = window.open(strPage, strTitle, strConfig);
		else
			g_oWindow.location = strPage;
	}
	else
		g_oWindow = window.open(strPage, strTitle, strConfig);
}

/**
 * <p> Closes an existing browser window
 *
 */
function closeWindow()
{
	if (g_oWindow != null)
		g_oWindow.close();
}
