/**
 * a Dialog which has a title bar with a close button
 */
Dialog = function() {
	this.args = []
	for (var i=0; i<arguments.length; i++) this.args[i] = arguments[i]
	var defaults = {
		options:{}
	}
	for (i in defaults) {
		try {
			if (arg = this.args.shift()) this[i] = arg
			else this[i] = defaults[i]
		} catch(ex) {
			logs(ex)
		}
	}
	this.view = {}
	this.view.dialog = new DIV(
		{
			'class':'dialog',
			'style':{
				'width':this.options.width,
				'height':this.options.height,
				'top':'0',
				'left':'0'
			}
		}, 
		this.view.title_bar = DIV({'class':'title_bar'},
			this.view.title = SPAN({'class':'title'},this.options.title || 'Dialog'),
			this.view.close = SPAN({'class':'close'}, this.options.close || ' X ')),
		this.view.body = DIV({'class':'body','style':{
			'position':'absolute',
			'height':'100%',
			'width':'100%'
		}}, this.args))
			
	connect(this.view.close, 'onclick', bind(function(e){
		signal(this,'onclosing', e)
	}, this.view.dialog))
			
	return this.view.dialog
}
Dialog.prototype = {
	toString:function() {
		return "<Dialog: >"
	}
}
