var WindowFunctions = new function()
{
	/**
	 *
	 */
	var oWindowsByName = new Object();

	/**
	 *
	 *
	 */
	this.openWindow = function( sName, sUrl, oFeatures, bForceReloadWhenOpen )
	{
		oFeatures = oFeatures || new this.WindowFeatures(); // Create default empty features
		if ( oWindowsByName[ sName ] && !oWindowsByName[ sName ].closed )
		{
			// TODO: Other checks to ensure the window is not closed/closing etc.
			// TODO: Focus or reload.
			oWindowsByName[ sName ].focus();
		}
		else
		{
			var sFeatures = oFeatures.getFeatureString();
			oWindowsByName[ sName ] = window.open( sUrl, sName, sFeatures );									
		}	
	}
	
	/**
	 *
	 *
	 */
	this.WindowFeatures = function( iWidth, iHeight )
	{
		var iW = iWidth;
		var iH = iHeight;
		
		this.getFeatureString = function()
		{
			var sString = ( iW?"width=" + iW: "" );
			sString += ( sString != ""?",":"" );
			sString += ( iH?"height=" + iH: "" );
			sString += ( sString != ""?",":"" );
			sString += "scrollbars=1";
			
			return sString;
		}
	}
} 