(function() {
	var c = /^(H[1-6]|HR|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|CAPTION|BLOCKQUOTE|CENTER|DL|DT|DD|SCRIPT|NOSCRIPT|STYLE)$/i, f = /^(https?|ftp|rmtp|mms):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i, e = /<(script|noscript|style)[\u0000-\uFFFF]*?<\/(script|noscript|style)>/g;
	this.MooEditable = new Class(
			{
				Implements : [ Events, Options ],
				options : {
					toolbar : true,
					cleanup : true,
					paragraphise : true,
					xhtml : true,
					semantics : true,
					actions : "bold italic underline strikethrough | insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | createmailto removemailto | urlimage | toggleview",
					handleSubmit : true,
					handleLabel : true,
					disabled : false,
					baseCSS : "html{ height: 100%; cursor: text; } body{ font-family: sans-serif; }",
					extraCSS : "",
					externalCSS : "",
					html : '<!DOCTYPE html><html><head><meta charset="UTF-8">{BASEHREF}<style>{BASECSS} {EXTRACSS}</style>{EXTERNALCSS}</head><body></body></html>',
					rootElement : "p",
					baseURL : "",
					dimensions : null
				},
				initialize : function(a, b) {
					this.setOptions(b);
					this.textarea = document.id(a);
					this.textarea.store("MooEditable", this);
					this.actions = this.options.actions.clean().split(" ");
					this.keys = {};
					this.dialogs = {};
					this.protectedElements = [];
					this.actions.each(function(d) {
						var g = MooEditable.Actions[d];
						if (g) {
							if (g.options) {
								var k = g.options.shortcut;
								if (k)
									this.keys[k] = d
							}
							g.dialogs && Object.each(g.dialogs, function(j, l) {
								j = j.attempt(this);
								j.name = d + ":" + l;
								if (typeOf(this.dialogs[d]) != "object")
									this.dialogs[d] = {};
								this.dialogs[d][l] = j
							}, this);
							g.events && Object.each(g.events, function(j, l) {
								this.addEvent(l, j)
							}, this)
						}
					}.bind(this));
					this.render()
				},
				toElement : function() {
					return this.textarea
				},
				render : function() {
					var a = this, b = this.options.dimensions
							|| this.textarea.getSize();
					this.container = new Element("div", {
						id : this.textarea.id ? this.textarea.id
								+ "-mooeditable-container" : null,
						"class" : "mooeditable-container",
						styles : {
							width : b.x
						}
					});
					this.textarea.addClass("mooeditable-textarea").setStyle(
							"height", b.y);
					this.iframe = new IFrame( {
						"class" : "mooeditable-iframe",
						frameBorder : 0,
						src : 'javascript:""',
						styles : {
							height : b.y
						}
					});
					this.toolbar = new MooEditable.UI.Toolbar( {
						onItemAction : function() {
							var d = Array.from(arguments);
							a.action(d[0].name, d)
						}
					});
					this.attach.delay(1, this);
					this.options.handleLabel
							&& this.textarea.id
							&& $$('label[for="' + this.textarea.id + '"]')
									.addEvent("click", function(d) {
										if (a.mode == "iframe") {
											d.preventDefault();
											a.focus()
										}
									});
					if (this.options.handleSubmit) {
						this.form = this.textarea.getParent("form");
						if (!this.form)
							return;
						this.form.addEvent("submit", function() {
							a.mode == "iframe" && a.saveContent()
						})
					}
					this.fireEvent("render", this)
				},
				attach : function() {
					var a = this;
					this.mode = "iframe";
					this.editorDisabled = false;
					this.container.wraps(this.textarea);
					this.textarea.setStyle("display", "none");
					this.iframe.setStyle("display", "").inject(this.textarea,
							"before");
					Object.each(this.dialogs, function(k, j) {
						Object.each(k, function(l) {
							document.id(l).inject(a.iframe, "before");
							var m;
							l.addEvents( {
								open : function() {
									m = a.selection.getRange();
									a.editorDisabled = true;
									a.toolbar.disable(j);
									a.fireEvent("dialogOpen", this)
								},
								close : function() {
									a.toolbar.enable();
									a.editorDisabled = false;
									a.focus();
									m && a.selection.setRange(m);
									a.fireEvent("dialogClose", this)
								}
							})
						})
					});
					this.win = this.iframe.contentWindow;
					this.doc = this.win.document;
					if (Browser.firefox)
						this.doc.designMode = "On";
					var b = this.options.html
							.substitute( {
								BASECSS : this.options.baseCSS,
								EXTRACSS : this.options.extraCSS,
								EXTERNALCSS : this.options.externalCSS ? '<link rel="stylesheet" href="' + this.options.externalCSS + '">'
										: "",
								BASEHREF : this.options.baseURL ? '<base href="' + this.options.baseURL + '" />'
										: ""
							});
					this.doc.open();
					this.doc.write(b);
					this.doc.close();
					Browser.ie ? this.doc.body.contentEditable = true
							: this.doc.designMode = "On";
					Object.append(this.win, new Window);
					Object.append(this.doc, new Document);
					if (Browser.Element) {
						b = this.win.Element.prototype;
						for ( var d in Element)
							d.test(/^[A-Z]|\$|prototype|mooEditable/)
									|| (b[d] = Element.prototype[d])
					} else
						document.id(this.doc.body);
					this.setContent(this.textarea.get("value"));
					this.doc.addEvents( {
						mouseup : this.editorMouseUp.bind(this),
						mousedown : this.editorMouseDown.bind(this),
						mouseover : this.editorMouseOver.bind(this),
						mouseout : this.editorMouseOut.bind(this),
						mouseenter : this.editorMouseEnter.bind(this),
						mouseleave : this.editorMouseLeave.bind(this),
						contextmenu : this.editorContextMenu.bind(this),
						click : this.editorClick.bind(this),
						dblclick : this.editorDoubleClick.bind(this),
						keypress : this.editorKeyPress.bind(this),
						keyup : this.editorKeyUp.bind(this),
						keydown : this.editorKeyDown.bind(this),
						focus : this.editorFocus.bind(this),
						blur : this.editorBlur.bind(this)
					});
					this.win.addEvents( {
						focus : this.editorFocus.bind(this),
						blur : this.editorBlur.bind(this)
					});
					[ "cut", "copy", "paste" ].each(function(k) {
						a.doc.body.addListener(k, a["editor" + k.capitalize()]
								.bind(a))
					});
					this.textarea.addEvent("keypress", this.textarea.retrieve(
							"mooeditable:textareaKeyListener", this.keyListener
									.bind(this)));
					Browser.firefox2 && this.doc.addEvent("focus", function() {
						a.win.fireEvent("focus").focus()
					});
					this.doc.addEventListener
							&& this.doc.addEventListener("focus", function() {
								a.win.fireEvent("focus")
							}, true);
					if (!Browser.ie && !Browser.opera) {
						var g = function() {
							a.execute("styleWithCSS", false, false);
							a.doc.removeEvent("focus", g)
						};
						this.win.addEvent("focus", g)
					}
					if (this.options.toolbar) {
						document.id(this.toolbar).inject(this.container, "top");
						this.toolbar.render(this.actions)
					}
					this.options.disabled && this.disable();
					this.selection = new MooEditable.Selection(this.win);
					this.oldContent = this.getContent();
					this.fireEvent("attach", this);
					return this
				},
				detach : function() {
					this.saveContent();
					this.textarea.setStyle("display", "").removeClass(
							"mooeditable-textarea").inject(this.container,
							"before");
					this.textarea.removeEvent("keypress", this.textarea
							.retrieve("mooeditable:textareaKeyListener"));
					this.container.dispose();
					this.fireEvent("detach", this);
					return this
				},
				enable : function() {
					this.editorDisabled = false;
					this.toolbar.enable();
					return this
				},
				disable : function() {
					this.editorDisabled = true;
					this.toolbar.disable();
					return this
				},
				editorFocus : function(a) {
					this.oldContent = "";
					this.fireEvent("editorFocus", [ a, this ])
				},
				editorBlur : function(a) {
					this.oldContent = this.saveContent().getContent();
					this.fireEvent("editorBlur", [ a, this ])
				},
				editorMouseUp : function(a) {
					if (this.editorDisabled)
						a.stop();
					else {
						this.options.toolbar && this.checkStates();
						this.fireEvent("editorMouseUp", [ a, this ])
					}
				},
				editorMouseDown : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorMouseDown", [ a, this ])
				},
				editorMouseOver : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorMouseOver", [ a, this ])
				},
				editorMouseOut : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorMouseOut", [ a, this ])
				},
				editorMouseEnter : function(a) {
					if (this.editorDisabled)
						a.stop();
					else {
						if (this.oldContent
								&& this.getContent() != this.oldContent) {
							this.focus();
							this.fireEvent("editorPaste", [ a, this ])
						}
						this.fireEvent("editorMouseEnter", [ a, this ])
					}
				},
				editorMouseLeave : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorMouseLeave", [ a, this ])
				},
				editorContextMenu : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorContextMenu", [ a, this ])
				},
				editorClick : function(a) {
					if (Browser.safari || Browser.chrome) {
						var b = a.target;
						if (Element.get(b, "tag") == "img") {
							this.options.baseURL
									&& b.getProperty("src").indexOf("http://") == -1
									&& b.setProperty("src",
											this.options.baseURL
													+ b.getProperty("src"));
							this.selection.selectNode(b);
							this.checkStates()
						}
					}
					this.fireEvent("editorClick", [ a, this ])
				},
				editorDoubleClick : function(a) {
					this.fireEvent("editorDoubleClick", [ a, this ])
				},
				editorKeyPress : function(a) {
					if (this.editorDisabled)
						a.stop();
					else {
						this.keyListener(a);
						this.fireEvent("editorKeyPress", [ a, this ])
					}
				},
				editorKeyUp : function(a) {
					if (this.editorDisabled)
						a.stop();
					else {
						var b = a.code;
						if (this.options.toolbar
								&& (/^enter|left|up|right|down|delete|backspace$/i
										.test(a.key)
										|| b >= 33
										&& b <= 36
										|| b == 45
										|| a.meta || a.control))
							if (Browser.ie6) {
								clearTimeout(this.checkStatesDelay);
								this.checkStatesDelay = this.checkStates.delay(
										500, this)
							} else
								this.checkStates();
						this.fireEvent("editorKeyUp", [ a, this ])
					}
				},
				editorKeyDown : function(a) {
					if (this.editorDisabled)
						a.stop();
					else {
						if (a.key == "enter")
							if (this.options.paragraphise)
								if (a.shift
										&& (Browser.safari || Browser.chrome)) {
									var b = this.selection, d = b.getRange(), g = this.doc
											.createElement("br");
									d.insertNode(g);
									d.setStartAfter(g);
									d.setEndAfter(g);
									b.setRange(d);
									if (b.getSelection().focusNode == g.previousSibling) {
										d = this.doc.createTextNode("\u00a0");
										var k = g.parentNode;
										(g = g.nextSibling) ? k.insertBefore(d,
												g) : k.appendChild(d);
										b.selectNode(d);
										b.collapse(1)
									}
									this.win.scrollTo(0, Element.getOffsets(b
											.getRange().startContainer).y);
									a.preventDefault()
								} else {
									if (Browser.firefox || Browser.safari
											|| Browser.chrome) {
										b = this.selection.getNode();
										Element.getParents(b).include(b).some(
												function(j) {
													return j.nodeName.test(c)
												})
												|| this
														.execute("insertparagraph")
									}
								}
							else if (Browser.ie) {
								d = this.selection.getRange();
								b = this.selection.getNode();
								if (d && b.get("tag") != "li") {
									this.selection.insertContent("<br>");
									this.selection.collapse(false)
								}
								a.preventDefault()
							}
						if (Browser.opera)
							if ((b = a.control || a.meta) && a.key == "x")
								this.fireEvent("editorCut", [ a, this ]);
							else if (b && a.key == "c")
								this.fireEvent("editorCopy", [ a, this ]);
							else if (b && a.key == "v" || a.shift
									&& a.code == 45)
								this.fireEvent("editorPaste", [ a, this ]);
						this.fireEvent("editorKeyDown", [ a, this ])
					}
				},
				editorCut : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorCut", [ a, this ])
				},
				editorCopy : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorCopy", [ a, this ])
				},
				editorPaste : function(a) {
					this.editorDisabled ? a.stop() : this.fireEvent(
							"editorPaste", [ a, this ])
				},
				keyListener : function(a) {
					if ((Browser.Platform.mac ? a.meta : a.control)
							&& this.keys[a.key]) {
						a.preventDefault();
						this.toolbar.getItem(this.keys[a.key]).action(a)
					}
				},
				focus : function() {
					(this.mode == "iframe" ? this.win : this.textarea).focus();
					this.fireEvent("focus", this);
					return this
				},
				action : function(a, b) {
					var d = MooEditable.Actions[a];
					if (d.command && typeOf(d.command) == "function")
						d.command.apply(this, b);
					else {
						this.focus();
						this.execute(a, false, b);
						this.mode == "iframe" && this.checkStates()
					}
				},
				execute : function(a, b, d) {
					if (!this.busy) {
						this.busy = true;
						this.doc.execCommand(a, b, d);
						this.saveContent();
						return this.busy = false
					}
				},
				toggleView : function() {
					this.fireEvent("beforeToggleView", this);
					if (this.mode == "textarea") {
						this.mode = "iframe";
						this.iframe.setStyle("display", "");
						this.setContent(this.textarea.value);
						this.textarea.setStyle("display", "none")
					} else {
						this.saveContent();
						this.mode = "textarea";
						this.textarea.setStyle("display", "");
						this.iframe.setStyle("display", "none")
					}
					this.fireEvent("toggleView", this);
					this.focus.delay(10, this);
					return this
				},
				getContent : function() {
					var a = this.protectedElements;
					return this.cleanup(this.ensureRootElement(this.doc.body
							.get("html").replace(
									/<!-- mooeditable:protect:([0-9]+) --\>/g,
									function(b, d) {
										return a[d.toInt()]
									})))
				},
				setContent : function(a) {
					var b = this.protectedElements;
					a = a.replace(e, function(d) {
						b.push(d);
						return "<!-- mooeditable:protect:" + (b.length - 1)
								+ " --\>"
					});
					this.doc.body.set("html", this.ensureRootElement(a));
					return this
				},
				saveContent : function() {
					this.mode == "iframe"
							&& this.textarea.set("value", this.getContent());
					return this
				},
				ensureRootElement : function(a) {
					if (this.options.rootElement) {
						a = new Element("div", {
							html : a.trim()
						});
						for ( var b = -1, d = false, g = "", k = a.childNodes.length, j = 0; j < k; j++) {
							var l = a.childNodes[j], m = l.nodeName;
							if (!m.test(c) && m !== "#comment")
								if (m === "#text") {
									if (l.nodeValue.trim()) {
										if (b < 0)
											b = j;
										g += l.nodeValue
									}
								} else {
									if (b < 0)
										b = j;
									g += (new Element("div")).adopt(
											$(l).clone()).get("html")
								}
							else
								d = true;
							if (j == k - 1)
								d = true;
							if (b >= 0 && d) {
								d = new Element(this.options.rootElement, {
									html : g
								});
								a.replaceChild(d, a.childNodes[b]);
								for (b = b + 1; b < j; b++) {
									a.removeChild(a.childNodes[b]);
									k--;
									j--;
									b--
								}
								b = -1;
								d = false;
								g = ""
							}
						}
						a = a.get("html").replace(/\n\n/g, "")
					}
					return a
				},
				checkStates : function() {
					var a = this.selection.getNode();
					a
							&& typeOf(a) == "element"
							&& this.actions.each(function(b) {
								var d = this.toolbar.getItem(b);
								if (d) {
									d.deactivate();
									var g = MooEditable.Actions[b].states;
									if (g)
										if (typeOf(g) == "function")
											g.attempt( [ document.id(a), d ],
													this);
										else {
											try {
												if (this.doc
														.queryCommandState(b)) {
													d.activate();
													return
												}
											} catch (k) {
											}
											if (g.tags) {
												b = a;
												do {
													var j = b.tagName
															.toLowerCase();
													if (g.tags.contains(j)) {
														d.activate(j);
														break
													}
												} while ((b = Element
														.getParent(b)) != null)
											}
											if (g.css) {
												b = a;
												do {
													j = false;
													for ( var l in g.css) {
														var m = g.css[l];
														if (b.style[l
																.camelCase()]
																.contains(m)) {
															d.activate(m);
															j = true
														}
													}
													if (j || b.tagName.test(c))
														break
												} while ((b = Element
														.getParent(b)) != null)
											}
										}
								}
							}.bind(this))
				},
				cleanup : function(a) {
					if (!this.options.cleanup)
						return a.trim();
					do {
						var b = a;
						if (this.options.baseURL)
							a = a.replace('="' + this.options.baseURL, '="');
						a = a.replace(
								/<br class\="webkit-block-placeholder">/gi,
								"<br />");
						a = a
								.replace(
										/<span class="Apple-style-span">(.*)<\/span>/gi,
										"$1");
						a = a.replace(/ class="Apple-style-span"/gi, "");
						a = a.replace(/<span style="">/gi, "");
						a = a.replace(/<p>\s*<br ?\/?>\s*<\/p>/gi,
								"<p>\u00a0</p>");
						a = a
								.replace(/<p>(&nbsp;|\s)*<\/p>/gi,
										"<p>\u00a0</p>");
						this.options.semantics
								|| (a = a.replace(/\s*<br ?\/?>\s*<\/p>/gi,
										"</p>"));
						if (this.options.xhtml)
							a = a.replace(/<br>/gi, "<br />");
						if (this.options.semantics) {
							if (Browser.ie)
								a = a.replace(
										/<li>\s*<div>(.+?)<\/div><\/li>/g,
										"<li>$1</li>");
							if (Browser.safari || Browser.chrome) {
								a = a.replace(/^([\w\s]+.*?)<div>/i,
										"<p>$1</p><div>");
								a = a.replace(/<div>(.+?)<\/div>/ig,
										"<p>$1</p>")
							}
							if (!Browser.ie) {
								a = a
										.replace(
												/<p>[\s\n]*(<(?:ul|ol)>.*?<\/(?:ul|ol)>)(.*?)<\/p>/ig,
												"$1<p>$2</p>");
								a = a
										.replace(
												/<\/(ol|ul)>\s*(?!<(?:p|ol|ul|img).*?>)((?:<[^>]*>)?\w.*)$/g,
												"</$1><p>$2</p>")
							}
							a = a.replace(/<br[^>]*><\/p>/g, "</p>");
							a = a.replace(/<p>\s*(<img[^>]+>)\s*<\/p>/ig,
									"$1\n");
							a = a.replace(/<p([^>]*)>(.*?)<\/p>(?!\n)/g,
									"<p$1>$2</p>\n");
							a = a.replace(/<\/(ul|ol|p)>(?!\n)/g, "</$1>\n");
							a = a.replace(/><li>/g, ">\n\t<li>");
							a = a.replace(/([^\n])<\/(ol|ul)>/g, "$1\n</$2>");
							a = a.replace(/([^\n])<img/ig, "$1\n<img");
							a = a.replace(/^\s*$/g, "")
						}
						a = a.replace(/<br ?\/?>$/gi, "");
						a = a.replace(/^<br ?\/?>/gi, "");
						if (this.options.paragraphise)
							a = a
									.replace(
											/(h[1-6]|p|div|address|pre|li|ol|ul|blockquote|center|dl|dt|dd)><br ?\/?>/gi,
											"$1>");
						a = a.replace(
								/<br ?\/?>\s*<\/(h1|h2|h3|h4|h5|h6|li|p)/gi,
								"</$1");
						a = a
								.replace(
										/<span style="font-weight: bold;">(.*)<\/span>/gi,
										"<strong>$1</strong>");
						a = a
								.replace(
										/<span style="font-style: italic;">(.*)<\/span>/gi,
										"<em>$1</em>");
						a = a.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,
								"<strong>$1</strong>");
						a = a.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,
								"<em>$1</em>");
						a = a
								.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,
										'<span style="text-decoration: underline;">$1</span>');
						a = a
								.replace(
										/<strong><span style="font-weight: normal;">(.*)<\/span><\/strong>/gi,
										"$1");
						a = a
								.replace(
										/<em><span style="font-weight: normal;">(.*)<\/span><\/em>/gi,
										"$1");
						a = a
								.replace(
										/<span style="text-decoration: underline;"><span style="font-weight: normal;">(.*)<\/span><\/span>/gi,
										"$1");
						a = a
								.replace(
										/<strong style="font-weight: normal;">(.*)<\/strong>/gi,
										"$1");
						a = a
								.replace(
										/<em style="font-weight: normal;">(.*)<\/em>/gi,
										"$1");
						a = a.replace(/<[^> ]*/g, function(d) {
							return d.toLowerCase()
						});
						a = a.replace(/<[^>]*>/g, function(d) {
							return d = d.replace(/ [^=]+=/g, function(g) {
								return g.toLowerCase()
							})
						});
						a = a.replace(/<[^!][^>]*>/g, function(d) {
							return d = d.replace(/( [^=]+=)([^"][^ >]*)/g,
									'$1"$2"')
						});
						if (this.options.xhtml)
							a = a.replace(/<img([^>]+)(\s*[^\/])>(<\/img>)*/gi,
									"<img$1$2 />");
						a = a.replace(/<p>(?:\s*)<p>/g, "<p>");
						a = a.replace(/<\/p>\s*<\/p>/g, "</p>");
						a = a.replace(/<pre[^>]*>.*?<\/pre>/gi, function(d) {
							return d.replace(/<br ?\/?>/gi, "\n")
						});
						a = a.trim()
					} while (a != b);
					return a
				}
			});
	MooEditable.Selection = new Class(
			{
				initialize : function(a) {
					this.win = a
				},
				getSelection : function() {
					this.win.focus();
					return this.win.getSelection ? this.win.getSelection()
							: this.win.document.selection
				},
				getRange : function() {
					var a = this.getSelection();
					if (!a)
						return null;
					try {
						return a.rangeCount > 0 ? a.getRangeAt(0)
								: a.createRange ? a.createRange() : null
					} catch (b) {
						return this.doc.body.createTextRange()
					}
				},
				setRange : function(a) {
					if (a.select)
						Function.attempt(function() {
							a.select()
						});
					else {
						var b = this.getSelection();
						if (b.addRange) {
							b.removeAllRanges();
							b.addRange(a)
						}
					}
				},
				selectNode : function(a, b) {
					var d = this.getRange(), g = this.getSelection();
					if (d.moveToElementText)
						Function.attempt(function() {
							d.moveToElementText(a);
							d.select()
						});
					else if (g.addRange) {
						b ? d.selectNodeContents(a) : d.selectNode(a);
						g.removeAllRanges();
						g.addRange(d)
					} else
						g.setBaseAndExtent(a, 0, a, 1);
					return a
				},
				isCollapsed : function() {
					var a = this.getRange();
					if (a.item)
						return false;
					return a.boundingWidth == 0
							|| this.getSelection().isCollapsed
				},
				collapse : function(a) {
					var b = this.getRange(), d = this.getSelection();
					if (b.select) {
						b.collapse(a);
						b.select()
					} else
						a ? d.collapseToStart() : d.collapseToEnd()
				},
				getContent : function() {
					var a = this.getRange(), b = new Element("body");
					if (this.isCollapsed())
						return "";
					if (a.cloneContents)
						b.appendChild(a.cloneContents());
					else
						a.item != undefined || a.htmlText != undefined ? b.set(
								"html", a.item ? a.item(0).outerHTML
										: a.htmlText) : b.set("html", a
								.toString());
					return b.get("html")
				},
				getText : function() {
					var a = this.getRange(), b = this.getSelection();
					return this.isCollapsed() ? "" : a.text
							|| (b.toString ? b.toString() : "")
				},
				getNode : function() {
					var a = this.getRange();
					if (!Browser.ie || Browser.version >= 9) {
						var b = null;
						if (a) {
							b = a.commonAncestorContainer;
							if (!a.collapsed)
								if (a.startContainer == a.endContainer)
									if (a.startOffset - a.endOffset < 2)
										if (a.startContainer.hasChildNodes())
											b = a.startContainer.childNodes[a.startOffset];
							for (; typeOf(b) != "element";)
								b = b.parentNode
						}
						return document.id(b)
					}
					return document.id(a.item ? a.item(0) : a.parentElement())
				},
				insertContent : function(a) {
					if (Browser.ie) {
						var b = this.getRange();
						if (b.pasteHTML) {
							b.pasteHTML(a);
							b.collapse(false);
							b.select()
						} else if (b.insertNode) {
							b.deleteContents();
							if (b.createContextualFragment)
								b.insertNode(b.createContextualFragment(a));
							else {
								var d = this.win.document, g = d
										.createDocumentFragment();
								d = d.createElement("div");
								g.appendChild(d);
								d.outerHTML = a;
								b.insertNode(g)
							}
						}
					} else
						this.win.document.execCommand("insertHTML", false, a)
				}
			});
	var h = {};
	MooEditable.Locale = {
		define : function(a, b) {
			if (typeOf(window.Locale) != "null")
				return Locale.define("en-US", "MooEditable", a, b);
			if (typeOf(a) == "object")
				Object.merge(h, a);
			else
				h[a] = b
		},
		get : function(a) {
			if (typeOf(window.Locale) != "null")
				return Locale.get("MooEditable." + a);
			return a ? h[a] : ""
		}
	};
	MooEditable.Locale.define( {
		ok : "OK",
		cancel : "Cancel",
		bold : "Bold",
		italic : "Italic",
		underline : "Underline",
		strikethrough : "Strikethrough",
		unorderedList : "Unordered List",
		orderedList : "Ordered List",
		indent : "Indent",
		outdent : "Outdent",
		undo : "Undo",
		redo : "Redo",
		removeHyperlink : "Remove Hyperlink",
		addHyperlink : "Add Hyperlink",
		removeMailto : "Remove Email",
		addMailto : "Add Email",
		selectTextHyperlink : "Please select the text you wish to hyperlink.",
		selectTextMailto : "Please select the text you wish to link an email address to.",
		enterURL : "Enter URL",
		enterAddress : "Enter Email Address",
		enterImageURL : "Enter image URL",
		addImage : "Add Image",
		toggleView : "Toggle View"
	});
	MooEditable.UI = {};
	MooEditable.UI.Toolbar = new Class( {
		Implements : [ Events, Options ],
		options : {
			"class" : ""
		},
		initialize : function(a) {
			this.setOptions(a);
			this.el = new Element("div", {
				"class" : "mooeditable-ui-toolbar " + this.options["class"]
			});
			this.items = {};
			this.content = null
		},
		toElement : function() {
			return this.el
		},
		render : function(a) {
			if (this.content)
				this.el.adopt(this.content);
			else
				this.content = a.map(function(b) {
					return b == "|" ? this.addSeparator() : this.addItem(b)
				}.bind(this));
			return this
		},
		addItem : function(a) {
			var b = MooEditable.Actions[a];
			if (b) {
				var d = b.options || {};
				b = new (MooEditable.UI[(b.type || "button").camelCase()
						.capitalize()])(Object.append(d, {
					name : a,
					"class" : a + "-item toolbar-item",
					title : b.title,
					onAction : this.itemAction.bind(this)
				}));
				this.items[a] = b;
				document.id(b).inject(this.el);
				return b
			}
		},
		getItem : function(a) {
			return this.items[a]
		},
		addSeparator : function() {
			return (new Element("span", {
				"class" : "toolbar-separator"
			})).inject(this.el)
		},
		itemAction : function() {
			this.fireEvent("itemAction", arguments)
		},
		disable : function(a) {
			Object.each(this.items, function(b) {
				b.name == a ? b.activate() : b.deactivate().disable()
			});
			return this
		},
		enable : function() {
			Object.each(this.items, function(a) {
				a.enable()
			});
			return this
		},
		show : function() {
			this.el.setStyle("display", "");
			return this
		},
		hide : function() {
			this.el.setStyle("display", "none");
			return this
		}
	});
	MooEditable.UI.Button = new Class(
			{
				Implements : [ Events, Options ],
				options : {
					title : "",
					name : "",
					text : "Button",
					"class" : "",
					shortcut : "",
					mode : "icon"
				},
				initialize : function(a) {
					this.setOptions(a);
					this.name = this.options.name;
					this.render()
				},
				toElement : function() {
					return this.el
				},
				render : function() {
					var a = Browser.Platform.mac ? "Cmd" : "Ctrl";
					a = this.options.shortcut ? " ( " + a + "+"
							+ this.options.shortcut.toUpperCase() + " )" : "";
					var b = this.options.title || name;
					this.el = new Element(
							"button",
							{
								"class" : "mooeditable-ui-button "
										+ this.options["class"],
								title : b + a,
								html : '<span class="button-icon"></span><span class="button-text">'
										+ b + "</span>",
								events : {
									click : this.click.bind(this),
									mousedown : function(d) {
										d.preventDefault()
									}
								}
							});
					this.options.mode != "icon"
							&& this.el.addClass("mooeditable-ui-button-"
									+ this.options.mode);
					this.disabled = this.active = false;
					Browser.ie && this.el.addEvents( {
						mouseenter : function() {
							this.addClass("hover")
						},
						mouseleave : function() {
							this.removeClass("hover")
						}
					});
					return this
				},
				click : function(a) {
					a.preventDefault();
					this.disabled || this.action(a)
				},
				action : function() {
					this.fireEvent("action", [ this ].concat(Array
							.from(arguments)))
				},
				enable : function() {
					this.active && this.el.removeClass("onActive");
					if (this.disabled) {
						this.disabled = false;
						this.el.removeClass("disabled").set( {
							disabled : false,
							opacity : 1
						});
						return this
					}
				},
				disable : function() {
					if (!this.disabled) {
						this.disabled = true;
						this.el.addClass("disabled").set( {
							disabled : true,
							opacity : 0.4
						});
						return this
					}
				},
				activate : function() {
					if (!this.disabled) {
						this.active = true;
						this.el.addClass("onActive");
						return this
					}
				},
				deactivate : function() {
					this.active = false;
					this.el.removeClass("onActive");
					return this
				}
			});
	MooEditable.UI.Dialog = new Class( {
		Implements : [ Events, Options ],
		options : {
			"class" : "",
			contentClass : ""
		},
		initialize : function(a, b) {
			this.setOptions(b);
			this.html = a;
			this.el = new Element("div", {
				"class" : "mooeditable-ui-dialog " + this.options["class"],
				html : '<div class="dialog-content '
						+ this.options.contentClass + '">' + a + "</div>",
				styles : {
					display : "none"
				},
				events : {
					click : this.click.bind(this)
				}
			})
		},
		toElement : function() {
			return this.el
		},
		click : function() {
			this.fireEvent("click", arguments);
			return this
		},
		open : function() {
			this.el.setStyle("display", "");
			this.fireEvent("open", this);
			return this
		},
		close : function() {
			this.el.setStyle("display", "none");
			this.fireEvent("close", this);
			return this
		}
	});
	MooEditable.UI.AlertDialog = function(a) {
		if (a) {
			a = a + ' <button class="dialog-ok-button">'
					+ MooEditable.Locale.get("ok") + "</button>";
			return new MooEditable.UI.Dialog(a, {
				"class" : "mooeditable-alert-dialog",
				onOpen : function() {
					var b = this.el.getElement(".dialog-ok-button");
					(function() {
						b.focus()
					}).delay(10)
				},
				onClick : function(b) {
					b.preventDefault();
					b.target.tagName.toLowerCase() == "button"
							&& document.id(b.target).hasClass(
									"dialog-ok-button") && this.close()
				}
			})
		}
	};
	MooEditable.UI.PromptDialog = function(a, b, d) {
		if (a) {
			a = '<label class="dialog-label">'
					+ a
					+ ' <input type="text" class="text dialog-input" value="'
					+ b
					+ '"></label> <button class="dialog-button dialog-ok-button">'
					+ MooEditable.Locale.get("ok")
					+ '</button><button class="dialog-button dialog-cancel-button">'
					+ MooEditable.Locale.get("cancel") + "</button>";
			return new MooEditable.UI.Dialog(a, {
				"class" : "mooeditable-prompt-dialog",
				onOpen : function() {
					var g = this.el.getElement(".dialog-input");
					(function() {
						g.focus();
						g.select()
					}).delay(10)
				},
				onClick : function(g) {
					g.preventDefault();
					if (g.target.tagName.toLowerCase() == "button") {
						var k = document.id(g.target);
						g = this.el.getElement(".dialog-input");
						if (k.hasClass("dialog-cancel-button")) {
							g.set("value", b);
							this.close()
						} else if (k.hasClass("dialog-ok-button")) {
							k = g.get("value");
							g.set("value", b);
							this.close();
							d && d.attempt(k, this)
						}
					}
				}
			})
		}
	};
	MooEditable.Actions = {
		bold : {
			title : MooEditable.Locale.get("bold"),
			options : {
				shortcut : "b"
			},
			states : {
				tags : [ "b", "strong" ],
				css : {
					"font-weight" : "bold"
				}
			},
			events : {
				beforeToggleView : function() {
					if (Browser.firefox) {
						var a = this.textarea.get("value"), b = a.replace(
								/<strong([^>]*)>/gi, "<b$1>").replace(
								/<\/strong>/gi, "</b>");
						a != b && this.textarea.set("value", b)
					}
				},
				attach : function() {
					if (Browser.firefox) {
						var a = this.textarea.get("value"), b = a.replace(
								/<strong([^>]*)>/gi, "<b$1>").replace(
								/<\/strong>/gi, "</b>");
						if (a != b) {
							this.textarea.set("value", b);
							this.setContent(b)
						}
					}
				}
			}
		},
		italic : {
			title : MooEditable.Locale.get("italic"),
			options : {
				shortcut : "i"
			},
			states : {
				tags : [ "i", "em" ],
				css : {
					"font-style" : "italic"
				}
			},
			events : {
				beforeToggleView : function() {
					if (Browser.firefox) {
						var a = this.textarea.get("value"), b = a.replace(
								/<embed([^>]*)>/gi, "<tmpembed$1>").replace(
								/<em([^>]*)>/gi, "<i$1>").replace(
								/<tmpembed([^>]*)>/gi, "<embed$1>").replace(
								/<\/em>/gi, "</i>");
						a != b && this.textarea.set("value", b)
					}
				},
				attach : function() {
					if (Browser.firefox) {
						var a = this.textarea.get("value"), b = a.replace(
								/<embed([^>]*)>/gi, "<tmpembed$1>").replace(
								/<em([^>]*)>/gi, "<i$1>").replace(
								/<tmpembed([^>]*)>/gi, "<embed$1>").replace(
								/<\/em>/gi, "</i>");
						if (a != b) {
							this.textarea.set("value", b);
							this.setContent(b)
						}
					}
				}
			}
		},
		underline : {
			title : MooEditable.Locale.get("underline"),
			options : {
				shortcut : "u"
			},
			states : {
				tags : [ "u" ],
				css : {
					"text-decoration" : "underline"
				}
			}
		},
		strikethrough : {
			title : MooEditable.Locale.get("strikethrough"),
			options : {
				shortcut : "s"
			},
			states : {
				tags : [ "s", "strike" ],
				css : {
					"text-decoration" : "line-through"
				}
			}
		},
		insertunorderedlist : {
			title : MooEditable.Locale.get("unorderedList"),
			states : {
				tags : [ "ul" ]
			}
		},
		insertorderedlist : {
			title : MooEditable.Locale.get("orderedList"),
			states : {
				tags : [ "ol" ]
			}
		},
		indent : {
			title : MooEditable.Locale.get("indent"),
			states : {
				tags : [ "blockquote" ]
			}
		},
		outdent : {
			title : MooEditable.Locale.get("outdent")
		},
		undo : {
			title : MooEditable.Locale.get("undo"),
			options : {
				shortcut : "z"
			}
		},
		redo : {
			title : MooEditable.Locale.get("redo"),
			options : {
				shortcut : "y"
			}
		},
		unlink : {
			title : MooEditable.Locale.get("removeHyperlink")
		},
		createlink : {
			title : MooEditable.Locale.get("addHyperlink"),
			options : {
				shortcut : "l"
			},
			states : {
				tags : [ "a" ]
			},
			dialogs : {
				alert : MooEditable.UI.AlertDialog.pass(MooEditable.Locale
						.get("selectTextHyperlink")),
				prompt : function(a) {
					return MooEditable.UI.PromptDialog(MooEditable.Locale
							.get("enterURL"), "http://", function(b) {
						a.execute("createlink", false, b.trim())
					})
				}
			},
			command : function() {
				var a = this.selection, b = this.dialogs.createlink;
				if (a.isCollapsed()) {
					var d = a.getNode();
					if (d.get("tag") == "a" && d.get("href")) {
						a.selectNode(d);
						b = b.prompt;
						b.el.getElement(".dialog-input").set("value",
								d.get("href"));
						b.open()
					} else
						b.alert.open()
				} else {
					d = a.getText();
					b = b.prompt;
					f.test(d)
							&& b.el.getElement(".dialog-input").set("value", d);
					b.open()
				}
			}
		},
		removemailto : {
			title : MooEditable.Locale.get("removeMailto")
		},
		createmailto : {
			title : MooEditable.Locale.get("addMailto"),
			options : {
				shortcut : "m"
			},
			states : {
				tags : [ "a" ]
			},
			dialogs : {
				alert : MooEditable.UI.AlertDialog.pass(MooEditable.Locale
						.get("selectTextMailto")),
				prompt : function(a) {
					return MooEditable.UI.PromptDialog(MooEditable.Locale
						.get("enterAddress"), "mailto:", function(b) {
					a.execute("createlink", false, b.trim())
					})
				}
			},
			command : function() {
				var a = this.selection, b = this.dialogs.createmailto;
				if (a.isCollapsed()) {
					var d = a.getNode();
					if (d.get("tag") == "a" && d.get("href")) {
						a.selectNode(d);
						b = b.prompt;
						b.el.getElement(".dialog-input").set("value",
								d.get("href"));
						b.open()
					} else
						b.alert.open()
				} else {
					d = a.getText();
					b = b.prompt;
					f.test(d)
					&& b.el.getElement(".dialog-input").set("value", d);
					b.open()
				}
			}
		},
		urlimage : {
			title : MooEditable.Locale.get("addImage"),
			options : {
				shortcut : "m"
			},
			dialogs : {
				prompt : function(a) {
					return MooEditable.UI.PromptDialog(MooEditable.Locale
							.get("enterImageURL"), "http://", function(b) {
						a.execute("insertimage", false, b.trim())
					})
				}
			},
			command : function() {
				this.dialogs.urlimage.prompt.open()
			}
		},
		toggleview : {
			title : MooEditable.Locale.get("toggleView"),
			command : function() {
				this.mode == "textarea" ? this.toolbar.enable() : this.toolbar
						.disable("toggleview");
				this.toggleView()
			}
		}
	};
	MooEditable.Actions.Settings = {};
	Element.Properties.mooeditable = {
		get : function() {
			return this.retrieve("MooEditable")
		}
	};
	Element.implement( {
		mooEditable : function(a) {
			var b = this.get("mooeditable");
			b || (b = new MooEditable(this, a));
			return b
		}
	})
})();
MooEditable.UI.MenuList = new Class( {
	Implements : [ Events, Options ],
	options : {
		title : "",
		name : "",
		"class" : "",
		list : []
	},
	initialize : function(c) {
		this.setOptions(c);
		this.name = this.options.name;
		this.render()
	},
	toElement : function() {
		return this.el
	},
	render : function() {
		var c = "";
		this.options.list.each(function(f) {
			c += '<option value="{value}" style="{style}">{text}</option>'
					.substitute(f)
		});
		this.el = new Element("select", {
			"class" : this.options["class"],
			title : this.options.title,
			html : c,
			styles : {
				height : "21px"
			},
			events : {
				change : this.change.bind(this)
			}
		});
		this.disabled = false;
		Browser.ie && this.el.addEvents( {
			mouseenter : function() {
				this.addClass("hover")
			},
			mouseleave : function() {
				this.removeClass("hover")
			}
		});
		return this
	},
	change : function(c) {
		c.preventDefault();
		this.disabled || this.action(c.target.value)
	},
	action : function() {
		this.fireEvent("action", [ this ].concat(Array.from(arguments)))
	},
	enable : function() {
		if (this.disabled) {
			this.disabled = false;
			this.el.set("disabled", false).removeClass("disabled").set( {
				disabled : false,
				opacity : 1
			});
			return this
		}
	},
	disable : function() {
		if (!this.disabled) {
			this.disabled = true;
			this.el.set("disabled", true).addClass("disabled").set( {
				disabled : true,
				opacity : 0.4
			});
			return this
		}
	},
	activate : function(c) {
		if (!this.disabled) {
			var f = 0;
			c && this.options.list.each(function(e, h) {
				if (e.value == c)
					f = h
			});
			this.el.selectedIndex = f;
			return this
		}
	},
	deactivate : function() {
		this.el.selectedIndex = 0;
		this.el.removeClass("onActive");
		return this
	}
});
MooEditable.UI.ButtonOverlay = new Class(
		{
			Extends : MooEditable.UI.Button,
			options : {
				overlayHTML : "",
				overlayClass : "",
				overlaySize : {
					x : 150,
					y : "auto"
				},
				overlayContentClass : ""
			},
			initialize : function(c) {
				this.parent(c);
				this.render();
				this.el.addClass("mooeditable-ui-buttonOverlay");
				this.renderOverlay(this.options.overlayHTML)
			},
			renderOverlay : function(c) {
				var f = this;
				this.overlay = (new Element("div", {
					"class" : "mooeditable-ui-button-overlay " + f.name
							+ "-overlay " + f.options.overlayClass,
					html : '<div class="overlay-content '
							+ f.options.overlayContentClass + '">' + c
							+ "</div>",
					tabindex : 0,
					styles : {
						left : "-999em",
						position : "absolute",
						width : f.options.overlaySize.x,
						height : f.options.overlaySize.y
					},
					events : {
						mousedown : f.clickOverlay.bind(f),
						focus : f.openOverlay.bind(f),
						blur : f.closeOverlay.bind(f)
					}
				})).inject(document.body).store("MooEditable.UI.ButtonOverlay",
						this);
				this.overlayVisible = false;
				window.addEvent("resize", function() {
					f.overlayVisible && f.positionOverlay()
				})
			},
			openOverlay : function() {
				if (!this.overlayVisible) {
					this.overlayVisible = true;
					this.activate();
					this.fireEvent("openOverlay", this);
					return this
				}
			},
			closeOverlay : function() {
				if (this.overlayVisible) {
					this.overlay.setStyle("left", "-999em");
					this.overlayVisible = false;
					this.deactivate();
					this.fireEvent("closeOverlay", this);
					return this
				}
			},
			clickOverlay : function(c) {
				if (!(c.target == this.overlay || c.target.parentNode == this.overlay)) {
					this.overlay.blur();
					c.preventDefault();
					this.action(c)
				}
			},
			click : function(c) {
				c.preventDefault();
				if (!this.disabled)
					if (this.overlayVisible)
						this.overlay.blur();
					else {
						this.positionOverlay();
						this.overlay.focus()
					}
			},
			positionOverlay : function() {
				var c = this.el.getCoordinates();
				this.overlay.setStyles( {
					top : c.bottom,
					left : c.left
				});
				return this
			}
		});
