function slyTextEditor(textId, textNode) {
	this.textNode = textNode;
	this.textId = textId;
	this.node = document.createElement('div');
	this.base = slyDialog;
	this.base({title:'Text bearbeiten'});
	this.arrangeElements();
}
slyTextEditor.prototype = new slyDialog();

slyTextEditor.prototype.setDialogContent = function(parentNode, textNode) {
	var html = '<textarea id="slyNewsForm_text" style="height:300px"></textarea><p />';
	html += '<div style="text-align:right"><input type="button" value="Abbrechen" onclick="sly.dialog.cancel()" /> <input type="button" value="Speichern" onclick="sly.dialog.save()" /></div>';
	this.node.innerHTML = html;
	parentNode.appendChild(this.node);
	tinyMCE.execCommand("mceAddControl", true, "slyNewsForm_text");
	var _this = this;
	setTimeout(function() {
		_this.arrangeElements();
		sly.call('load', {entity:'texts', id:_this.textId}, function(data) {
			tinyMCE.activeEditor.setContent(data.res.text);
		});
		tinyMCE.execCommand("mceFocus", true, "slyNewsForm_text");
	}, 500);
};

slyTextEditor.prototype.cancel = function() {
	this.close();
};

slyTextEditor.prototype.save = function() {
	var _this = this;
	sly.call('save', {entity:'texts',id:this.textId,text:tinyMCE.activeEditor.getContent()}, function(data) {
		if (data.statusCode == 200) {
			_this.textNode.innerHTML = tinyMCE.activeEditor.getContent();
			_this.close();
		}
		else alert('Fehler');
	});
};
