
FXEDITOR_MAIL = Class.create();
FXEDITOR_MAIL.prototype = Object.extend(new FXEDITOR, {
	
	initialize: function () {
		this.id = "fxeditor_mail";
		this._ckconfig = '../../config/config_mail.js';
	},
	
	/**
	 * @inherits
	 */
	notifyChange: function(isNotifyFlex, interval) {
		var fxeditor = this;
		if (isNotifyFlex == null) {
			isNotifyFlex = true;
		}
		if (interval == null) {
			interval = 100;
		}
		if (this._editor != null && this._contentChanged) {
			this._editor.setData(this.content, function() {
				fxeditor.notifyChange(false, 1000);
			});
			this._contentChanged = false;
		}
		
		if (fxeditor._editor != null) {
			setTimeout(function() {
				try {
					var html = ""
					
					// body追加
					html += fxeditor.getContent();
					
					var htmlSize = FXEDITOR.getContentSize(html, fxeditor.career);
					
					$("main").updateSize(htmlSize);
					
					// プレビューに変更を通知します。
					fxeditor._preview.updateContent(
						FXEDITOR.replaceImage(html, fxeditor.career));
					
				} catch (e) {
					var n = "";
					for (var o in e) {
						n += e[o] + "\n";
					}
					alert(n);
				}
			}, interval);
		}
	},
	
	/**
	 * @inherits
	 */
	getContent: function () {
		if (this._editor != null) {
			this._editor.updateElement();
			var html = this._editor.getData();
			return FXEDITOR.decodeHtml(html);
		} else {
			return "";
		}
	},
	
	/**
	 * @inherits
	 */
	setContent: function (value) {
	
		if (value == null || value == "") return;
		
		// 改行を一旦<br />に変換しておく
		var html = value;
		html = html.replace(/\r\n/g, "<br />");
		html = html.replace(/(\n|\r)/g, "<br />");
		
	
		this._contentChanged = true;
		this.content = html;
		this.notifyChange(false);
	}
	
});
