// 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.winName = "";					// JavaScript window name
	this.winPointer = false;				// Pointer to new window
}

// implementation --------------------------------------------------------------

// function doOpen(ASPdoc)
function doOpen(ASPdoc,width,height)
{
	var winProperties;

	// check if we already have a pointer to an open window
	if (!this.winPointer || this.winPointer.closed)
	{
		winProperties = "toolbar=no,location=no,directories=no,status=no," +
			"menubar=no,scrollbars=yes,resizable=yes,width=" + width + ",height=" + height;
	
		// first load an HTML file that doesn't need the ASP session cookie
		this.winPointer = window.open(this.HTMLdoc, this.winName, 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;
	//this.winPointer.document.location.reload();
	
	// set focus on new window
	this.winPointer.focus();
}

// function doClose()
function doClose(theURL)
{
	if (this.winPointer) 
	{
		if (theURL!="")
			this.winPointer.opener.parent.location.replace(theURL);
			
		this.winPointer.close();
	}
}
