function Desktop()
{
	extend(this, Container);
	this.desktopManager = new DesktopManager();
};

Desktop.prototype = new Container();

Desktop.prototype.getDesktopManager = function()
{
	return this.desktopManager;
};

// public void install(Element<?> domContainer);
Desktop.prototype.install = function(domContainer)
{
	if(!domContainer)
	{
		throw new Error("Desktop.install() - parameter 'domContainer' cannot be null");
	} else
	{		
		var updateSize = getMethodPointer(this, function()
		{
			this.setSize(domContainer.clientWidth, domContainer.clientHeight);
		});
		
		this.uninstall();
		
		domContainer.appendChild(this.domContainer);
		domContainer.onresize = updateSize;
		
		this.parentDomContainer = domContainer;
		
		updateSize();
	}
}

// public void uninstall();
Desktop.prototype.uninstall = function()
{
	if(this.parentDomContainer)
	{
		this.parentDomContainer.onresize = null;
		delete this.parentDomContainer;
	}
};

// public String getWidgetName();
Desktop.prototype.getWidgetName = function()
{
	return "desktop";
};

// public String bringToFront(Widget widget);
Desktop.prototype.bringToFront = function(widget)
{
	if(widget.container == this)
	{
		var maxZIndex = 1;
		
		for(var i = 0; i < this.widgets.length; i++)
		{
			var aWidget = this.widgets[i];
			
			if(aWidget != widget)
			{
				try
				{
					maxZIndex = Math.max(parseInt(aWidget.domContainer.style.zIndex) + 1, maxZIndex);
				} catch (e)
				{
				}
			}
		}
		
		widget.domContainer.style.zIndex = maxZIndex;
	}
};

Desktop.prototype.toString = function()
{
	return "Widget/Desktop";
}
