CMS.Alert = CMS.Widget.extend({
	title: "Alert",
	text: "Dit is een alert!",
	
	_window: null,
	
	_buttons: null,
	
	_callbacks: [],
	
	construct: function(title,text) {
		arguments.callee.$.call(this);
		
		if ( title != undefined ) { this.title = title; }
		if ( text != undefined ) { this.text = text; }
	},
	
	show: function() {
		this._buttons = document.createElement("div");
		addClass(this._buttons, 'Buttons');
				
		var _this = this;
		//addEvent(this._ok, 'click', function() {_this.handleOk();});
		
		//this._ok.appendChild(document.createTextNode(this.ok));
	
		this._window = new CMS.Window(this.title);
		this._window.width = 600;
		this._window.height = 250;

		this._window.addElement(document.createTextNode(this.text));
		this._window.addElement(this._buttons);

		this._window.show();
	},
	
	hide: function() {
		this._window.hide();
	},
	
	handleOk: function() {
		this.hide();
		this.callback(this._tree.getSelected());
	},
	
	handleCancel: function() {
		this.hide();
		this.callback([]);
	},
	
	callback: function(value) {
		if (!this.multiple) {
			if (value.length>0) {
				value = value[0];
			} else {
				value = null;
			}
		}
	
		for (var i = 0; i < this._callbacks.length; i++) {
			this._callbacks[i](value);	
		}
	},
	
	addCallback: function(func) {
		this._callbacks.push(func);
		return this;
	}	
});