function Dialog(title)
{
	Window.apply(this, [title]);
}

Dialog.prototype = new Window();

Dialog.prototype.doModal = function()
{
	var desktop = new Desktop();
	var overlay = document.createElement("div");
	var currentOpacity = 0;
	var thisRef = this;
	
	with(overlay.style)
	{
		position = "absolute";
		left = 0;
		top = 0;
		width = document.body.clientWidth;
		height = document.body.clientHeight;
		background = "black";
		
		/*opacity = 0.75; 
		MozOpacity = 0.75; 
		KhtmlOpacity = 0.75; 
		filter = "alpha(opacity=75)";*/
				
		/* if(Toolkit.getBrowser() == Toolkit.INTERNET_EXPLORER)
		{
			filter = "progid:DXImageTransform.Microsoft.Alpha(enabled=1,opacity=75)";
		} else
		{
			MozOpacity = "alpha(opacity=0.75);";
		} */
	}
	
	desktop.setBounds(0, 0, document.body.clientWidth, document.body.clientHeight);
	desktop.domContainer.style.background = "";
	
	this.setLocation(desktop.getWidth()/2 - this.getWidth()/2, desktop.getHeight()/2 - this.getHeight()/2);
	
	/*var childNodes = document.body.childNodes;
	
	for(var i = 0; i < childNodes.length; i++)
	{
		var childNode = childNodes[i];
		
		childNode.style.filter = "progid:DXImageTransform.Microsoft.BasicImage(grayscale=1)";
		
		for(var property in childNode)
		{
			if(property.length > 2 && property.substring(0, 2) == "on")
			{
				childNode["__modal_" + property] = childNode[property];
				childNode[property] = null;
			}
		}
	}*/
	
	var fade = function() {
		with(overlay.style)
		{
			opacity = currentOpacity; 
			MozOpacity = currentOpacity; 
			KhtmlOpacity = currentOpacity; 
			filter = "alpha(opacity=" + (currentOpacity * 100) + ")";
			
			currentOpacity += 0.1;
			
			if(currentOpacity < 0.85)
			{
				window.setTimeout(fade, 10);
			} else
			{
				desktop.add(thisRef);
			}
		}
	};
	
	window.setTimeout(fade, 0);
	
	document.body.appendChild(overlay);
	document.body.appendChild(desktop.domContainer);
};

Dialog.alert = function(title, text, type)
{
	var dialog = new Dialog(title);
	var contentPane = dialog.getContentPane();
	
	contentPane.domContainer.innerHTML = text;
	
	dialog.setSize(320, 180);
	dialog.doModal();
}