MooEditable.Locale.define( {
	blockFormatting : "Block Formatting",
	paragraph : "Paragraph",
	heading1 : "Heading 1",
	heading2 : "Heading 2",
	heading3 : "Heading 3",
	alignLeft : "Align Left",
	alignRight : "Align Right",
	alignCenter : "Align Center",
	alignJustify : "Align Justify",
	removeFormatting : "Remove Formatting",
	insertHorizontalRule : "Insert Horizontal Rule"
});
Object.append(MooEditable.Actions, {
	formatBlock : {
		title : MooEditable.Locale.get("blockFormatting"),
		type : "menu-list",
		options : {
			list : [ {
				text : MooEditable.Locale.get("paragraph"),
				value : "p"
			}, {
				text : MooEditable.Locale.get("heading1"),
				value : "h1",
				style : "font-size:24px; font-weight:bold;"
			}, {
				text : MooEditable.Locale.get("heading2"),
				value : "h2",
				style : "font-size:18px; font-weight:bold;"
			}, {
				text : MooEditable.Locale.get("heading3"),
				value : "h3",
				style : "font-size:14px; font-weight:bold;"
			} ]
		},
		states : {
			tags : [ "p", "h1", "h2", "h3" ]
		},
		command : function(c, f) {
			var e = "<" + f + ">";
			this.focus();
			this.execute("formatBlock", false, e)
		}
	},
	justifyleft : {
		title : MooEditable.Locale.get("alignLeft"),
		states : {
			css : {
				"text-align" : "left"
			}
		}
	},
	justifyright : {
		title : MooEditable.Locale.get("alignRight"),
		states : {
			css : {
				"text-align" : "right"
			}
		}
	},
	justifycenter : {
		title : MooEditable.Locale.get("alignCenter"),
		states : {
			tags : [ "center" ],
			css : {
				"text-align" : "center"
			}
		}
	},
	justifyfull : {
		title : MooEditable.Locale.get("alignJustify"),
		states : {
			css : {
				"text-align" : "justify"
			}
		}
	},
	removeformat : {
		title : MooEditable.Locale.get("removeFormatting")
	},
	insertHorizontalRule : {
		title : MooEditable.Locale.get("insertHorizontalRule"),
		states : {
			tags : [ "hr" ]
		},
		command : function() {
			this.selection.insertContent("<hr>")
		}
	}
});
MooEditable.Group = new Class(
		{
			Implements : [ Options ],
			options : {
				actions : "bold italic underline strikethrough | insertunorderedlist insertorderedlist indent outdent | undo redo | createlink unlink | createmailto removemailto | urlimage | toggleview"
			},
			initialize : function(c, f) {
				this.setOptions(f);
				this.actions = this.options.actions.clean().split(" ");
				var e = this;
				this.toolbar = (new MooEditable.UI.Toolbar( {
					onItemAction : function() {
						var h = Array.from(arguments), a = h[0];
						if (e.activeEditor) {
							e.activeEditor.focus();
							e.activeEditor.action(a.name, h);
							e.activeEditor.mode == "iframe"
									&& e.activeEditor.checkStates()
						}
					}
				})).render(this.actions);
				document.id(c).adopt(this.toolbar)
			},
			add : function(c, f) {
				return this.activeEditor = new MooEditable.Group.Item(c, this,
						Object.merge( {
							toolbar : false
						}, this.options, f))
			}
		});
