/*--------------------------------------------------------------------------------------
WindowObject.js
creates common function names for accessing windows and their events.
functions under Netscape 4+, IExplorer 4+
Initally created Fall 1998,
current version 2001.02.11 Steve Savage info@realitystorm.com
--------------------------------------------------------------------------------------
*/

// to store margin widths, calculated once then used by all windows.
this.i_marginLeft = -1;
this.i_marginTop = -1;

function WindowObject(o_Window, s_file, s_id, i_width, i_height, s_appearance)
{
	// o_Window 			: the window to create the object for, if '0' create a popup.
	// s_file 				: the file to open in the window.
	// s_id						: the id to be given to the object (must be unique within the parent document)
	// i_width				: the optional initial inner-width of the window
	// i_height				: the optional initial inner-height of the window
	// s_appearance		: toolbar=yes/no, menubar=yes/no, status=yes/no, scroollbars=yes/no, resizable=yes/no etc.

	// set defaults
	this.id = "popup";
	this.s_file = document.location;
	this.i_width = 100;
	this.i_height = 100;
	this.i_currentX = 0;
	this.i_currentY = 0;
	this.s_appearance = null;

	if(o_Window != '0')	
		{ this.window = o_Window;}
	else
	{
		if (s_id) this.id = s_id; 
		if (s_file) this.s_file = s_file; 
		if (i_width) this.i_width = i_width; 
		if (i_height) this.i_height = i_height;
		if (s_appearance) this.s_appearance = eval(inTop);

		var windowSettings ="width=" + this.i_width + ",height=" + this.i_height + ","
		if (this.s_appearance) {windowSettings += appearance;}
		else {windowSettings+="toolbar=no,menubar=no,status=no,scroollbars=no,resizable=no";}
		this.window = window.open(s_file, s_id, windowSettings);
	}

	// used by animation functions.
	// settings
	this.i_targetX = 0;
	this.i_targetY = 0;
	this.b_visible = true;
	this.b_bound = false;
	this.s_endFunction = null;
	this.i_timer = 50;

	// this function is run whenever the window moves function is run.
	this.onmove = null;

	// set by animation functions.
	this.b_moving = false;
	this.b_collisionX = false;
	this.b_collisionY = false;
}

///////////////////////////////////////////////////////////////////////////
// define functions used to manipulate the properties of the window
WindowObject.prototype.close = function()
	{ if((this.window != null) && (!this.window.closed)) this.window.close();}

WindowObject.prototype.closed = function()
	{ if(this.window != null) { return this.window.closed; } else { return true; }}

WindowObject.prototype.loaded = function()
{ 
	if(this.window&&!this.window.closed)
	{
		if(this.window&&!this.window.closed&&this.window.document)
		{
			if(document.all)
			{ 
				if(this.window.document.body) return true
				else return false;
			}
			else return true;
		}
		else return false;
	}			
	else return false;
}

// present for compatibility with animateObject.js
WindowObject.prototype.setVisibility = function() {}
WindowObject.prototype.getVisibility = function() { return true; }	

function sf_popup(inURL,inWidth,inHeight)
{
	sv_popup_hdnl=window.open(inURL, "pop_window", "toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars,resizable,width=" + inWidth + ",height=" + inHeight);
	sv_popup_hdnl.focus();
}