
_windowChildren = new Array(0);

function openWindow( pURL, pOptions )
{
	function getOption( pKey, pOptions )
	{
		return ( pOptions ) ? findValue( pKey + ':', pOptions, ';'):null;
	}
	
	var lName = getOption( 'name', pOptions );
	var lTips = getOption( 'tips', pOptions );
	var lReplace = getOption( 'replace', pOptions );
	var lWindow;
	
	if ( lName )
	{
		lWindow = window.open( pURL, lName, lTips, lReplace );
		
		addChildWindow( lWindow );
	}
	else
		window.location = pURL;
	
	return ( lWindow != null );
}

function addChildWindow( pWindow )
{
	var lIdx;
	
	lIdx = _windowChildren.length;
	
	_windowChildren[lIdx] = pWindow;
	_windowChildren[++lIdx] = null;
}

function closeChildWindows()
{
	var lIdx;
	var lWindow;
	
	for ( lIdx = 0; lIdx < _windowChildren.length; lIdx++ )
	{
		lWindow = _windowChildren[lIdx];
		
		if ( ( lWindow != null ) && lWindow.closed == false )
			lWindow.close();
	}
}

function closeWindow()
{
	closeChildWindows();
	
	window.close();
}

function isWindowInFrame()
{
	return ( window.top.frames.length > 0 );
}

function printWindow()
{
	window.print();
}
