/**
 * QLIB 1.0 Window Control
 * Copyright (C) 2002 2003, Quazzle.com Serge Dolgov
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * http://qlib.quazzle.com
 */
 
 /*
		Description
		-----------

		A window is a rectangle area on the screen which content is clipped if exceeds the client area. It's defined by position, the client area size, the client content and by set of extended optional properties such as initial visibility, opacity, stacking order, effects and transitions. According to DHTML principals, the height of a window is optional. If this property is missed, the window automatically selects the proper height to fit the content size (auto-height window). 

		The content must be provided either as a string or as a function (or method). The first way is preferable when you need to fill a window with HTML code you already have. Functional content is useful when other QLIB controls are created in the window or even the hierarchy of nested windows is created. 

		QLIB window control brings up an easiest way to enrich your page appearance with variety of animated transition effects. Basically the most of such effects are available only in IE browser, others just ignore them. But there's a lucky exception: mozilla-family browsers do support CSS opacity and fade-in/fade-out transition (emulated by the script). This list includes Netscape 6, Netscape 7 and Mozilla 1.0. 

		Implementation Notes
		--------------------

		For details of cross-browser support refer to Implementation Notes to QWndCtrl class. 

		See Also
		--------

		QWndCtrl, Windowing 

		Constructor
		-----------

		QWindow(parent, name, x, y, width, heightopt, content, visibleopt, effectsopt, opacityopt, zindexopt) 

		Creates new window. If the window is created as a child control, valid parent object must be specified. If the window is assigned to global variable, parent should be null. The name should be the same as the name of variable or property that has been assigned by newly created object. 

		Parameters
		----------

		parent - Parent control (if any, null otherwise).
		name - The object reference name.
		x, y - Coordinates of the top left corner in pixels. If the window is created in document context, it gets positioned in absolute page coordinates. If this window is nested in another one, it's positioned in relative coordinates of the parent.
		width - The window width in pixels.
		height - The window height in pixels. If you want the window to automatically select the height to fit the content, set this parameter to null.
		content - The window content provided either as a HTML code or by a function (see the example).
		visible - Optional initial visibility. By default the window appears visible.
		effects - Optional effects mask. By default the window is created with no effects. For complete list of effects refer to QWndCtrl page.
		opacity - Optional opacity from 0 to 100. Default value is 100 that corresponds to 100% opaqueness.
		zindex - Optional stacking order. If you need the browser to select it automatically let this parameter be null. 

		Properties
		----------

		Property 	Access	Description 

		Properties inherited from QWndCtrl 

		x 		R 	X coordinate of the window top left corner (pixels). 
		y 		R 	Y coordinate of the window top left corner (pixels). 
		width 		R 	Width in pixels of the window client area. 
		height 		R 	Height in pixels of the window client area (null if the window is auto-sized). 
		content 	R 	The window content (it's either a string or a function). 
		visible 	R 	Current visibility state. 
		effects 	R 	Current effects mask. 
		opacity 	R 	The window opacity from 0 (transparent) to 100 (opaque). 
		zindex 		R 	The window stacking order. Is null if the window is an auto-stacked. 
		 
		Properties inherited from QControl 

		name 		R 	Name of the control. Serves as a direct reference to this object when evaluated. 
		id 		R 	Alphanumerical unique identifier of the control. 
		parent 		R 	Reference to the parent control (if any, null otherwise). 
		tag 		R / W 	Can refer any value or object, tag is always passed to all event handlers as the last parameter. 
		window 		R 	This property is a reference to JavaScript window object in which the control exists. 
		document 	R 	Refers to document object in which the corresponding HTML elements exist. Normally all elements of a DOM2 compatible browser are children of the top document object. If the control creates new document scope (i.e. printing tags like <IFRAME>, <LAYER>), it should assign this document to this property. 

		Methods
		-------

		show(show) 

		Shows or hides the window. "IN" and "OUT" transitions can be assigned to show and hide actions respectively (see setEffects method). In this case the window does not show/hide promptly, instead the window smoothly changes its visibility through animation. 

		Parameters
		----------

		show - Desirable state as follows: true - make it visible, false - hide the window. 

		focus() 

		Gives the focus to the window. This brings it to the top of the stacking order.  

		center() 

		Centers the window on page.  

		moveTo(x, y) 

		Moves the window to specified position. If the window has been created in document context, it gets positioned in absolute page coordinates. If the window is nested in another one, it's positioned in relative coordinates of the parent window (see CSS positon property for more details). 

		Parameters
		----------

		x - X coordinate in pixels.
		y - Y coordinate in pixels. 

		setSize(w, hopt) 

		Resizes the window. The content gets relayouted to fill the area changed. See Implementation Notes for details of cross-browser support. 

		Parameters
		----------

		w - The window width in pixels.
		h - Optional. The window height in pixels. The window automatically selects the proper height is this parameter is skipped or null 

		setZIndex(z) 

		Changes the stacking order of the window. Window with higher index appear on the screen first obscuring underlying windows with lower indices. 

		Parameters
		----------

		z - Desirable stacking index (starting from 1).
		 
		setOpacity(op) 

		Changes the window opacity. See Implementation Notes for details and how this method is supported. 

		Parameters
		----------

		op - Desirable opacity as follows: 0 - transparent, 100 - opaque. 

		setEffects(fx) 

		Sets effects mask. There're two kinds of effects: static and dynamic. Static effects change the default appearance of the window (for example, a window casts shadow when it's set by QWndCtrl.SHADOW). On the other hand, dynamic effects are transitions that get activated when window changes its visibility state. A dynamic effect can be either "IN" or "OUT". The first type is played when a window appears. The second one is activated on the hiding. Effects of all types can be mixed together to bring up a composite effect (example: "QWndCtrl.SHADOW + QWndCtrl.BOXIN + QWndCtrl.FADEOUT" - makes a window to cast shadow, it appears with "box" effect, hides itself fading out from view). 

		Parameters
		----------

		fx - Mix of effects to apply. 

		Event Handlers
		--------------

		onShow(visible, tag) 

		This handler is fired when the window becomes visible or vanishes. When transitions are enabled, the handler is fired after the animation completes. 

		Parameters
		----------

		visible - Visibility state of the window.
		tag - Tag is commonly used to parameterize the event handler. Each control can be optionally assigned by a tag.

		Returns

		The return value is ignored. 

		CSS Class Selectors
		-------------------

		CSS Class Description Example (defined in a CSS file) 
		DIV.qwindow Defines style properties of the window DIV element. DIV.qwindow { background-color: red } // sets the window background to red.
  */

function QWindow(parent, name, x, y, width, height, content, visible, effects, opacity, zindex) 
{
    this.init(parent, name);
    this.x = x - 0;
    this.y = y - 0;
    this.width = width - 0;
    this.height = (typeof(height) == "number") ? height : null;
    this.content = content;
    var j = QWindow.arguments.length;
    this.visible = (j > 7) ? visible : true;
    this.effects = (j > 8) ? effects : 0;
    this.opacity = (j > 9) ? opacity : 100;
    this.zindex  = (j > 10) ? zindex : null;
    this.create();
}

QWindow.prototype = new QWndCtrl();