MooEditable.Group.Item = new Class( {
	Extends : MooEditable,
	initialize : function(c, f, e) {
		var h = this;
		this.group = f;
		this.parent(c, e);
		this.addEvent("attach", function() {
			var a = function() {
				if (this == h.win)
					h.group.activeEditor = h
			};
			h.textarea.addEvent("focus", a);
			h.win.addEvent("focus", a)
		})
	}
});
MooEditable.Actions.Settings.forecolor = {
	colors : [
			[ "000000", "993300", "333300", "003300", "003366", "000077",
					"333399", "333333" ],
			[ "770000", "ff6600", "777700", "007700", "007777", "0000ff",
					"666699", "777777" ],
			[ "ff0000", "ff9900", "99cc00", "339966", "33cccc", "3366f0",
					"770077", "999999" ],
			[ "ff00ff", "ffcc00", "ffff00", "00ff00", "00ffff", "00ccff",
					"993366", "cccccc" ],
			[ "ff99cc", "ffcc99", "ffff99", "ccffcc", "ccffff", "99ccff",
					"cc9977", "ffffff" ] ]
};
MooEditable.Locale.define("changeColor", "Change Color");
MooEditable.Actions.forecolor = {
	type : "button-overlay",
	title : MooEditable.Locale.get("changeColor"),
	options : {
		overlaySize : {
			x : "auto"
		},
		overlayHTML : function() {
			var c = "";
			MooEditable.Actions.Settings.forecolor.colors
					.each(function(f) {
						f
								.each(function(e) {
									c += '<a href="#" class="forecolor-colorpicker-color" style="background-color: #'
											+ e
											+ '" title="#'
											+ e.toUpperCase() + '"></a>'
								});
						c += '<span class="forecolor-colorpicker-br"></span>'
					});
			return c
		}()
	},
	command : function(c, f) {
		var e = f.target;
		if (e.tagName.toLowerCase() == "a") {
			this.execute("forecolor", false, $(e).getStyle("background-color"));
			this.focus()
		}
	}
};
MooEditable.Actions.Settings.smiley = {
	imagesPath : "../../Assets/MooEditable/Smiley/",
	smileys : [ "angryface", "blush", "gasp", "grin", "halo", "lipsaresealed",
			"smile", "undecided", "wink" ],
	fileExt : ".png"
};
MooEditable.Locale.define("insertSmiley", "Insert Smiley");
MooEditable.Actions.smiley = {
	type : "button-overlay",
	title : MooEditable.Locale.get("insertSmiley"),
	options : {
		overlaySize : {
			x : "auto"
		},
		overlayHTML : function() {
			var c = MooEditable.Actions.Settings.smiley, f = "";
			c.smileys.each(function(e) {
				f += '<img src="' + c.imagesPath + e + c.fileExt
						+ '" alt="" class="smiley-image">'
			});
			return f
		}()
	},
	command : function(c, f) {
		var e = f.target;
		if (e.tagName.toLowerCase() == "img") {
			e = '<img style="border:0;" class="smiley" src="' + $(e).get("src") + '" alt="">';
			this.focus();
			this.selection.insertContent(e)
		}
	},
	events : {
		attach : function(c) {
			Browser.ie && c.doc.addListener("controlselect", function(f) {
				var e = f.target || f.srcElement;
				if (e.tagName.toLowerCase() == "img")
					if (document.id(e).hasClass("smiley"))
						if (f.preventDefault)
							f.preventDefault();
						else
							f.returnValue = false
			})
		},
		editorMouseDown : function(c, f) {
			var e = c.target, h = e.tagName.toLowerCase() == "img"
					&& $(e).hasClass("smiley");
			Function.attempt(function() {
				f.doc.execCommand("enableObjectResizing", false, !h)
			})
		}
	}
};
MooEditable.Locale.define( {
	tableColumns : "columns",
	tableRows : "rows",
	tableWidth : "width",
	tableClass : "class",
	tableType : "type",
	tableHeader : "Header",
	tableCell : "Cell",
	tableAlign : "align",
	tableAlignNone : "none",
	tableAlignCenter : "center",
	tableAlignRight : "right",
	tableValign : "vertical align",
	tableValignNone : "none",
	tableValignTop : "top",
	tableValignMiddle : "middle",
	tableValignBottom : "bottom",
	addTable : "Add Table",
	editTable : "Edit Table",
	addTableRow : "Add Table Row",
	editTableRow : "Edit Table Row",
	mergeTableRow : "Merge Table Row",
	splitTableRow : "Split Table Row",
	deleteTableRow : "Delete Table Row",
	addTableCol : "Add Table Column",
	editTableCol : "Edit Table Column",
	mergeTableCell : "Merge Table Cell",
	splitTableCell : "Split Table Cell",
	deleteTableCol : "Delete Table Column"
});
MooEditable.UI.TableDialog = function(c, f) {
	var e = {
		tableadd : MooEditable.Locale.get("tableColumns")
				+ ' <input type="text" class="table-c" value="" size="4"> '
				+ MooEditable.Locale.get("tableRows")
				+ ' <input type="text" class="table-r" value="" size="4"> ',
		tableedit : MooEditable.Locale.get("tableWidth")
				+ ' <input type="text" class="table-w" value="" size="4"> '
				+ MooEditable.Locale.get("tableClass")
				+ ' <input type="text" class="table-c" value="" size="15"> ',
		tablerowedit : MooEditable.Locale.get("tableClass")
				+ ' <input type="text" class="table-c" value="" size="15"> '
				+ MooEditable.Locale.get("tableType")
				+ ' <select class="table-c-type"><option value="th">'
				+ MooEditable.Locale.get("tableHeader")
				+ '</option><option value="td">'
				+ MooEditable.Locale.get("tableCell") + "</option></select> ",
		tablecoledit : MooEditable.Locale.get("tableWidth")
				+ ' <input type="text" class="table-w" value="" size="4"> '
				+ MooEditable.Locale.get("tableClass")
				+ ' <input type="text" class="table-c" value="" size="15"> '
				+ MooEditable.Locale.get("tableAlign")
				+ ' <select class="table-a"><option>'
				+ MooEditable.Locale.get("tableAlignNone")
				+ "</option><option>"
				+ MooEditable.Locale.get("tableAlignLeft")
				+ "</option><option>"
				+ MooEditable.Locale.get("tableAlignCenter")
				+ "</option><option>"
				+ MooEditable.Locale.get("tableAlignRight")
				+ "</option></select> " + MooEditable.Locale.get("tableValign")
				+ ' <select class="table-va"><option>'
				+ MooEditable.Locale.get("tableValignNone")
				+ "</option><option>"
				+ MooEditable.Locale.get("tableValignTop")
				+ "</option><option>"
				+ MooEditable.Locale.get("tableValignMiddle")
				+ "</option><option>"
				+ MooEditable.Locale.get("tableValignBottom")
				+ "</option></select> "
	};
	e[f] += '<button class="dialog-button dialog-ok-button">'
			+ MooEditable.Locale.get("ok")
			+ '</button><button class="dialog-button dialog-cancel-button">'
			+ MooEditable.Locale.get("cancel") + "</button>";
	var h = {
		tableadd : {
			click : function() {
				var a = this.el.getElement(".table-c").value.toInt(), b = this.el
						.getElement(".table-r").value.toInt();
				if (b > 0 && a > 0) {
					var d, g, k = [];
					d = new Element("tdiv");
					g = (new Element("table")).set("border", 0).set("width",
							"100%").inject(d);
					g = (new Element("tbody")).inject(g);
					for ( var j = 0; j < b; j++) {
						k[j] = (new Element("tr")).inject(g, "bottom");
						for ( var l = 0; l < a; l++)
							(new Element("td")).set("html", "&nbsp;").inject(
									k[j], "bottom")
					}
					c.selection.insertContent(d.get("html"))
				}
			}
		},
		tableedit : {
			load : function() {
				var a = c.selection.getNode().getParent("table");
				this.el.getElement(".table-w").set("value", a.get("width"));
				this.el.getElement(".table-c").set("value", a.className)
			},
			click : function() {
				var a = c.selection.getNode().getParent("table");
				a.set("width", this.el.getElement(".table-w").value);
				a.className = this.el.getElement(".table-c").value
			}
		},
		tablerowedit : {
			load : function() {
				var a = c.selection.getNode().getParent("tr");
				this.el.getElement(".table-c").set("value", a.className);
				this.el.getElement(".table-c-type").set("value",
						c.selection.getNode().get("tag"))
			},
			click : function() {
				var a = c.selection.getNode().getParent("tr");
				a.className = this.el.getElement(".table-c").value;
				a.getElements("td, th").each(
						function(b) {
							if (this.el.getElement(".table-c-type") != b
									.get("tag")) {
								var d = c.doc.createElement(this.el.getElement(
										".table-c-type").get("value"));
								$(d).set("html", b.get("html")).replaces(b)
							}
						}, this)
			}
		},
		tablecoledit : {
			load : function() {
				var a = c.selection.getNode();
				if (a.get("tag") != "td")
					a = a.getParent("td");
				this.el.getElement(".table-w").set("value", a.get("width"));
				this.el.getElement(".table-c").set("value", a.className);
				this.el.getElement(".table-a").set("value", a.get("align"));
				this.el.getElement(".table-va").set("value", a.get("valign"))
			},
			click : function() {
				var a = c.selection.getNode();
				if (a.get("tag") != "td")
					a = a.getParent("td");
				a.set("width", this.el.getElement(".table-w").value);
				a.className = this.el.getElement(".table-c").value;
				a.set("align", this.el.getElement(".table-a").value);
				a.set("valign", this.el.getElement(".table-va").value)
			}
		}
	};
	return new MooEditable.UI.Dialog(e[f], {
		"class" : "mooeditable-table-dialog",
		onOpen : function() {
			h[f].load && h[f].load.apply(this);
			var a = this.el.getElement("input");
			(function() {
				a.focus()
			}).delay(10)
		},
		onClick : function(a) {
			a.target.tagName.toLowerCase() == "button" && a.preventDefault();
			a = document.id(a.target);
			if (a.hasClass("dialog-cancel-button"))
				this.close();
			else if (a.hasClass("dialog-ok-button")) {
				this.close();
				h[f].click.apply(this)
			}
		}
	})
};
Object
		.append(
				MooEditable.Actions,
				{
					tableadd : {
						title : MooEditable.Locale.get("addTable"),
						dialogs : {
							prompt : function(c) {
								return MooEditable.UI
										.TableDialog(c, "tableadd")
							}
						},
						command : function() {
							this.dialogs.tableadd.prompt.open()
						}
					},
					tableedit : {
						title : MooEditable.Locale.get("editTable"),
						dialogs : {
							prompt : function(c) {
								return MooEditable.UI.TableDialog(c,
										"tableedit")
							}
						},
						command : function() {
							this.selection.getNode().getParent("table")
									&& this.dialogs.tableedit.prompt.open()
						}
					},
					tablerowadd : {
						title : "Add Row",
						command : function() {
							var c = this.selection.getNode().getParent("tr");
							c && c.clone().inject(c, "after")
						}
					},
					tablerowedit : {
						title : MooEditable.Locale.get("editTableRow"),
						dialogs : {
							prompt : function(c) {
								return MooEditable.UI.TableDialog(c,
										"tablerowedit")
							}
						},
						command : function() {
							this.selection.getNode().getParent("table")
									&& this.dialogs.tablerowedit.prompt.open()
						}
					},
					tablerowspan : {
						title : MooEditable.Locale.get("mergeTableRow"),
						command : function() {
							var c = this.selection.getNode();
							if (c.get("tag") != "td")
								c = c.getParent("td");
							if (c) {
								var f = c.cellIndex, e = c.getParent().rowIndex;
								if (c.getParent().getParent().childNodes[e
										+ c.rowSpan]) {
									c.getParent().getParent().childNodes[e
											+ c.rowSpan].deleteCell(f);
									c.rowSpan++
								}
							}
						}
					},
					tablerowsplit : {
						title : MooEditable.Locale.get("splitTableRow"),
						command : function() {
							var c = this.selection.getNode();
							if (c.get("tag") != "td")
								c = c.getParent("td");
							if (c) {
								var f = c.cellIndex, e = c.getParent().rowIndex;
								if (c.getProperty("rowspan")) {
									var h = parseInt(c.getProperty("rowspan"));
									for (i = 1; i < h; i++)
										c.getParent().getParent().childNodes[e
												+ i].insertCell(f);
									c.removeProperty("rowspan")
								}
							}
						},
						states : function(c) {
							c.get("tag") == "td" && c
									&& c.getProperty("rowspan")
									&& parseInt(c.getProperty("rowspan")) > 1
									&& this.el.addClass("onActive")
						}
					},
					tablerowdelete : {
						title : MooEditable.Locale.get("deleteTableRow"),
						command : function() {
							var c = this.selection.getNode().getParent("tr");
							c && c.getParent().deleteRow(c.rowIndex)
						}
					},
					tablecoladd : {
						title : MooEditable.Locale.get("addTableCol"),
						command : function() {
							var c = this.selection.getNode();
							if (c.get("tag") != "td")
								c = c.getParent("td");
							if (c)
								for ( var f = c.cellIndex, e = c.getParent()
										.getParent().childNodes.length, h = 0; h < e; h++) {
									var a = $(c.getParent().getParent().childNodes[h].childNodes[f]);
									a.clone().inject(a, "after")
								}
						}
					},
					tablecoledit : {
						title : MooEditable.Locale.get("editTableCol"),
						dialogs : {
							prompt : function(c) {
								return MooEditable.UI.TableDialog(c,
										"tablecoledit")
							}
						},
						command : function() {
							this.selection.getNode().getParent("table")
									&& this.dialogs.tablecoledit.prompt.open()
						}
					},
					tablecolspan : {
						title : MooEditable.Locale.get("mergeTableCell"),
						command : function() {
							var c = this.selection.getNode();
							if (c.get("tag") != "td")
								c = c.getParent("td");
							if (c) {
								var f = c.cellIndex + 1;
								if (c.getParent().childNodes[f]) {
									c.getParent().deleteCell(f);
									c.colSpan++
								}
							}
						}
					},
					tablecolsplit : {
						title : MooEditable.Locale.get("splitTableCell"),
						command : function() {
							var c = this.selection.getNode();
							if (c.get("tag") != "td")
								c = c.getParent("td");
							if (c) {
								var f = c.cellIndex + 1;
								if (c.getProperty("colspan")) {
									var e = parseInt(c.getProperty("colspan"));
									for (i = 1; i < e; i++)
										c.getParent().insertCell(f + i);
									c.removeProperty("colspan")
								}
							}
						},
						states : function(c) {
							c.get("tag") == "td" && c
									&& c.getProperty("colspan")
									&& parseInt(c.getProperty("colspan")) > 1
									&& this.el.addClass("onActive")
						}
					},
					tablecoldelete : {
						title : MooEditable.Locale.get("deleteTableCol"),
						command : function() {
							var c = this.selection.getNode();
							if (c.get("tag") != "td")
								c = c.getParent("td");
							if (c) {
								var f = c.getParent().getParent().childNodes.length, e = c.cellIndex;
								c = c.getParent().getParent();
								for ( var h = 0; h < f; h++)
									c.childNodes[h].deleteCell(e)
							}
						}
					}
				});
