var bIsIE
bIsIE  = (document.all) ? true : false;

////////////////////////////////////////////////////////////////////////////
// Window functions
//
// create array to keep track of open child windows
var g_childWindowArray = new Array();

function getPointForCenteredWindow(windowWidth, windowHeight)
{
	var point = new Object();

	// get point for centered window based on current screen resolution setting
	var screenWidth = screen.width;	
	var screenHeight = screen.height;
	var x = (screenWidth - windowWidth)/2;
	var y = (screenHeight - windowHeight)/2;
	point.x = x;
	point.y = y;

	return point;
}

/////////////////////////////////////////////////////////////////////////
// function openModelessWindow(
//		strUrl, strWindowName, 
//		strFeatures, windowWidth, 
//		windowHeight, bCenter)
//
// params:	strUrl -		url of file to open in window
//			width -			the width of the window to be opened
//			height -		the height of the window to be opened
//			strFeatures -	string containing an feature list (do not include width and height)
//							(see documentation for window.open()
//			bCenter -		pass true to center window (default is true)
//
// 
// This function centers a window based on the current screen resolution and
// client width and height.
//
function openModelessWindow(strUrl, strWindowName, strFeatures, windowWidth, windowHeight, bCenter, x, y)
{
	var windowHandle;
	var x, y;
	
	if (x == null) 
		x = 0;
	if (y == null)
		y = 0;
	
	// center window based on current screen resolution setting
	if ((bCenter == true) || (bCenter == null))
	{
		var Point = getPointForCenteredWindow(windowWidth, windowHeight);
		x = Point.x;
		y = Point.y;
	}
	
	if (bIsIE)
		strFeatures = strFeatures + ",width=" + windowWidth + ",height=" + windowHeight +
				",left=" + x + ",top=" + y;
	else
		strFeatures = strFeatures + ",outerWidth=" + windowWidth + ",outerHeight=" + windowHeight +
				",screenX=" + x + ",screenY=" + y;

	windowHandle = window.open(strUrl, strWindowName, strFeatures);
	return windowHandle;
}

/////////////////////////////////////////////////////////////////////////
// function addChildWnd(objWnd)
//
// params:	objWnd -		A window handle that is returned when you call window.open
// 
// This finction stores window handles in an array.
//
function addChildWnd(objWnd)
{
	var i;
	for (i = 0; i < g_childWindowArray.length; i++)
	{
		if (g_childWindowArray[i] == objWnd)
			return;
	}
	
	g_childWindowArray[i] = objWnd;
	
}

/////////////////////////////////////////////////////////////////////////
// function closeAllChildWindows()
//
// This finction closes all child windows.
//
function closeAllChildWindows()
{
	var i;
	for (i = 0; i < g_childWindowArray.length; i++)
	{
		if (!g_childWindowArray[i].closed)
		{
			g_childWindowArray[i].focus();
			g_childWindowArray[i].close();
		}
	}
}


