// Pane windowing system
// Gianni Chiappetta - 2006
function Pane(paneID) {
	this.active = false;
	this.pane = $(paneID);
	
	// Get pane-windows
	this.paneWindows = document.getElementsByClassName('pane-window', this.pane);
	
	// Hide all panes
	this.paneWindows.each( function(pw) {
		Element.hide(pw);
	});
	
	// Link functions
	this.deactivate = function() { deactivate(arguments[0]); }
	
	// Functions
	function deactivate() {
		if (arguments[0]) {
			pw = arguments[0];
			
			if (typeof pw == 'number') { // Pane # to deactivate
				//Effect.BlindUp(this.paneWindows[pw-1], {duration: 0.4});
				Element.hide(this.paneWindows[pw-1]);
				this.active = false;
			}
			else if (typeof pw == 'string') { // ID of pane to deactivate
				//Effect.BlindUp(pw, {duration: 0.4, queue: {position:'end', scope: 'panescope', limit:2}});
				Element.hide(pw);
				this.active = false;
			}
		}
		else {
			if (this.active) {
				//Effect.BlindUp(this.active, {duration: 0.4, queue: {position:'end', scope: 'panescope', limit:2}});
				Element.hide(this.active);
				this.active = false;
			}
		}
	} // deactivate

	this.activate = function(pw) {
		if (typeof pw == 'number') { // Pane # to activate
			if (this.active != this.paneWindows[pw-1].id) {
				if (this.active && this.active != this.paneWindows[pw-1].id) deactivate();
				
				//Effect.BlindDown(this.paneWindows[pw-1], {duration: 0.4, queue: {position:'end', scope: 'panescope', limit:2}});
				Element.show(this.paneWindows[pw-1]);
				this.active = this.paneWindows[pw-1].id;
				active = this.paneWindows[pw-1].id;
			}
		}
		else if (typeof pw == 'string') { // ID of pane to activate
			this.paneWindows.each( function(pwRef) {
				if (pw == pwRef.id) {
					if (this.active != pw) {
						if (this.active && this.active != pw) deactivate();
	
						//Effect.BlindDown(pw, {duration: 0.4, queue: {position:'end', scope: 'panescope', limit:2}});
						Element.show(pw);
						this.active = pw;
						active = pw;
					}
				}
			});
		}
	} // activate
}