MooEditable.Locale.define( {
	imageAlt : "alt",
	imageClass : "class",
	imageAlign : "align",
	imageAlignNone : "none",
	imageAlignLeft : "left",
	imageAlignCenter : "center",
	imageAlignRight : "right",
	addEditImage : "Add/Edit Image"
});
MooEditable.UI.ImageDialog = function(c) {
	var f = MooEditable.Locale.get("enterImageURL")
			+ ' <input type="text" class="dialog-url" value="" size="15"> '
			+ MooEditable.Locale.get("imageAlt")
			+ ' <input type="text" class="dialog-alt" value="" size="8"> '
			+ MooEditable.Locale.get("imageClass")
			+ ' <input type="text" class="dialog-class" value="" size="8"> '
			+ MooEditable.Locale.get("imageAlign")
			+ ' <select class="dialog-align"><option>'
			+ MooEditable.Locale.get("imageAlignNone")
			+ "</option><option>"
			+ MooEditable.Locale.get("imageAlignLeft")
			+ "</option><option>"
			+ MooEditable.Locale.get("imageAlignCenter")
			+ "</option><option>"
			+ MooEditable.Locale.get("imageAlignRight")
			+ '</option></select> <button class="dialog-button dialog-ok-button">'
			+ MooEditable.Locale.get("ok")
			+ '</button> <button class="dialog-button dialog-cancel-button">'
			+ MooEditable.Locale.get("cancel") + "</button>";
	return new MooEditable.UI.Dialog(f, {
		"class" : "mooeditable-image-dialog",
		onOpen : function() {
			var e = this.el.getElement(".dialog-url"), h = c.selection
					.getNode();
			if (h.get("tag") == "img") {
				this.el.getElement(".dialog-url").set("value", h.get("src"));
				this.el.getElement(".dialog-alt").set("value", h.get("alt"));
				this.el.getElement(".dialog-class").set("value", h.className);
				this.el.getElement(".dialog-align")
						.set("align", h.get("align"))
			}
			(function() {
				e.focus();
				e.select()
			}).delay(10)
		},
		onClick : function(e) {
			e.target.tagName.toLowerCase() == "button" && e.preventDefault();
			e = document.id(e.target);
			if (e.hasClass("dialog-cancel-button"))
				this.close();
			else if (e.hasClass("dialog-ok-button")) {
				this.close();
				e = this.el.getElement(".dialog-align");
				var h = c.selection.getNode();
				if (h.get("tag") == "img") {
					h.set("src", this.el.getElement(".dialog-url").get("value")
							.trim());
					h.set("alt", this.el.getElement(".dialog-alt").get("value")
							.trim());
					h.className = this.el.getElement(".dialog-class").get(
							"value").trim();
					h.set("align", $(e.options[e.selectedIndex]).get("value"))
				} else {
					h = new Element("div");
					(new Element("img", {
						src : this.el.getElement(".dialog-url").get("value")
								.trim(),
						alt : this.el.getElement(".dialog-alt").get("value")
								.trim(),
						"class" : this.el.getElement(".dialog-class").get(
								"value").trim(),
						align : $(e.options[e.selectedIndex]).get("value")
					})).inject(h);
					c.selection.insertContent(h.get("html"))
				}
			}
		}
	})
};
MooEditable.Actions.image = {
	title : MooEditable.Locale.get("addEditImage"),
	options : {
		shortcut : "m"
	},
	dialogs : {
		prompt : function(c) {
			return MooEditable.UI.ImageDialog(c)
		}
	},
	command : function() {
		this.dialogs.image.prompt.open()
	}
};
MooEditable.Locale.define( {
	embed : "Enter embed code",
	flashEmbed : "Flash Embed"
});
MooEditable.UI.FlashDialog = function(c) {
	var f = MooEditable.Locale.get("embed")
			+ ' <textarea class="dialog-f" value="" rows="2" cols="40"></textarea> <button class="dialog-button dialog-ok-button">'
			+ MooEditable.Locale.get("ok")
			+ '</button> <button class="dialog-button dialog-cancel-button">'
			+ MooEditable.Locale.get("cancel") + "</button>";
	return new MooEditable.UI.Dialog(f, {
		"class" : "mooeditable-flash-dialog",
		onOpen : function() {
			var e = this.el.getElement(".dialog-f");
			(function() {
				e.focus();
				e.select()
			}).delay(10)
		},
		onClick : function(e) {
			e.target.tagName.toLowerCase() == "button" && e.preventDefault();
			e = document.id(e.target);
			if (e.hasClass("dialog-cancel-button"))
				this.close();
			else if (e.hasClass("dialog-ok-button")) {
				this.close();
				e = (new Element("div")).set("html", this.el.getElement(
						".dialog-f").get("value").trim());
				c.selection.insertContent(e.get("html"))
			}
		}
	})
};
MooEditable.Actions.flash = {
	title : MooEditable.Locale.get("flashEmbed"),
	dialogs : {
		prompt : function(c) {
			return MooEditable.UI.FlashDialog(c)
		}
	},
	command : function() {
		this.dialogs.flash.prompt.open()
	}
};
MooEditable.Actions.Settings.charmap = {
	chars : [ [ "&nbsp;", "&#160;" ], [ "&amp;", "&#38;" ],
			[ "&quot;", "&#34;" ], [ "&cent;", "&#162;" ],
			[ "&euro;", "&#8364;" ], [ "&pound;", "&#163;" ],
			[ "&yen;", "&#165;" ], [ "&copy;", "&#169;" ],
			[ "&reg;", "&#174;" ], [ "&trade;", "&#8482;" ],
			[ "&permil;", "&#8240;" ], [ "&micro;", "&#181;" ],
			[ "&middot;", "&#183;" ], [ "&bull;", "&#8226;" ],
			[ "&hellip;", "&#8230;" ], [ "&prime;", "&#8242;" ],
			[ "&Prime;", "&#8243;" ], [ "&sect;", "&#167;" ],
			[ "&para;", "&#182;" ], [ "&szlig;", "&#223;" ],
			[ "&lsaquo;", "&#8249;" ], [ "&rsaquo;", "&#8250;" ],
			[ "&laquo;", "&#171;" ], [ "&raquo;", "&#187;" ],
			[ "&lsquo;", "&#8216;" ], [ "&rsquo;", "&#8217;" ],
			[ "&ldquo;", "&#8220;" ], [ "&rdquo;", "&#8221;" ],
			[ "&sbquo;", "&#8218;" ], [ "&bdquo;", "&#8222;" ],
			[ "&lt;", "&#60;" ], [ "&gt;", "&#62;" ], [ "&le;", "&#8804;" ],
			[ "&ge;", "&#8805;" ], [ "&ndash;", "&#8211;" ],
			[ "&mdash;", "&#8212;" ], [ "&macr;", "&#175;" ],
			[ "&oline;", "&#8254;" ], [ "&curren;", "&#164;" ],
			[ "&brvbar;", "&#166;" ], [ "&uml;", "&#168;" ],
			[ "&iexcl;", "&#161;" ], [ "&iquest;", "&#191;" ],
			[ "&circ;", "&#710;" ], [ "&tilde;", "&#732;" ],
			[ "&deg;", "&#176;" ], [ "&minus;", "&#8722;" ],
			[ "&plusmn;", "&#177;" ], [ "&divide;", "&#247;" ],
			[ "&frasl;", "&#8260;" ], [ "&times;", "&#215;" ],
			[ "&sup1;", "&#185;" ], [ "&sup2;", "&#178;" ],
			[ "&sup3;", "&#179;" ], [ "&frac14;", "&#188;" ],
			[ "&frac12;", "&#189;" ], [ "&frac34;", "&#190;" ],
			[ "&fnof;", "&#402;" ], [ "&int;", "&#8747;" ],
			[ "&sum;", "&#8721;" ], [ "&infin;", "&#8734;" ],
			[ "&radic;", "&#8730;" ], [ "&sim;", "&#8764;" ],
			[ "&cong;", "&#8773;" ], [ "&asymp;", "&#8776;" ],
			[ "&ne;", "&#8800;" ], [ "&equiv;", "&#8801;" ],
			[ "&isin;", "&#8712;" ], [ "&notin;", "&#8713;" ],
			[ "&ni;", "&#8715;" ], [ "&prod;", "&#8719;" ],
			[ "&and;", "&#8743;" ], [ "&or;", "&#8744;" ],
			[ "&not;", "&#172;" ], [ "&cap;", "&#8745;" ],
			[ "&cup;", "&#8746;" ], [ "&part;", "&#8706;" ],
			[ "&forall;", "&#8704;" ], [ "&exist;", "&#8707;" ],
			[ "&empty;", "&#8709;" ], [ "&nabla;", "&#8711;" ],
			[ "&lowast;", "&#8727;" ], [ "&prop;", "&#8733;" ],
			[ "&ang;", "&#8736;" ], [ "&acute;", "&#180;" ],
			[ "&cedil;", "&#184;" ], [ "&ordf;", "&#170;" ],
			[ "&ordm;", "&#186;" ], [ "&dagger;", "&#8224;" ],
			[ "&Dagger;", "&#8225;" ], [ "&Agrave;", "&#192;" ],
			[ "&Aacute;", "&#193;" ], [ "&Acirc;", "&#194;" ],
			[ "&Atilde;", "&#195;" ], [ "&Auml;", "&#196;" ],
			[ "&Aring;", "&#197;" ], [ "&AElig;", "&#198;" ],
			[ "&Ccedil;", "&#199;" ], [ "&Egrave;", "&#200;" ],
			[ "&Eacute;", "&#201;" ], [ "&Ecirc;", "&#202;" ],
			[ "&Euml;", "&#203;" ], [ "&Igrave;", "&#204;" ],
			[ "&Iacute;", "&#205;" ], [ "&Icirc;", "&#206;" ],
			[ "&Iuml;", "&#207;" ], [ "&ETH;", "&#208;" ],
			[ "&Ntilde;", "&#209;" ], [ "&Ograve;", "&#210;" ],
			[ "&Oacute;", "&#211;" ], [ "&Ocirc;", "&#212;" ],
			[ "&Otilde;", "&#213;" ], [ "&Ouml;", "&#214;" ],
			[ "&Oslash;", "&#216;" ], [ "&OElig;", "&#338;" ],
			[ "&Scaron;", "&#352;" ], [ "&Ugrave;", "&#217;" ],
			[ "&Uacute;", "&#218;" ], [ "&Ucirc;", "&#219;" ],
			[ "&Uuml;", "&#220;" ], [ "&Yacute;", "&#221;" ],
			[ "&Yuml;", "&#376;" ], [ "&THORN;", "&#222;" ],
			[ "&agrave;", "&#224;" ], [ "&aacute;", "&#225;" ],
			[ "&acirc;", "&#226;" ], [ "&atilde;", "&#227;" ],
			[ "&auml;", "&#228;" ], [ "&aring;", "&#229;" ],
			[ "&aelig;", "&#230;" ], [ "&ccedil;", "&#231;" ],
			[ "&egrave;", "&#232;" ], [ "&eacute;", "&#233;" ],
			[ "&ecirc;", "&#234;" ], [ "&euml;", "&#235;" ],
			[ "&igrave;", "&#236;" ], [ "&iacute;", "&#237;" ],
			[ "&icirc;", "&#238;" ], [ "&iuml;", "&#239;" ],
			[ "&eth;", "&#240;" ], [ "&ntilde;", "&#241;" ],
			[ "&ograve;", "&#242;" ], [ "&oacute;", "&#243;" ],
			[ "&ocirc;", "&#244;" ], [ "&otilde;", "&#245;" ],
			[ "&ouml;", "&#246;" ], [ "&oslash;", "&#248;" ],
			[ "&oelig;", "&#339;" ], [ "&scaron;", "&#353;" ],
			[ "&ugrave;", "&#249;" ], [ "&uacute;", "&#250;" ],
			[ "&ucirc;", "&#251;" ], [ "&uuml;", "&#252;" ],
			[ "&yacute;", "&#253;" ], [ "&thorn;", "&#254;" ],
			[ "&yuml;", "&#255;" ], [ "&Alpha;", "&#913;" ],
			[ "&Beta;", "&#914;" ], [ "&Gamma;", "&#915;" ],
			[ "&Delta;", "&#916;" ], [ "&Epsilon;", "&#917;" ],
			[ "&Zeta;", "&#918;" ], [ "&Eta;", "&#919;" ],
			[ "&Theta;", "&#920;" ], [ "&Iota;", "&#921;" ],
			[ "&Kappa;", "&#922;" ], [ "&Lambda;", "&#923;" ],
			[ "&Mu;", "&#924;" ], [ "&Nu;", "&#925;" ], [ "&Xi;", "&#926;" ],
			[ "&Omicron;", "&#927;" ], [ "&Pi;", "&#928;" ],
			[ "&Rho;", "&#929;" ], [ "&Sigma;", "&#931;" ],
			[ "&Tau;", "&#932;" ], [ "&Upsilon;", "&#933;" ],
			[ "&Phi;", "&#934;" ], [ "&Chi;", "&#935;" ],
			[ "&Psi;", "&#936;" ], [ "&Omega;", "&#937;" ],
			[ "&alpha;", "&#945;" ], [ "&beta;", "&#946;" ],
			[ "&gamma;", "&#947;" ], [ "&delta;", "&#948;" ],
			[ "&epsilon;", "&#949;" ], [ "&zeta;", "&#950;" ],
			[ "&eta;", "&#951;" ], [ "&theta;", "&#952;" ],
			[ "&iota;", "&#953;" ], [ "&kappa;", "&#954;" ],
			[ "&lambda;", "&#955;" ], [ "&mu;", "&#956;" ],
			[ "&nu;", "&#957;" ], [ "&xi;", "&#958;" ],
			[ "&omicron;", "&#959;" ], [ "&pi;", "&#960;" ],
			[ "&rho;", "&#961;" ], [ "&sigmaf;", "&#962;" ],
			[ "&sigma;", "&#963;" ], [ "&tau;", "&#964;" ],
			[ "&upsilon;", "&#965;" ], [ "&phi;", "&#966;" ],
			[ "&chi;", "&#967;" ], [ "&psi;", "&#968;" ],
			[ "&omega;", "&#969;" ], [ "&alefsym;", "&#8501;" ],
			[ "&piv;", "&#982;" ], [ "&real;", "&#8476;" ],
			[ "&thetasym;", "&#977;" ], [ "&upsih;", "&#978;" ],
			[ "&weierp;", "&#8472;" ], [ "&image;", "&#8465;" ],
			[ "&larr;", "&#8592;" ], [ "&uarr;", "&#8593;" ],
			[ "&rarr;", "&#8594;" ], [ "&darr;", "&#8595;" ],
			[ "&harr;", "&#8596;" ], [ "&crarr;", "&#8629;" ],
			[ "&lArr;", "&#8656;" ], [ "&uArr;", "&#8657;" ],
			[ "&rArr;", "&#8658;" ], [ "&dArr;", "&#8659;" ],
			[ "&hArr;", "&#8660;" ], [ "&there4;", "&#8756;" ],
			[ "&sub;", "&#8834;" ], [ "&sup;", "&#8835;" ],
			[ "&nsub;", "&#8836;" ], [ "&sube;", "&#8838;" ],
			[ "&supe;", "&#8839;" ], [ "&oplus;", "&#8853;" ],
			[ "&otimes;", "&#8855;" ], [ "&perp;", "&#8869;" ],
			[ "&sdot;", "&#8901;" ], [ "&lceil;", "&#8968;" ],
			[ "&rceil;", "&#8969;" ], [ "&lfloor;", "&#8970;" ],
			[ "&rfloor;", "&#8971;" ], [ "&lang;", "&#9001;" ],
			[ "&rang;", "&#9002;" ], [ "&loz;", "&#9674;" ],
			[ "&spades;", "&#9824;" ], [ "&clubs;", "&#9827;" ],
			[ "&hearts;", "&#9829;" ], [ "&diams;", "&#9830;" ] ]
};
MooEditable.Locale.define( {
	insertCustomCharacter : "Insert custom character",
	insertCharacter : "Insert character"
});
MooEditable.UI.CharacterDialog = function(c) {
	for ( var f = MooEditable.Locale.get("insertCharacter") + ' <select class="char">', e = MooEditable.Actions.Settings.charmap.chars, h = 0, a = e.length; h < a; h++)
		f += '<option data-code="' + e[h][0] + '">' + e[h][1] + "</option>";
	f += '</select><button class="dialog-button dialog-ok-button">'
			+ MooEditable.Locale.get("ok")
			+ '</button><button class="dialog-button dialog-cancel-button">'
			+ MooEditable.Locale.get("cancel") + "</button>";
	return new MooEditable.UI.Dialog(f, {
		"class" : "mooeditable-charmap-dialog",
		onClick : function(b) {
			b.target.tagName.toLowerCase() == "button" && b.preventDefault();
			b = document.id(b.target);
			if (b.hasClass("dialog-cancel-button"))
				this.close();
			else if (b.hasClass("dialog-ok-button")) {
				this.close();
				b = b.getPrevious("select.char");
				b = (new Element("div")).set("html", $(
						b.options[b.selectedIndex]).getProperty("data-code")
						.trim());
				c.selection.insertContent(b.get("html"))
			}
		}
	})
};
MooEditable.Actions.charmap = {
	title : MooEditable.Locale.get("insertCustomCharacter"),
	dialogs : {
		prompt : function(c) {
			return MooEditable.UI.CharacterDialog(c)
		}
	},
	command : function() {
		this.dialogs.charmap.prompt.open()
	},
	events : {
		toggleView : function() {
			if (this.mode == "textarea") {
				var c = this.textarea.get("value");
				MooEditable.Actions.Settings.charmap.chars.each(function(f) {
					if (! [ "&amp;", "&gt;", "&lt;", "&quot;", "&nbsp;" ]
							.contains(f[0])) {
						var e = RegExp(String.fromCharCode(parseInt(f[1]
								.replace("&#", "").replace(";", ""))), "g");
						c = c.replace(e, f[0])
					}
				}, this);
				this.textarea.set("value", c)
			}
		}
	}
};
MooEditable.Actions.Settings.pagebreak = {
	imageFile : "../../Assets/MooEditable/Other/pagebreak.gif"
};
MooEditable.Locale.define("pageBreak", "Page break");
MooEditable.Actions.pagebreak = {
	title : MooEditable.Locale.get("pageBreak"),
	command : function() {
		this.selection
				.insertContent('<img class="mooeditable-visual-aid mooeditable-pagebreak">')
	},
	events : {
		attach : function(c) {
			Browser.ie && c.doc.addListener("controlselect", function(f) {
				var e = f.target || f.srcElement;
				if (e.tagName.toLowerCase() == "img")
					if (document.id(e).hasClass("mooeditable-pagebreak"))
						if (f.preventDefault)
							f.preventDefault();
						else
							f.returnValue = false
			})
		},
		editorMouseDown : function(c, f) {
			var e = c.target, h = e.tagName.toLowerCase() == "img"
					&& $(e).hasClass("mooeditable-pagebreak");
			Function.attempt(function() {
				f.doc.execCommand("enableObjectResizing", false, !h)
			})
		},
		beforeToggleView : function() {
			if (this.mode == "iframe") {
				var c = this
						.getContent()
						.replace(
								/<img([^>]*)class="mooeditable-visual-aid mooeditable-pagebreak"([^>]*)>/gi,
								"<!-- page break --\>");
				this.setContent(c)
			} else {
				c = this.textarea
						.get("value")
						.replace(/<!-- page break --\>/gi,
								'<img class="mooeditable-visual-aid mooeditable-pagebreak">');
				this.textarea.set("value", c)
			}
		},
		render : function() {
			this.options.extraCSS = "img.mooeditable-pagebreak { display:block; width:100%; height:16px; background: url("
					+ MooEditable.Actions.Settings.pagebreak.imageFile
					+ ") repeat-x; }" + this.options.extraCSS
		}
	}
};
