function WindowPane(wmanager, paneParent,left,right,top,bottom,width,height,help,alt) {
	var titleBar, content, resizer;
	var Pane;

	var MySelf = this;

	/** Initial Setup **/

	Pane = document.createElement('div');
	Pane.className = 'WindowPane';
	Pane.style.left = left;
	Pane.style.top = top;
	Pane.style.right = right;
	Pane.style.bottom = bottom;
	Pane.style.width = width;
	Pane.style.height = height;

	Pane.style.zIndex = DEFAULT_WINDOW_INDEX;

	titleBar = document.createElement('div');
	titleBar.className = 'TitleBar';

	if(help) {
		var helpImg = document.createElement('img');
		helpImg.src = HELP_DEFAULT_ICON;
		var helpLink = document.createElement('a');
		helpLink.href = help;
		helpLink.target = '_blank';
		helpImg.style.right = '2px';
		helpImg.style.position = 'absolute';
		helpLink.appendChild(helpImg);
		Pane.appendChild(helpLink);
		if(alt) {
			helpImg.setAttribute("alt", alt);
			helpImg.setAttribute("alternative", alt);
			helpImg.setAttribute("title", alt);
		}
	}

	content = document.createElement('div');
	content.className = 'Content';

	resizer = document.createElement('div');
	resizer.className = 'Resizer';
 
	Pane.appendChild(titleBar);
	Pane.appendChild(content);
	Pane.appendChild(resizer);

	// Register with the Window Manager
	wmanager.addWindow(MySelf);

	this.showWindowPane = function(passParent) {
		if(passParent) {
			paneParent = passParent;
		}
		Pane.className = 'WindowPane';
		Pane.style.visibility = 'visible';
		paneParent.appendChild(Pane);
		resizeContent();
	}

	this.hideWindowPane = function() {
//		Pane.className = 'HiddenWindowPane';
		Pane.style.visibility = 'hidden';
	}
	
	this.toggleVisibility = function() {
		if(Pane.style.visibility == 'hidden') {
			Pane.style.visibility = 'visible';
		} else {
			Pane.style.visibility = 'hidden';
		}
	}
	titleBar.onmousedown = function() {
		Pane.className = 'WindowPaneSelected';
		wmanager.selectWindow(MySelf);
	}

	titleBar.onmouseup = function() {
		Pane.className = 'WindowPane';
	}

	this.setTitleBarImage = function(img) {
		titleBar.style.backgroundImage = 'url('+img+')';
	}


	this.getTitleBar = function() {
		return titleBar;
	}
	
	this.getContent = function() {
		return content;
	}

	this.setContent = function(obj) {
		content = obj;
	}

	this.getPane = function() {
		return Pane;
	}

	function convertToPercent(obj) {
		var wSize = getWindowSize();
		var parent = obj.parentNode;
		if(parent.offsetWidth > 0) { wSize.x = parent.offsetWidth; }
		if(parent.offsetHeight > 0) { wSize.y = parent.offsetHeight; }
		obj.style.width = (obj.offsetWidth / wSize.x) * 100 + '%';
		obj.style.height = (obj.offsetHeight / wSize.y) * 100 + '%';
		return false;
	}

	function resizeContent() {
		var elm = content;	
		var parent = content.parentNode;
		elm.style.height = parent.offsetHeight - titleBar.offsetHeight+ 'px';
		elm.style.width = parent.offsetWidth - resizer.offsetWidth + 'px';
		elm.style.top = titleBar.offsetHeight+'px';
	}

	this.resizeContent = function() {
		resizeContent();
	}

	this.onResize = function() {
		resizeContent();
	}

	function stopResizing(trigger,obj) {
		trigger.style.bottom = '0px';
		trigger.style.right = '0px';

		var parent = trigger.parentNode;
		convertToPercent(parent);
		MySelf.onResize();
		return false;
	}

	function resizeWindowPane(trigger,obj) {
		var parent = trigger.parentNode;
		parent.style.width = trigger.offsetLeft+obj.offsetWidth+1+'px';
		parent.style.height = trigger.offsetTop+obj.offsetHeight+1+'px';
		return false;
	}

	function normalizeWindowPaneBehavior(obj) {
		if(obj.style.left == 'auto') {
			obj.style.left = obj.offsetLeft + 'px';
			obj.style.right = 'auto';
		}
		if(obj.style.top == 'auto') {
			obj.style.top = obj.offsetTop + 'px';
			obj.style.bottom = 'auto';
		}
	}

	function shadeWindowPane(trigger) {
		var obj = trigger.parentNode;
		obj.old_height = obj.style.height;
		obj.style.height = trigger.offsetHeight+'px';

		trigger.ondblclick = function() { unshadeWindowPane(trigger); }
		return false;
	}

	function unshadeWindowPane(trigger) {
		var obj = trigger.parentNode;
		obj.style.height = obj.old_height;
		trigger.ondblclick = function() { shadeWindowPane(trigger); }
		return false;
	}

	titleBar.ondblclick = function () {
		shadeWindowPane(this);
	}
	
	var PaneDraggable = new Draggable(Pane, titleBar, true,true,false);

	/*
	 * Resizer Configuration
	 */

	resizer.onmousedown = function() { normalizeWindowPaneBehavior(Pane); }

	var ResizerDraggable = new Draggable(resizer,resizer,true,true,true);
	ResizerDraggable.whileDrag = resizeWindowPane;
	ResizerDraggable.onDrop = stopResizing;
}
