// Name   : newWindowHandler (v1.0.1)
// Args   : none
// Desc   : This JavaScript object is designed to display an Active Server 
//          Page - which requires access to the user's Session object - in 
//          a new window. Therefore it first loads an HTML document in the new 
//          window, then copies the cookie from the current window to the new 
//          window and then loads the ASP document.
// Author : Gerrie Kimpen (c) Katholieke Hogeschool Kempen - 1999
////////////////////////////////////////////////////////////////////////////////

// object constructor function -------------------------------------------------
function newWindowHandler() {
	// methods
	this.open = doOpen;
	this.close = doClose;
	// properties
	this.HTMLdoc = "";					// HTML doc to load before ASP doc
	this.winProperties = "";			// JavaScript windows properties
	this.winName = "";					// JavaScript window name
	this.winPointer = false;			// Pointer to new window
}

// implementation --------------------------------------------------------------

// function doOpen(ASPdoc)
function doOpen(ASPdoc)
{
	// check if we already have a pointer to an open window
	if (!this.winPointer || this.winPointer.closed)
	{
		// first load an HTML file that doesn't need the ASP session cookie
		this.winPointer = window.open(this.HTMLdoc, this.winName, this.winProperties);
		
		// copy cookie of current window to new window; that's the whole point!
		this.winPointer.document.cookie = self.document.cookie;
	}
	
	// now the cookie is set, load the ASP file
	this.winPointer.location = ASPdoc;
	
	// set focus on new window
	this.winPointer.focus();
}

// function doClose()
function doClose()
{
	if (this.winPointer) this.winPointer.close();
}
