/*
 Rangy, a cross-browser JavaScript range and selection library
 http://code.google.com/p/rangy/

 Copyright 2011, Tim Down
 Licensed under the MIT license.
 Version: 1.2.2
 Build date: 13 November 2011
 Advanced HTML Editor 3
 Version: 3.3.0
 (c) 2012 DMXzone.com
 @build 01-02-2012 15:21:47
*/
(function(){function va(a){var b=!1;d.ajax({async:!1,url:a,success:function(){b=!0},dataType:"script"});return b}function fa(a,b,c){return b?c?d(a).closest(b)[0]||null:d(a).parent().closest(b)[0]||null:null}function $(a,b){var c=parseInt(a,10);if(isNaN(c)||0>c)c=$(b,0);return c}function wa(a,b){a.config=function(){switch(arguments.length){case 0:return b;case 1:if("string"==typeof arguments[0])return b[arguments[0]];"object"==typeof arguments[0]&&d.extend(!0,b,arguments[0]);break;case 2:b[arguments[0]]=
arguments[1]}}}function A(a){window.console&&window.console.warn&&window.console.warn(a)}function O(){window.console&&window.console.error&&window.console.error.apply&&window.console.error.apply(this,arguments)}function xa(){return!1}function V(){return!0}function ka(a){a.preventDefault()}function ya(a){a.stopPropagation()}function P(a,b){return d.isFunction(a)?a.apply(b||{},Array.prototype.slice.call(arguments,2)):a}function L(a,b){return function(){return b.apply(a,arguments)}}function la(a,b){for(b=
b.split(".");a&&b[0];)if(a=a[b.shift()],"undefined"==typeof a)return!1;return!0}function J(a){var e;for(var b,c=window,a=a.split(".");a[0];)b=a.shift(),e=c[b]=c[b]||{},c=e}function ca(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Pa(a){a=ca(a);return a=a.replace(/[^\x00-\x7F]/g,function(a){var c=a.charCodeAt(0);return c in za?za[c]:a})}function Aa(){var a="dmxEditor_"+ ++Qa;return d.dmxEditor&&d.dmxEditor.instances&&d.dmxEditor.instances[a]?
Aa():a}function W(){d.dmxEditor.ui.hideMenus()}function Ra(a){window.cancelMenuHide=!1;W(d(a).siblings(),!0)}function Ba(a){do a=a.parentNode;while(a&&1===a.nodeType&&!a.hasAttribute("tabindex"));a&&1===a.nodeType&&a.focus&&a.focus()}function Sa(a,b){var c=d('<ul class="menu-items-wrapper"/>').appendTo(b),e,g=0;d.each(a,function(a,i){e=d('<li class="dmx-menu-item hoverable checkable" tabindex="0" />').appendTo(c);var h=d('<span class="dmx-menu-item-left">&nbsp;</span>'),l=d('<span class="dmx-menu-item-label">'+
a+"</span>"),j=d('<span class="dmx-menu-item-right">&nbsp;</span>'),k,q;i&&"object"==typeof i?(k=!!P(i.checked,i),q=!!P(i.disabled,i),k&&(b.addClass("checked"),e.addClass("checked")),q&&e.addClass("disabled").removeAttr("tabindex"),"leftStyle"in i&&h.css(i.leftStyle),"labelStyle"in i&&l.css(i.labelStyle),"rightStyle"in i&&j.css(i.rightStyle),"icon"in i&&(-1!=i.icon.indexOf("://")?h.append('<img src="'+i.icon+'" class="checkable" align="top" />'):h.append('<div class="dmx-editor-icon dmx-editor-icon-'+
i.icon+' checkable" />')),"label"in i&&l.html(i.label),"key"in i&&j.html(i.key),i.isGroupLabel&&e.addClass("group-label").removeClass("hoverable"),i.isSeparator&&(l.html(""),e.addClass("separator").removeClass("hoverable")),e.data("menuitemData",i)):"-"==i&&(l.html(""),e.addClass("separator").removeAttr("tabindex"));if(i.getMenuData)e[0].getMenuData=i.getMenuData,j.addClass("has-children");e.append(h);e.append(l);e.append(j);g=Math.max(g,l.outerWidth()+j.outerWidth()+30)});c.is(":empty")?d('<li class="dmx-menu-item hoverable disabled" style="width:90px;"><span class="dmx-menu-item-left"/><span class="dmx-menu-item-label">(Empty)</span></li>').appendTo(c):
c.css("width",g)}function Ta(a){function b(a){var b=d.data(a,"menuitemData")||{};a.parentNode.activeItem=a;a.showMenuTimeout&&window.clearTimeout(a.showMenuTimeout);Ra(a);d(a).trigger({type:"menuitemin",menuitem:a,menuitemData:b});if(b.getMenuData)a.showMenuTimeout=window.setTimeout(function(){d(a).trigger("popupmenu")},400)}d(".dmx-menu-item",a).not(".separator").not(".disabled").not(".group-label").each(function(a,e){var g=d(e),f=g.data("menuitemData")||{};g.bind("blur",function(){g.triggerHandler("mouseleave")});
g.bind("focus",function(a,c){c||b(this)});g.bind("mouseleave",function(){if(this.showMenuTimeout)window.clearTimeout(this.showMenuTimeout),this.showMenuTimeout=null;d(this).trigger({type:"menuitemout",menuitem:this,menuitemData:f})});g.bind("mouseenter",function(a){a.stopPropagation();d(this).trigger("focus",[1]);b(this)});g.bind("mousedown",function(){var a=d.Event("menucommand");a.menuitem=this;a.menuitemData=f;d(this).trigger(a);a.isDefaultPrevented()||d(this).unbind().trigger("hidemenus")})})}
function Ca(a){a=d(a||".dmx-menu");d(".dmx-menu-item",a).each(function(a,c){var e=d(".dmx-menu-item-right",c);"&nbsp;"!=e.html()&&d(".dmx-menu-item-label",c).css("marginRight",e.outerWidth({margin:!0})+12)})}function Da(){this.wrapper=d('<li class="dmx-menu-item separator"><span class="dmx-menu-item-left">&nbsp;</span><span class="dmx-menu-item-label"/><span class="dmx-menu-item-right">&nbsp;</span></li>');return this}function E(a){this.options=a;this.editor=a.editor;this.wrapper=d('<li class="dmx-menu-item hoverable checkable" tabindex="0"><span class="dmx-menu-item-left">&nbsp;</span><span class="dmx-menu-item-label"/><span class="dmx-menu-item-right">'+
(this.options.key||"&nbsp;")+"</span></li>");this.init()}function ma(a){this.options=a;this.editor=a.editor;this.wrapper=d('<li class="dmx-menu-item hoverable" tabindex="0"><span class="dmx-menu-item-left">&nbsp;</span><span class="dmx-menu-item-label"/><span class="dmx-menu-item-right">&nbsp;</span></li>');this.init()}function Ua(a){function b(a){return t.repeat(k.indent.indentChar,a)}function c(a,b){for(var a=a.replace(/\/$/gi,"").split("/"),b=b.replace(/\/$/gi,"").split("/"),c=b.slice(0),e=0;e<
a.length;e++)if(a[e].toLowerCase()==b[e].toLowerCase())c.shift();else{for(var d=0,e=a.length-e;d<e;d++)c.unshift("..");break}return c.join("/")}function e(a){a=a.nodeName;"lower"==k.alphaCase.tags?a=a.toLowerCase():"upper"==k.alphaCase.tags&&(a=a.toUpperCase());return a}function g(a,c){var e=""+(a.nodeValue||a.innerHTML||a.textContent);if(1==a.nodeType&&a.nodeName in l)return e;b(c);8==a.nodeType&&(e="<\!--"+e+"--\>","lower"==k.alphaCase.cdata?e=e.toLowerCase():"upper"==k.alphaCase.cdata&&(e=e.toUpperCase()));
k.indent.enabled&&(e=e.replace(/[\r\n]+[\t\s]*$/g,""));e&&3==a.nodeType&&(k.indent.enabled&&(e=e.replace(/^[\r\n]+/,""),e=e.replace(/[\r\n]+$/,""),e=e.replace(/^( )+/," "),e=e.replace(/( )+$/," ")),e=Pa(e),"lower"==k.alphaCase.text?e=e.toLowerCase():"upper"==k.alphaCase.text&&(e=e.toUpperCase()));return e}function f(a,c){if(a.hasAttribute&&a.hasAttribute("dmx:orig"))return unescape(a.getAttribute("dmx:orig"));if(a.hasAttribute&&a.hasAttribute("data-orig-script"))return unescape(a.getAttribute("data-orig-script"));
var d;a:{d=k.tagFilter.length;for(var f,l,w;d--;){f=k.tagFilter[d];l=f.name;if("string"==typeof l&&("*"==l||l==a.nodeName))if(w=P(f.value,{},a),2==w||3==w){d=w;break a}if(l&&l instanceof RegExp&&l.test(a.nodeName)&&(w=P(f.value,{},a),2==w||3==w)){d=w;break a}}d=1}switch(d){case 1:if(1===a.nodeType){if("IMG"==a.nodeName&&!a.alt)a.alt="";return a.nodeName in j?(d=k.indent.enabled,k.indent.enabled=!1,f=h(a,c)+i(a,c+1)+(a.nodeName in da?"":(k.indent.enabled&&a.children.length?k.eol+b(c):"")+"</"+e(a,
c)+">"),k.indent.enabled=d,f):h(a,c)+i(a,c+1)+(a.nodeName in da?"":(k.indent.enabled&&a.children.length?k.eol+b(c):"")+"</"+e(a,c)+">")}return g(a,c);case 3:return 1===a.nodeType?i(a,c):g(a,c)}return""}function i(a,b){if(1===a.nodeType){var c=a.childNodes.length,e,d="";if(0===c&&("TD"==a.nodeName||"TH"==a.nodeName))return"&nbsp;";for(e=0;e<c;e++)d+=f(a.childNodes[e],b);return d}return g(a,b)}function h(a,c){var d;d=""+((k.indent.enabled?k.eol+b(c):"")+"<");d+=e(a,c);if(a.attributes&&0<a.attributes.length)for(var g=
0;g<a.attributes.length;g++){var f;if(f=a.attributes[g].specified){a:{f=a.attributes[g];var i=a,h={name:f.name,value:f.value};h.value=k.attributeValueFilter(f,i);for(var l=k.attributeFilter.length,j=void 0,T=void 0,aa=void 0;l--;){j=k.attributeFilter[l];T=j.name;if("string"==typeof T&&("*"==T||T==f.name))if(aa=P(j.value,{},h,i),2==aa){f=aa;break a}if(T&&T instanceof RegExp&&T.test(f.name)&&(aa=P(j.value,{},h,i),2==aa)){f=aa;break a}}f=1}f=1===f}if(f)d+=" ",f=a.attributes[g].name,"lower"==k.alphaCase.attributeName?
f=f.toLowerCase():"upper"==k.alphaCase.attributeName&&(f=f.toUpperCase()),d+=f,d+='="',f=a.attributes[g],i=f.value,i=k.attributeValueFilter(f,a),"lower"==k.alphaCase.attributeValue?i=i.toLowerCase():"upper"==k.alphaCase.attributeValue&&(i=i.toUpperCase()),f=i.replace(/"/g,"&quot;"),d+=f,d+='"'}return d+=(a.nodeName in da?" /":"")+">"}var l=t.makeMap("SCRIPT,STYLE,CODE,PRE,TEXTAREA"),j=t.makeMap("A,ABBR,ACRONYM,B,BASEFONT,BDO,BIG,CITE,CODE,DFN,EM,FONT,I,IMG,INPUT,KBD,LABEL,Q,S,SAMP,SELECT,SMALL,SPAN,STRIKE,STRONG,SUB,SUP,TEXTAREA,TT,U,VAR,MARK,TIME,METER,PROGRESS"),
k=d.extend(!0,{eol:"<br/>",forceXHTML:!0,indent:{enabled:!0,indentChar:"&nbsp;",indentCount:4},alphaCase:{tags:"lower",attributeName:"auto",attributeValue:"auto",text:"auto",cdata:"auto"},tagFilter:[{name:"BODY",value:3},{name:"HTML",value:2},{name:"HEAD",value:2},{name:/^dmx/i,value:3},{name:"SCRIPT",value:function(){return ha?2:1}},{name:"TBODY",value:function(a){return a.children&&a.children[0]&&"TR"==a.children[0].nodeName?3:1}},{name:"DIV",value:function(a){return"_cssx_load_test"==a.id?2:1}},
{name:"SPAN",value:function(a){return 0==a.attributes.length?3:1}},{name:"FONT",value:function(a){return a.children&&0==a.children.length&&a.textContent&&""==t.trim(a.textContent)?2:1}},{name:"*",value:function(a){return-1<a.nodeName.indexOf(":")?2:"#text"==a.nodeName||a.nodeName in Va?1:2}}],attributeFilter:[{name:"*",value:function(a){return-1<a.name.indexOf(":")?2:1}},{name:/^_moz_/i,value:2},{name:/^dmx/i,value:2},{name:/^jquery\d+$/i,value:2},{name:/^on\w+$/i,value:function(){return ha?2:1}},
{name:/^(href|src|dynsrc|lowsrc)$/i,value:function(a){return ha?/^\s*javascript:/i.test(a.value)?2:1:1}},{name:/^(rowspan|colspan)$/i,value:function(a){return!a.value||"1"==a.value?2:1}},{name:/^style$/i,value:function(a){return!a.value?2:1}},{name:/^class$/i,value:function(a,b){if(!a.value||/^apple\-/i.test(a.value))return 2;return/^mso[^\s]+$/i.test(a.value)?(b&&b.getAttribute&&b.getAttribute("STYLE")&&b.removeAttribute("STYLE"),2):1}}],attributeValueFilter:function(a){if("style"==a.name.toLowerCase()){for(var a=
a.value.split(/\s*;\s*/),b=a.length,e=[],f,g=0;g<b;g++)f=a[g],/^\s*mso-/i.test(f)||/(expession|behavior)/i.test(f)||e.push(f);return 0===e.length?"":e.join(";")}if(/(src|href)/i.test(a.name)){b=a.value;a=d('<a href="'+b+'" />')[0].href;e=d('<a href="/" />')[0].href;if(0==a.indexOf(e))switch(k.linkType){case "rel":b=document.location.href;b=b.substring(0,b.lastIndexOf("/"))+"/";b=c(b,a);break;case "abs":b="/"+c(e,a);break;case "full":b=a}return k.forceXHTML?b.replace(/(?:&(amp;)*)/g,"&").replace(/&/g,
"&amp;"):b}return a.value},scriptTranslator:function(){}},a);if(k.forceXHTML)k.alphaCase.tags="lower",k.alphaCase.attributeName="lower";wa(this,k);this.walk=function(a,b,c){b=b||0;a=c?i(a,b):f(a,b);return a=a.replace(/^[\r\n\t\s]*/,"")}}function u(a){this.element=a;this.refresh()}function Wa(a,b){this.index=b;this.element=a;this.columns=[]}function ia(a,b,c){this.element=a;this.colSpan=parseInt(a.colSpan,10)||1;this.rowSpan=parseInt(a.rowSpan,10)||1;this.startRow=b;this.startCol=c;this.updateCoordinates_()}
function Ea(){d(".dmx-menu").each(function(){var a=d(this).data("settings");if(a&&a.offsetElement){var b=a.position||"bottom",c=d(a.offsetElement).offset();switch(b){case "bottom":d(this).css({left:c.left,top:c.top+d(a.offsetElement).outerHeight(!1)})}}})}function na(a){0==d(a.target).closest(".dmx-menu").length&&d.dmxEditor.ui.hideMenus()}function R(a,b,c){this.editor=b;this.dialog=null;this.success=!1;this.value=null;this.data={};this.options={container:"body",dialog:"",width:"auto",height:"auto",
minWidth:10,minHeight:10,darken:!1,cache:!1,parent:document,position:"down",modal:!1,retFocus:!0,onShow:null,onClose:null,onSuccess:null};d.extend(!0,this.options,c||{});this.cls="dmx-editor-dialog"+(""!=this.options.dialog?"-"+this.options.dialog:"");this.id=this.cls+"-"+a;this.cls+=" dmx-editor-wrapper"}if(!window.jQuery||"function"!=typeof window.jQuery)alert("Please include jQuery before using Advanced HTML Editor 3!");else{var Xa=function(){var a=function(){var a;if(!("createTouch"in document)){try{a=
document.createEvent("TouchEvent")}catch(c){return!1}if(!a.initTouchEvent)return!1}return!0}();return function(b){var c,e,d;function f(a){j=!0;c=a.targetTouches[0].clientX;e=a.targetTouches[0].clientY;d=window.pageYOffset;return!0}function i(a){if(j&&(10<Math.abs(a.targetTouches[0].clientX-c)||10<Math.abs(a.targetTouches[0].clientY-e)))j=!1;return!0}function h(a){var b,f;if(!j||5<Math.abs(window.pageYOffset-d))return!0;b=document.elementFromPoint(c,e);if(b.nodeType===Node.TEXT_NODE)b=b.parentNode;
if(!(-1!==b.className.indexOf("clickevent")&&-1===b.className.indexOf("touchandclickevent")))f=document.createEvent("MouseEvents"),f.initMouseEvent("click",!0,!0,window,1,0,0,c,e,!1,!1,!1,!1,0,null),f.forwardedTouchEvent=!0,b.dispatchEvent(f);if(!(b instanceof HTMLSelectElement)&&-1===b.className.indexOf("clickevent"))a.preventDefault();else return!1}function l(){j=!1}if(a){if(!(b instanceof HTMLElement))throw new TypeError("Layer must be instance of HTMLElement");a&&(b.addEventListener("touchstart",
f,!0),b.addEventListener("touchmove",i,!0),b.addEventListener("touchend",h,!0),b.addEventListener("touchcancel",l,!0));b.addEventListener("click",function(b){if(!window.event)return!0;var d=!0,f,g=window.event.forwardedTouchEvent;if(a&&(f=document.elementFromPoint(c,e),!f||!g&&-1==f.className.indexOf("clickevent")))d=!1;if(d)return!0;b.stopPropagation();b.preventDefault();b.stopImmediatePropagation();return!1},!0);if(b.onclick instanceof Function)b.addEventListener("click",b.onclick,!1),b.onclick=
"";c=0;e=0;d=0;var j=!1}}}(),d=window.jQuery,X=function(){var a=!1,b=/xyz/.test(function(){})?/\b_super\b/:/.*/,c=function(){};c.extend=function(c){function d(){!a&&this.init&&this.init.apply(this,arguments)}var f=this.prototype;a=!0;var i=new this;a=!1;for(var h in c)i[h]="function"==typeof c[h]&&"function"==typeof f[h]&&b.test(c[h])?function(a,b){return function(){var c=this._super;this._super=f[a];var e=b.apply(this,arguments);this._super=c;return e}}(h,c[h]):c[h];d.prototype=i;d.constructor=d;
d.extend=arguments.callee;return d};return c}(),t={makeMap:function(a,b){a=a||[];b=d.extend({},b||{});"string"==typeof a&&(a=a.split(/\s*,\s*/));for(var c=0,e=a.length;c<e;c++)b[a[c]]=!0;return b},resolve:function(a,b){for(var b=b||window,a=a.split("."),c=0,e=a.length;c<e&&!(b=b[a[c]],!b);c++);return b},resolveValue:function(a,b){var c=t.resolve(a,b);return"function"==typeof c?c.call(b||{}):c},getBasePath:function(){var a=d("script[src$='dmxEditor.min.js']");return 0!=a.length?a[0].src.replace(/dmxEditor\.min\.js$/,
"").replace(/\s/g,"%20"):""},repeat:function(a,b){for(var c="",e=0;e<b;e++)c+=a;return c},trim:function(a){return a.replace(/^\s+|\s+$/g,"")}},H=!1,M=d.browser.msie,ea=d.browser.mozilla;navigator.appVersion.indexOf("Mac");var Fa=!!("iPhone"==navigator.platform||"iPad"==navigator.platform||"iPod"==navigator.platform),Y=!(!Fa||!window.Worker),oa="function"==typeof window.getSelection&&"function"==typeof document.createRange,ha=!1,Ga=!1,Ha={ADDRESS:"Address",BLOCKQUOTE:"Blockquote",CENTER:"Center",DIV:"Div",
H1:"Heading 1",H2:"Heading 2",H3:"Heading 3",H4:"Heading 4",H5:"Heading 5",H6:"Heading 6",P:"Paragraph",PRE:"Preformatted text"},pa=d.extend({},Ha,{DIR:"DIR",DL:"Definition list",FIELDSET:"Fieldset",FORM:"Form",HR:"Horizontal rule",ISINDEX:"ISINDEX",MENU:"Menu (list)",NOFRAMES:"NOFRAMES",NOSCRIPT:"NOSCRIPT",OL:"Ordered list",TABLE:"Table",UL:"Unordered list",DT:"Definition therm",DD:"Definition description",LI:"List item"}),da=t.makeMap("AREA,BASE,BASEFONT,BR,COL,FRAME,HR,IMG,INPUT,ISINDEX,LINK,META,PARAM"),
Ia=t.makeMap("TABLE,TBODY",da),Ya=t.makeMap("TBODY,THEAD,TFOOT,COL,COLGROUP,TR,TH,TD,CAPTION"),Za=t.makeMap("INPUT,BUTTON,SELECT,TEXTAREA"),$a=t.makeMap("TBODY,THEAD,TFOOT");t.makeMap("CHECKED,COMPACT,DECLARE,DEFER,DISABLED,ISMAP,MULTIPLE,NOHREF,NORESIZE,NOSHADE,NOWRAP,READONLY,SELECTED");var Va=t.makeMap("A,ABBR,ADDRESS,AREA,ARTICLE,ASIDE,AUDIO,B,BASE,BDO,BLOCKQUOTE,BODY,BR,BUTTON,CANVAS,CAPTION,CITE,CODE,COL,COLGROUP,COMMAND,DATALIST,DD,DEL,DETAILS,DFN,DIV,DL,DT,EM,EMBED,EVENTSOURCE,FIELDSET,FIGCAPTION,FIGURE,FOOTER,FORM,H1,H2,H3,H4,H5,H6,HEAD,HEADER,HGROUP,HR,HTML,I,IFRAME,IMG,INPUT,INS,KBD,KEYGEN,LABEL,LEGEND,LI,LINK,MARK,MAP,MENU,META,METER,NAV,NOSCRIPT,OBJECT,OL,OPTGROUP,OPTION,OUTPUT,P,PARAM,PRE,PROGRESS,Q,RUBY,RP,RT,SAMP,SCRIPT,SECTION,SELECT,SMALL,SOURCE,SPAN,STRONG,STYLE,SUB,SUMMARY,SUP,TABLE,TBODY,TD,TEXTAREA,TFOOT,TH,THEAD,TIME,TITLE,TR,UL,VAR,VIDEO,WBR,FONT,U,STRIKE,XMP,TT,ACRONYM,BASEFONT,BIG,CENTER,DIR,FRAME,FRAMESET,ISINDEX,LEGEND,NOFRAMES,S"),
za={160:"&nbsp;",169:"&copy;",172:"&not;",174:"&reg;",178:"&sup2;",179:"&sup3;",710:"&trade;",732:"&tilde;",8211:"&ndash;",8212:"&mdash;",8216:"&lsquo;",8217:"&rsquo;",8220:"&ldquo;",8221:"&rdquo;",8224:"&dagger;",8225:"&Dagger;",8226:"&bull;",8242:"&prime;",8243:"&Prime;",8249:"&lsaquo;",8250:"&rsaquo;",8364:"&euro;",8482:"&trade;",8592:"&larr;",8593:"&uarr;",8594:"&rarr;",8595:"&darr;",8596:"&harr;",9674:"&loz;",9824:"&spades;",9827:"&clubs;",9829:"&hearts;",9830:"&diams;"},Ja={16:"SHIFT",17:"CTRL",
18:"ALT",224:"CMD"},Ka={8:"BACKSPACE",9:"TAB",13:"ENTER",27:"ESC",32:"SPACE",33:"PAGE_UP",34:"PAGE_DOWN",35:"END",36:"HOME",37:"LEFT",38:"UP",39:"RIGHT",40:"DOWN",45:"INSERT",46:"DELETE",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",
119:"F8",120:"F9",121:"F10",122:"F11",123:"F12"},ab={48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z"};jQuery(window).one("load",function(){Ga=!0});var qa={};d.each("IE MOZILLA HAS_DOM_RANGE DIALOGS_DIR ICONSETS_DIR LOCALES_DIR EXTENSIONS_DIR NS_DMX IS_MAC NO_SCRIPT_MODE".split(" "),function(a,b){qa[b]=
Function("","return "+b+";")});var Qa=0;d.dmxEditor=function(a){function b(a,b,c){if(!(b&&-1!=b.search(/(\/styles\/dmxEditor\.css|\/ScriptLibrary\/dmxEditor\/|\/styles\/dmxEditor\/)/i)))for(var b=a.length,e,d,f=0;f<b;f++)if(d=a[f],!("type"in d&&1!==d.type)&&(e=d.selectorText,-1!=e.indexOf(".")&&!(-1<e.indexOf(":"))&&!(-1<e.indexOf(" "))&&"dmx"!=e.substring(1,4)))d={},e=e.split("."),d.tag=""!=e[0]?e[0].toUpperCase():"*",d.value=e[1],d.label=e[1].toLowerCase().replace(/[-_]/g," ").replace(/\b(\w)/g,
function(a){return a.toUpperCase()}),e="*"==d.tag?"General":d.tag,c.userStyles[e]||(c.userStyles[e]=[]),c.userStyles[e].push(d)}function c(){var a=h.getDocument(),b=d(a),c=h.getBody();d(c);c=h.getWindow();d(c);var c=h.getRootElement(),c=d(c),f=d(h.frame);h.initEvents();b.bind("keydown.editor keypress.editor keyup.editor copy.editor paste.editor delete.editor",function(a){var b=new jQuery.Event("editor:"+a.type);e(b);b.isDefaultPrevented()||h.checkForSelectionChange(a)});c.unbind("drop.editor").bind("drop.editor",
function(a){h.checkForSelectionChange(a);e("editor:drop")});f.bind("editor:unload",function(b){b.isDefaultPrevented()||(l="",d("*",a).add(a).unbind())});b.bind("mouseup.editor",function(){h.checkForSelectionChange()});b.unbind("mousedown.editor").bind("mousedown.editor",function(a){d(document.documentElement).trigger("hidemenus");a=a.target;if(a.nodeName&&a.nodeName in Ia){var b=h.getSelection();b.removeAllRanges();var c=h.getRange();c.selectNode(a);b.addRange(c);h.checkForSelectionChange()}return!0});
oa||c.unbind("mousedrag.editor").bind("mousedrag.editor",function(){h.checkForSelectionChange()})}function e(a){var b,c=Array.prototype.slice.call(arguments,1);b="string"==typeof a?a:a.type;b=b.replace(/^(editor\:)?/,"editor:");if("editor:nodeselectionchange"==b&&(!c[0]||!(c[0]!==h.getDocument()&&1===d(c[0]).closest("body").length)))return!1;b=new jQuery.Event(b);"string"==typeof a?d(h.frame).trigger("editor:*",b,c).trigger(b,c):(d(h.frame).trigger("editor:*",b,c).trigger(b,c),b.isDefaultPrevented()&&
a.preventDefault(),b.isPropagationStopped()&&a.stopPropagation(),b.isImmediatePropagationStopped()&&a.stopImmediatePropagation());return b.result}function g(a,b){var c;c={editor:h,inStr:""+a};e("editor:"+b,c);return c=c.inStr}function f(a,b){var c=void 0===a?h.getBody().innerHTML:a+"";b||(c=n.htmlToCode(c));return g(c,"untranslate")}function i(a){a=n.codeToHtml(a+"");return g(a,"translate")}if(!a.frame)throw"Missing frame parameter in config";if(!a.element)throw"Missing element parameter in config";
d.data(a.element,"dmxEditor",this);d.data(a.frame,"dmxEditor",this);if(!d.dmxEditor.instances)d.dmxEditor.instances={};this.ready=!1;this.id=Aa();this.Keys={};d.dmxEditor.instances[this.id]=this;H&&console.time("["+this.id+"] load");H&&console.time("["+this.id+"] ready");this.options=d.extend(!0,{},d.dmxEditor.Defaults,a);wa(this,this.options);"noScript"in this.options&&(Ga?delete this.options.noScript:ha=!!this.options.noScript);var h=this,l,j=!0,k,q;this.importStyles=function(){if(this.options.includeCss){var a=
d('link[href*="'+this.options.includeCss+'"]',this.getDocument())[0];try{var c=a.sheet||a.styleSheet,e=c.cssRules||c.rules;e&&0<e.length&&b(e,c.href,this)}catch(f){}}};this.skin="default";this.frame=this.options.frame;this.element=this.options.element;this.Commands={};this.Toolbars={};this.userStyles={};this.currentView="design";var o=!1;this.isDocumentModified=function(){return!!o};this.history=new bb(this);this.Formatter=new Ua(this.options.formatterSettings);this.wrapper=d(this.frame).parents(".dmx-editor-wrapper:first");
this.storage={useColorCode:{highlightColor:"hex",backgroundColor:"hex",color:"hex"},livePreview:{highlightColor:!0,backgroundColor:!0,color:!0}};this.stopModificationsMonitoring=function(){j=!1};this.startModificationsMonitoring=function(){l=this.getHTML();j=!0};this.checkForDocChange=function(){if(j){var a=h.getHTML();if(a!=l){var a=h.getHTML(),b=new jQuery.Event("editor:documentedited");o=!0;e(b,l,a);b.isDefaultPrevented()||h.history.saveUndoPoint(a,"Edit document")}l=a}};var n={htmlToCode:function(a){return a.replace(/<span [^>]*?\bdata-orig-script="([^"]*)?"[^>]*><\/span>/gi,
function(a,b){return unescape(b)})},codeToHtml:function(a){return a.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,function(a){return'<span contenteditable="false" onselect="return false;" onselectstart="return false;" onbeforeeditfocus="return false;" onbeforeactivate="return false;" class="dmx-script-lock" data-orig-script="'+escape(a)+'"></span>'})}};this.setHTML=function(a){var b=l;if(b!=a){o=!0;a=i(a);d(this.getBody()).html(a);ea&&d(this.getBody()).css({MozUserInput:"enabled",MozUserModify:"read-write"});
l=this.getBody().innerHTML;var c=new jQuery.Event("editor:contentreplaced");e(c,b,a)}};this.save=function(){"code"==this.currentView&&this.setView("design");var a=d("<div>"+this.getBody().innerHTML+"</div>")[0];a.innerHTML=l=f(a.innerHTML,!0);var a=this.Formatter.walk(a,0,!0),a=a.replace(/ contenteditable="(true|false)"/g,""),b={editor:this,html:a};e("editor:beforeSave",b);a=b.html;a=a.replace(/\u200B/g,"");d(this.element).val(a);o=!1;e("editor:afterSave",b)};this.setView=function(a){this.currentView=
a;var b=this.getBody();if("code"==a)this.clearSelection(),this.frame.blur(),b=d("<div>"+this.getBody().innerHTML+"</div>")[0],b.innerHTML=f(b.innerHTML,!0),a=this.Formatter.walk(b,0,!0),b={editor:this,source:a},e("editor:beforeViewSource",b),a=b.source,this.frame.blur(),b=this.getBody(),a=ca(a).replace(/\r\n/g,"<br/>").replace(/ /g,"&nbsp;").replace(/(&lt;(.*?)&gt;)/gi,'<span class="ccp_tag">$1</span>').replace(/(&lt;\/?a\b(.*?)&gt;)/gi,'<span class="ccp_A">$1</span>').replace(/(&lt;\/?img\b(.*?)&gt;)/gi,
'<span class="ccp_img">$1</span>').replace(/(&lt;\/?(form|input|textarea|label|fieldset|legend|select|optgroup|option|button)\b(.*?)&gt;)/gi,'<span class="ccp_form">$1</span>').replace(/(&lt;\/?(table|th|tr|td|caption|colgroup|col|thead|tbody|tfoot)\b(.*?)&gt;)/gi,'<span class="ccp_table">$1</span>').replace(/(&lt;!--(.*?)--&gt;)/gi,'<span class="ccp_htmlcomment">$1</span>').replace(/=(&quot;(.*?)&quot;)/gi,'=<span class="ccp_paramvalue">$1</span>').replace(/(&amp;\w+;)/gi,'<span class="ccp_entity">$1</span>'),
b.innerHTML=a,d(this.getBody()).addClass("dmx-codeview");else if("design"==a)a=(""+d(b).html().replace(/<br\/?>/g,"\r\n").replace(/&nbsp;/g," ").replace(/<[^>]+>/g,"")).replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"),a=i(a),d(b).html(a).removeClass("dmx-codeview"),b.contentEditable=!1,l=b.innerHTML,b.contentEditable=!0;this.refreshToolbars();this.dispatch("editor:viewChanged")};this.clearSelection=function(){this.selection&&this.selection.removeAllRanges()};
this.removeNode=function(a){if(a=a||this.getSelectedNode()){if(a.nodeName in da)return this.deleteNode(a);if(fa(a,"BODY",!1)&&!(a.nodeName in Ya)){var b=h.selectedElement;if(oa){var c=this.getSelection();c.removeAllRanges();var f=a.parentNode,g=this.getDocument().createRange();g.selectNode(f);g.setStartBefore(a);d(a).replaceWith(a.innerHTML);c.addRange(g);c.collapseToStart();e("editor:selectionchange");f!==b&&e("editor:nodeselectionchange",f,b);e("editor:selectstart")}else r=this.getBody().createTextRange(),
r.moveToElementText(a),d(a).replaceWith(a.innerHTML),r.select()}}};this.deleteNode=function(a){var b=a||this.getSelectedNode();if(b&&fa(b,"BODY",!1)&&!fa(b,"TBODY",!0)&&!fa(b,"TBODY",!0)){var c=this.selectedElement;if(oa){a=this.getSelection();a.removeAllRanges();var d=b.parentNode,f=this.getDocument().createRange();f.selectNode(d);f.setStartBefore(b);var g=this.getDocument().createRange();g.selectNode(b);g.deleteContents();a.addRange(f);a.collapseToStart();e("editor:selectionchange");d!==c&&e("editor:nodeselectionchange",
d,c);e("editor:selectstart")}else a.outerHTML=""}};this.setSelectedNode=function(a){if(!a||!a.nodeName||a.nodeName in $a||this.selectedElement===a)return!1;var b=this.getSelection(),c=this.createRange();try{c.selectNodeContents(a)}catch(e){try{c.selectNode(a)}catch(d){try{c.setStartBefore(a),c.setEndAfter(a)}catch(f){A("Can't set node selection to "+a.nodeName)}}}b.setSingleRange(c);c.toString()||this.selection.collapseToStart();this.refreshSelection("setSelectedNode");return!0};this.insertHtml=function(a,
b){if(!a)return!1;a=i(""+a);M&&this.focus();var c=l=this.getHTML(),d=this.getDocument(),f=this.getSelection();b?f.deleteFromDocument():f.isCollapsed||f.collapseToEnd();try{d.execCommand("inserthtml",!1,a)}catch(g){try{var j=d.createElement("div");j.innerHTML=a;this.range.insertNode(j);j.outerHTML=j.innerHTML}catch(k){A("Couldn't insert html",k)}}d=this.getHTML();return c!=d?(l=d,e("editor:documentedited",c,d),h.history.saveUndoPoint(d,"Edit document"),!0):!1};this.insertNode=function(a){var b=h.getSelection(),
b=h.getRange(b);b.insertNode(a);b.selectNodeContents(a);this.updateSelection();return a};this.destruct=function(){this.idleDetector.destruct();k&&window.clearInterval(k);q&&window.clearTimeout(q);d(this.frame).unbind();d(this.wrapper).find("*").andSelf().unbind();d(this.getWindow()).unbind();d("*",this.getDocument()).add(this.getDocument()).unbind();h=l=this.idleDetector=null;d(this.element).removeData("dmxEditor");d(this.frame).removeData("dmxEditor");this.storage=this.options=this.history=this.frame=
this.Toolbars=this.Formatter=this.Commands=null;d.dmxEditor.instances[this.id]=null;d(this.wrapper).before(this.element);d(this.wrapper).remove();this.element.wasVisible&&(d(this.element).show(),delete this.element.wasVisible);d(this.element).trigger("editor:removed")};this.getKeyMap=function(){return KEY_MAP};this.getPathToStyles=function(){var a="/styles",b=d('link[href*="dmxEditor.css"]');0<b.length&&(a=b[0].href.replace(/dmxEditor\.css$/i,""));return a};(function(a){function b(){h.designview=
{};h.designview.element=h.frame;h.designview.window=h.getWindow();h.designview.document=h.getDocument();h.designview.body=h.getBody();h.setLocale(h.options.locale);h.initSelection();h.initCommands();h.initControls();h.initKeys();h.createToolbars();c();h.idleDetector=new cb(h,h.options.idleTolerance);d(h.frame).bind("editor:idle",L(h,h.checkForDocChange));h.extensions={};h.options.extensions?(H&&console.time("["+h.id+"] loadExtension"),h.loadExtension(h.options.extensions,function(){H&&console.timeEnd("["+
h.id+"] loadExtension");h.reloadAllToolbars();g(a);H&&console.timeEnd("["+h.id+"] ready");h.ready=!0;e("editor:ready",h)})):(g(a),H&&console.timeEnd("["+h.id+"] ready"),h.reloadAllToolbars(),h.ready=!0,e("editor:ready",h))}function f(){h.importStyles()}function g(a){h.setHTML(a||"<p>\u200b</p>");d(h.frame).show();h.getWindow();H&&console.timeEnd("["+h.id+"] load");e("editor:load");l=h.getHTML();0<h.options.autoSaveInterval&&(a=parseFloat(h.options.autoSaveInterval),!isNaN(a)&&0<a&&(a=Math.max(Math.round(6E4*
a),50),k=setInterval(function(){h&&h.execute("save")},a)));h.history.saveUndoPoint(l,"Initial state");h.getBody();d(h.frame).blur();h.options.focusOnLoad&&d(h.getBody()).trigger("focus")}h.setSkin(h.options.skin);h.setIconSet(h.options.iconSet);var i=h.config();if(!i.bgColor)i.bgColor="#FFFFFF";if(!i.textColor)i.textColor="#000000";var j="";if(h.options.autoIncludeCss){var o=document.styleSheets;if(o)for(var n=0;n<o.length;n++){var B=o[n].href;if(!B||B&&-1==B.search(/(\/styles\/dmxEditor\.css|\/ScriptLibrary\/dmxEditor\/|\/styles\/dmxEditor\/)/i))try{for(var y=
o[n].rules?o[n].rules:o[n].cssRules,B=0;B<y.length;B++)try{var v=y[B].selectorText;v&&(/^\.(dmx|firebug)/.test(v)||(j+=v+" {"+y[B].style.cssText+"}\n"))}catch(ra){}}catch(t){}}}o=""!=h.options.includeCss?'    <link rel="stylesheet" type="text/css" href="'+h.options.includeCss+'" />':"";n=h.frame.contentDocument||h.frame.contentWindow.document;n.open();n.write('<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"  xmlns:dmx="http://www.dmxzone.com/namespace/dmx">  <head>    <meta http-equiv="Content-Type" content="text/html; charset='+
document.characterSet+'" />    <meta name="format-detection" content="telephone=no" />    <title>DMXEditor Design View</title>    <link rel="stylesheet" type="text/css" href="'+h.getPathToStyles()+/*START Bizamajig Customization: Path needed extra slash.*/'/'+/*END Bizamajig Customization*/'dmxEditor/designtime.css" />'+o+"    <style>\nbody {"+(i.bodyStyle?i.bodyStyle.replace("##bgcolor##",i.bgColor).replace("##textcolor##",i.textColor):"")+"}\n "+j+(Y?"body {overflow-y:scroll;-webkit-overflow-scrolling:touch;-webkit-touch-callout:none;-webkit-tap-highlight-color: rgba(0,0,0,0);}\n":"")+'    </style>  </head>  <body spellcheck="false" contenteditable="true" onload="window.editorLoaded = true;"></body></html>');
n.close();h.getWindow().editorLoaded?f():d(h.getWindow()).load(f);(function(){function a(){h.getDocument()&&h.getBody()&&h.getWindow()?b():q=setTimeout(a,10)}a()})()})(this.options.content)};d.dmxEditor.replaceElement=function(a,b){H&&console.time("["+a.id+"] replaceElement");var c=d(a);if(!c.data("dmxEditor")){a.wasVisible=c.is(":visible");var b=d.extend(!0,{},d.dmxEditor.Defaults,b),e=b.width,g=b.height,f=d('<div class="dmx-editor-wrapper"></div>'),i=d('<div class="dmx-editor-toolbars"></div>'),
h=d('<iframe frameborder="0"></iframe>'),l=d('<div class="dmx-editor-frame-wrapper"></div>'),j=d('<div class="dmx-editor-frame-wrapper-inner"></div>'),k=c.is('textarea,input[type="text"],input[type="hidden"]')?c.val():c.html();c.is("body")?(c.html(f),f=c.find("> .dmx-editor-wrapper")):(c.wrap(f),f=c.parent(),c.hide());f.prepend(i);l.insertAfter(i);j.append(h);l.append(j);M&&f.addClass("ie").mousemove(function(a){!a.target.unselectable&&!(a.target.nodeName in Za||"IFRAME"==a.target.nodeName)&&d(a.target).attr("unselectable",
"on")});i=h.width()-h.outerWidth();l=h.height()-h.outerHeight();f.css({width:"string"==typeof e?e:e+i,height:"string"==typeof g?g:g+l});d.data(h[0],"origSize",{width:e,height:g});f.data("origSize",{width:e,height:g});var q=new d.dmxEditor(d.extend(!0,{frame:h[0],content:k,element:a},b));c.bind("focus",function(){q.focus()});f.removeClass(function(a,b){for(var c=b.split(" "),e=[],d=0;d<c.length;d++)/^dmx-editor-iconset-/.test(c[d])&&e.push(c[d]);return e.join(" ")});"default"!=b.iconSet&&(f.addClass("dmx-editor-iconset-"+
b.iconSet),require([d.dmxEditor.basePath+"css.js!"+q.getIconPath(b.iconSet+".css")],function(){q.resizeUI()}));(b.fullscreen||c.is("body"))&&q.getCommand("togglefulscreen").execute();a.form&&d(a.form).bind("submit",function(){q.save()});H&&console.timeEnd("["+a.id+"] replaceElement")}};d.dmxEditor.Command=d.dmxEditor.Command||{};d.dmxEditor.basePath=t.getBasePath();d.dmxEditor.ui=d.dmxEditor.ui||{};var La=1;d(document.documentElement).bind("hidemenus.menuhider",W).bind("contextmenu popupmenu",function(a,
b){"popupmenu"==a.type&&a.stopPropagation();var c=a.target;if("contextmenu"==a.type){if(!d.isFunction(c.getContextMenuData)&&!d.isFunction(c.getContextMenuHTML))return!0}else if(!d.isFunction(c.getMenuData)&&!d.isFunction(c.getMenuHTML))return!0;var e=d(c);b&&d(c).addClass("active");e.bind("click.menuhidertmp",function(a){W(e);a.preventDefault();a.stopImmediatePropagation()});var g="contextmenu"==a.type?d.isFunction(c.getContextMenuHTML)?c.getContextMenuHTML:c.getContextMenuData:d.isFunction(c.getMenuHTML)?
c.getMenuHTML:c.getMenuData,f="contextmenu"==a.type?a.target.contextMenuId:a.target.menuId;if(!f)"contextmenu_"==a.type?(f="contextmenu_"+La++,a.target.contextMenuId=f):(f="menu_"+La++,a.target.menuId=f);var i=d("#"+f);0===i.length&&(d.dmxEditor.ui.createMenu({offsetElement:c,data:"Hello",onHide:function(){console.log("HIDE?")}}),i=d('<div class="dmx-menu" title="" tabindex="0" />').attr("id",f).bind("contextmenu selectstart",function(a){if(!/^(input|select|button)$/i.test(a.target.nodeName))return!1}).bind("mousedown focus click",
ya).appendTo("body"));i.css({width:"auto",visibility:"hidden"}).empty().show();c=g();"string"==typeof c||c.jquery?i.append(c):c&&"object"==typeof c&&Sa(g(),i);Ta(i);if("contextmenu"==a.type)g=e.offset(),i.css({left:a.clientX-g.left,top:a.clientY-g.top});else{var h=e.attr("menuPositionX")||(e.is(".dmx-menu-item")?"left-right":"left-left"),l=e.attr("menuPositionY")||(e.is(".dmx-menu-item")?"top-top":"top-bottom"),g=e.offset();i.css({left:g.left,top:g.top+e.height()})}b&&i.css({marginLeft:"left-right"==
h?1:-1,marginTop:"top-top"==l?-1:1}).addClass("root");i.css({visibility:""});i.bind("keydown",function(a){var b=[],c=null,e=-1,e=null;a.stopImmediatePropagation();switch(a.keyCode){case 27:Ba(i[0]);W(i.parent());break;case 39:d(a.target).trigger("popupmenu").find(".dmx-menu").trigger("focus");break;case 37:if(d(a.target).is(".dmx-menu-item")){if(0<d(".dmx-menu:visible",a.target).length){W(i);break}}else d(a.target).is(".dmx-menu")&&(Ba(i[0]),W(i.parent()));break;case 40:e=d(a.target).is(".dmx-menu")?
d(a.target).find("> .menu-items-wrapper")[0]:d(a.target).parents(".menu-items-wrapper:first")[0];b=d("> .dmx-menu-item",e).not(".separator").not(".disabled").not(".group-label");0<b.length&&(c=b[0],"activeItem"in e&&(e=b.index(e.activeItem),c=++e>=b.length?b[0]:b[e]));c&&c.focus();break;case 38:e=d(a.target).is(".dmx-menu")?d(a.target).find("> .menu-items-wrapper")[0]:d(a.target).parents(".menu-items-wrapper:first")[0];b=d("> .dmx-menu-item",e).not(".separator").not(".disabled").not(".group-label");
0<b.length&&(c=b[0],"activeItem"in e&&(e=b.index(e.activeItem),c=0>--e?b[b.length-1]:b[e]));c&&c.focus();break;case 13:d(a.target).is(".dmx-menu-item")&&d(a.target).trigger("mousedown")}});b&&i.trigger("focus");e.trigger("menuload");return!1});DMXMenu=function(a){this.editor=a;this.wrapper=d('<div class="dmx-menu"></div>');d.data(this.wrapper,"DMXMenu",this);M&&this.wrapper.addClass("ie").attr("unselectable","on")};DMXMenu.prototype={addItem:function(a,b){this.wrapper.is(":empty")&&this.wrapper.append('<ul class="menu-items-wrapper"/>');
d("> .menu-items-wrapper",this.wrapper)[b?"prepend":"append"](a.wrapper);a.editor=this.editor;return a},addSubMenu:function(a,b){return this.addItem(new E({label:a,editor:this.editor}),b)},addControl:function(a,b){var c=this.editor.getControl(a);c.editor=this.editor;if(c instanceof sa){for(var e=P(c.settings.values,c),d=this.addItem(new E(c),b),f=0,i=e.length;f<i;f++)(function(a){"string"==typeof a?"-"==a?d.addSeparator():d.addItem(new E({label:a,editor:c.editor,execute:function(){c.command.execute(a)}})):
d.addItem(new E({label:a.label,editor:c.editor,execute:function(){c.command.execute(a.value)}}))})(e[f]);return d}return c instanceof U?this.addItem(new ma(c),b):this.addItem(new E(c),b)},addSeparator:function(a){return this.addItem(new Da,a)},isEmpty:function(){return this.wrapper.is(":empty")},empty:function(){this.wrapper.empty();return this},showAt:function(a,b){Ca(this.wrapper);this.wrapper.find("li.separator + li.separator").remove();this.wrapper.find("li.separator:first-child, li.separator:last-child").remove();
this.wrapper.show().stickTo(d("body"),{stickY:b,stickX:a});document.addEventListener&&document.addEventListener("mousedown",na,!0);return this},init:function(){return this},loadDialog:function(a,b,c,e){b=new R("contextmenu",c,{container:this.wrapper,parent:this.wrapper.parent(),cache:!0,position:"none",onClose:function(){this.dialog.closest(".dmx-menu").hide()},onShow:b,onSuccess:function(){e.execute(this.value||this.data);d.dmxEditor.ui.hideMenus()}});if(e.options.command)c=e.options.command.queryValue(),
d.isPlainObject(c)?b.data=c:b.value=c;b.open(a)}};E.prototype={init:function(){var a=this,b=this.options,c=d("> .dmx-menu-item-left",this.wrapper),e=d("> .dmx-menu-item-label",this.wrapper),g=d("> .dmx-menu-item-right",this.wrapper);e.text(this.editor.translate(P(b.label||b.settings&&b.settings.tooltip||b.id||"Unknown",b)));this.execute=function(a){b.execute?b.execute(a):b.command&&b.command.execute?b.command.execute(a):b.settings&&b.settings.execute&&b.settings.execute(a)};if(b.command){var f=b.command.queryEnabled();
this.wrapper.setEnabled(f);f&&b.command.queryState()&&this.wrapper.addClass("checked")}if(icon=t.resolveValue("settings.icon",b))f='<div class="dmx-editor-icon',f=-1!=icon.indexOf("://")?f+('" style="background-image:url(\''+icon+"');\" />"):f+(" dmx-editor-icon-"+icon+'" />'),c.append(f);la(b,"settings.url")&&(g.addClass("has-children"),e.css("paddingRight",g.outerWidth()+26));this.wrapper.bind({mouseenter:function(a){a.stopPropagation();if(!d(this).hasClass("disabled")){if(E.activeItem&&E.activeItem===
this)return!1;d(this).trigger("myfocus")}},mouseleave:function(a){a.target===this&&this.openTimeout&&window.clearTimeout(this.openTimeout);this.canceled=!0},myfocus:function(c){function e(){if(!f.canceled){E.activeItem=f;var c=a.wrapper.find("> .dmx-menu");0!=c.length&&(c.show().stickTo(a.wrapper,{stickY:"top-top",stickX:"left-right"}),Ca(c));d.isFunction(b.onload)&&b.onload.call(a.menu)}}c.stopPropagation();E.activeItem&&E.activeItem!==this&&d(E.activeItem).trigger("blur");var f=this;this.canceled=
!1;this.openTimeout=window.setTimeout(function(){d(a.wrapper).siblings().find(".dmx-menu").hide();if(la(b,"settings.url")){if(!a.menu)a.menu=new DMXMenu,a.menu.wrapper.hide().appendTo(a.wrapper);a.menu.loadDialog(b.settings.url,e,b.editor,a)}else e()},400)},mousedown:function(c){c.stopPropagation();if(!d(this).is(".disabled")&&!la(b,"settings.url")&&!(d(this).is(".has-children")||0!=d(".dmx-menu",this).length))a.execute(),d(this).trigger("hidemenus")}})},addItem:function(a,b){var c=d("> .dmx-menu-item-label",
this.wrapper),e=d("> .dmx-menu-item-right",this.wrapper);e.addClass("has-children");c.css("paddingRight",e.outerWidth()+26);if(!this.menu)this.menu=new DMXMenu(this.editor),this.menu.wrapper.hide().appendTo(this.wrapper);return this.menu.addItem(a,b)},addControl:function(a,b){var c=d("> .dmx-menu-item-label",this.wrapper),e=d("> .dmx-menu-item-right",this.wrapper);e.addClass("has-children");c.css("paddingRight",e.outerWidth()+26);if(!this.menu)this.menu=new DMXMenu(this.editor),this.menu.wrapper.hide().appendTo(this.wrapper);
return this.menu.addControl(a,b)},addSeparator:function(a){if(!this.menu)this.menu=new DMXMenu(this.editor),this.menu.wrapper.hide().appendTo(this.wrapper);return this.menu.addSeparator(a)}};ma.prototype={init:function(){E.prototype.init.apply(this,arguments)}};d.DMXMenu=DMXMenu;d.DMXMenuItem=E;d.DMXDialogMenuItem=ma;d.DMXMenuSeparator=Da;(function(a){a.combo=function(b){var c=a.extend(!0,{options:[],index:-1,defaultIcon:"",charSize:0,editText:"",iconic:!0,title:"",attr:{}},b),e=a('<span class="combo"/>').attr(c.attr);
e.toggleClass("iconic",c.iconic);c.defaultIcon&&e.css({backgroundImage:"url('"+c.defaultIcon+"')",backgroundRepeat:"no-repeat",backgroundPosition:"3px center"});b=a('<input type="text" spellcheck="false" />');c.charSize&&b.attr("size",c.charSize);c.editText&&b.val(c.editText);b[0].editText=c.editText;b.bind("keypress",function(b){if(!a(this).is(".disabled")){var c=this.value;d.isFunction(this.getValue)&&(c=this.getValue());void 0!==c?d(this).trigger("dmxcommand",d.makeArray(c)):d(this).trigger("dmxcommand")}b.keyCode&&
13==b.keyCode&&b.stopPropagation()});a('<div class="disable-mask"/>').appendTo(e);var g=a("<span/>");c.title&&(g.attr("title",c.title),e.bind("commandupdate",function(a,b){g.attr("title",K.translate(b.title||c.title,b.editor.options.locale))}));var f=a('<span class="btn"/>');f.click(function(){e.trigger("popupmenu",!0);return!1});g.append(b);g.append(f);e.append(g);return e};a.fn.setEnabled=function(b){return this.each(function(c,e){b?a(this).clearClass("disabled").removeAttr("disabled"):a(this).addClass("disabled").attr("disabled",
"disabled");e.disabled=!b})};a.fn.setChecked=function(b){return this.each(function(c,e){b?a(this).addClass("checked").attr("checked","checked"):a(this).clearClass("checked").removeAttr("checked");e.checked=b})};a.fn.clearClass=function(b){return this.each(function(){this.className==b?a(this).removeAttr("class"):a(this).removeClass(b)})};a.fn.numCss=function(a,c){var e=parseFloat(this.css(a));return isNaN(e)?c||0:e};a.fn.stickTo=function(b,c,e){var d=a.extend({stickY:"top-bottom",stickX:"left-left"},
c),f=a(b),i=f.offset(),h="static"!=f.css("position");return this.each(function(){var b={top:"auto",left:"auto",bottom:"auto",right:"auto"};switch(d.stickX){case "left-left":b.left=h?0:i.left;break;case "left-right":b.left=h?"100%":i.left+f.outerWidth();break;case "left-center":b.left=h?"50%":i.left+f.outerWidth()/2;break;case "left-pointer":b.left=h?e.clientX-i.left:e.clientX;break;default:if("number"==typeof d.stickX)b.left=h?d.stickX-i.left:d.stickX}switch(d.stickY){case "top-top":b.top=h?0:i.top;
break;case "top-bottom":b.top=h?"100%":i.top+f.outerHeight();break;case "top-center":b.top=h?"50%":i.top+f.outerHeight()/2;break;case "top-pointer":b.top=h?e.clientY-i.top:e.clientY;break;default:if("number"==typeof d.stickY)b.top=h?d.stickY-i.top:d.stickY}a(this).css(b);var c=a(this).offset(),k=a(this).width(),q=a(this).height(),o=a(window).scrollTop();a(window).scrollLeft();if(c.left+k+20>a(window).width()){switch(d.stickX){case "left-right":h?(b.left="auto",b.right="100%"):(b.left=c.left-k,b.right=
"auto");break;case "left-left":h?(b.left="auto",b.right=0):(b.left=c.left+(f.outerWidth()-k),b.right="auto");break;default:if("number"==typeof d.stickX)b.left=c.left-k,b.right="auto"}a(this).css(b)}if(c.top-o+q+20>a(window).height()){switch(d.stickY){case "top-top":h?(b.top="auto",b.bottom=-4):(b.top=c.top-q+(o+4),b.bottom="auto",b.marginTop="auto");break;default:if("number"==typeof d.stickY)b.top=c.top-q,b.bottom="auto",b.marginTop="auto"}a(this).css(b)}c=a(this).offset();c.top<o+10&&a(this).css({top:o-
i.top+10,bottom:"auto",marginTop:"auto"});c=a(this).offset();0>c.left&&a(this).css({left:-i.left,right:"auto"})})};a.fn.bindKey=function(b,c,e){return this.each(function(){a(this).attr("tabindex",a(this).attr("tabindex")||"0").bind(window.opera||a.browser.mozilla?"keypress.dmx":"keydown.dmx",function(d){var f=d.keyCode||d.charCode;String.fromCharCode(f);f===b&&(f=a.makeArray(e||[]),f.unshift(d),c.apply(this,f))})})};a.tabs=function(b,c){var e=a(b).find(".dmx-tab"),d=a(c).find(".dmx-tab-pannel");e.each(function(){this.tabPannel=
d.filter("."+a(this).attr("pannel"))[0];a(this).click(function(){var b=d.filter(".active");0<b.length&&b[0]!==this.tabPannel&&b.hide().removeClass("active").trigger("hide");a(this.tabPannel).show().addClass("active").trigger("show");e.filter(".active").removeClass("active").trigger("tabdeactivate");a(this).addClass("active").trigger("tabactivate")})})};a.fn.unbindKey=function(){return this.unbind(window.opera||a.browser.mozilla?"keypress.dmx":"keydown.dmx")};a.fn.ajaxUpload=function(b){var c=this;
require([a.dmxEditor.basePath+"dmxEditor/dialogs/jquery.fileupload.js"],function(){a(c).fileUpload(b);navigator.vendor&&-1!=navigator.vendor.indexOf("Apple")&&-1!=navigator.platform.indexOf("Win")&&a(c).find("input:file").bind("click.dmxEditor",function(){function a(b){b.preventDefault();b.stopPropagation();window.removeEventListener("mousedown",a,!0);return!1}window.addEventListener("mousedown",a,!0)})});return this}})(jQuery);(function(a){function b(){function a(){var c=b.hslToRgb(f.hue,f.sat,f.lum);
f.r=c[0];f.g=c[1];f.b=c[2]}function e(){var a=b.rgbToHsl(f.r,f.g,f.b);f.hue=a[0];f.sat=a[1];f.lum=a[2]}function d(b,g){b in f&&f[b]!==g&&(f[b]=g,/^(r|g|b)$/.test(b)?e():/^(hue|sat|lum)$/.test(b)&&a())}var f={hue:0,sat:0.5,lum:0.5,r:255,g:0,b:0,alpha:1,name:""};this.setAlpha=function(a){d("alpha",Math.max(Math.min(a,1),0));return this};this.setName=function(a){d("name",""+a);return this};this.setHue=function(a){d("hue",Math.max(Math.min(a,1),0));return this};this.setSaturation=function(a){d("sat",
Math.max(Math.min(a,1),0));return this};this.setLuminance=function(a){d("lum",Math.max(Math.min(a,1),0));return this};this.setR=function(a){d("r",Math.max(Math.min(a,255),0));return this};this.setG=function(a){d("g",Math.max(Math.min(a,255),0));return this};this.setB=function(a){d("b",Math.max(Math.min(a,255),0));return this};this.getAlpha=function(){return f.alpha};this.getName=function(){return f.name};this.getHue=function(){return f.hue};this.getSaturation=function(){return f.sat};this.getLuminance=
function(){return f.lum};this.getR=function(){return f.r};this.getG=function(){return f.g};this.getB=function(){return f.b};this.getString=function(a){switch(a.toLowerCase()){case "hex":return b.rgbToHex(f.r,f.g,f.b);case "rgb":return"rgb("+Math.round(f.r)+", "+Math.round(f.g)+", "+Math.round(f.b)+")";case "rgba":return"rgba("+Math.round(f.r)+", "+Math.round(f.g)+", "+Math.round(f.b)+", "+f.alpha+")";case "hsl":return"hsl("+Math.round(3600*f.hue)/10+", "+Math.round(1E3*f.sat)/10+"%, "+Math.round(1E3*
f.lum)/10+"%)";case "hsla":return"hsla("+Math.round(3600*f.hue)/10+", "+Math.round(1E3*f.sat)/10+"%, "+Math.round(1E3*f.lum)/10+"%, "+f.alpha+")"}};this.setRGB=function(a,b,c){f.r=Math.max(Math.min(a,255),0);f.g=Math.max(Math.min(b,255),0);f.b=Math.max(Math.min(c,255),0);e();return this};this.setHSL=function(b,e,d){f.hue=Math.max(Math.min(b,1),0);f.sat=Math.max(Math.min(e,1),0);f.lum=Math.max(Math.min(d,1),0);a();return this};this.setString=function(a){a=b.parse(a);this.setRGB(a.getR(),a.getG(),a.getB());
return this}}b.rgbToHex=function(b,e,d){var f=[Math.round(b).toString(16),Math.round(e).toString(16),Math.round(d).toString(16)];a.each(f,function(a,b){1==b.length&&(f[a]="0"+b)});return"#"+f.join("")};b.rgbToHsl=function(a,b,d){var a=a/255,b=b/255,d=d/255,f=Math.max(a,b,d),i=Math.min(a,b,d),h,l=(f+i)/2;if(f==i)h=i=0;else{var j=f-i,i=0.5<l?j/(2-f-i):j/(f+i);switch(f){case a:h=(b-d)/j+(b<d?6:0);break;case b:h=(d-a)/j+2;break;case d:h=(a-b)/j+4}h/=6}return[h,i,l]};b.hslToRgb=function(a,b,d){if(0===
b)d=b=a=d;else var f=function(a,b,c){0>c&&(c+=1);1<c&&(c-=1);return c<1/6?a+6*(b-a)*c:0.5>c?b:c<2/3?a+6*(b-a)*(2/3-c):a},i=0.5>d?d*(1+b):d+b-d*b,h=2*d-i,d=f(h,i,a+1/3),b=f(h,i,a),a=f(h,i,a-1/3);return[255*d,255*b,255*a]};b.parse=function(c){var e;if(c&&c.constructor==Array&&(3==c.length||4==c.length))return e=(new b).setRGB(c[0],c[1],c[2]),4==c.length&&e.setAlpha(c[3]),e;c=""+c;if(e=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return(new b).setRGB(parseInt(e[1],16),parseInt(e[2],16),
parseInt(e[3],16));if(e=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return(new b).setRGB(parseInt(e[1]+e[1],16),parseInt(e[2]+e[2],16),parseInt(e[3]+e[3],16));if(e=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return(new b).setRGB(parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10));if(e=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return(new b).setRGB(2.55*parseFloat(e[1]),2.55*parseFloat(e[2]),2.55*
parseFloat(e[3]));if(e=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*(0|1|0?\.[0-9]+)\s*\)/.exec(c))return(new b).setRGB(parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3],10)).setAlpha(parseFloat(e[4]));if(e=/rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*(0|1|0?\.[0-9]+)\s*\)/.exec(c))return(new b).setRGB(2.55*parseFloat(e[1]),2.55*parseFloat(e[2]),2.55*parseFloat(e[3])).setAlpha(parseFloat(e[4]));if(e=/hsl\(\s*([0-9]+(?:\.[0-9]+)?)\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return(new b).setHSL(parseFloat(e[1])/
360,parseFloat(e[2])/100,parseFloat(e[3])/100);if(e=/hsla\(\s*([0-9]+(?:\.[0-9]+)?)\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*(0|1|0?\.[0-9]+)\s*\)/.exec(c))return(new b).setHSL(parseFloat(e[1])/360,parseFloat(e[2])/100,parseFloat(e[3])/100).setAlpha(parseFloat(e[4]));c=a.trim(c).toLowerCase();return(e=b.namedColors[c])?(new b).setRGB(e[0],e[1],e[2]).setName(c):(new b).setRGB(0,0,0)};b.fromRGB=function(a,e,d){return(new b).setRGB(a,e,d)};b.fromHSL=function(a,d,g){return(new b).setHSL(a,
d,g)};b.namedColors={black:[0,0,0],darkgreen:[0,100,0],navy:[0,0,128],darkred:[139,0,0],midnightblue:[25,25,112],mediumblue:[0,0,205],forestgreen:[34,139,34],saddlebrown:[139,69,19],darkolivegreen:[85,107,47],firebrick:[178,34,34],brown:[165,42,42],red:[255,0,0],teal:[0,128,128],seagreen:[46,139,87],darkmagenta:[139,0,139],olivedrab:[107,142,35],sienna:[160,82,45],crimson:[220,20,60],limegreen:[50,205,50],dimgrey:[105,105,105],orangered:[255,69,0],darkgoldenrod:[184,134,11],chocolate:[210,105,30],
mediumseagreen:[60,179,113],mediumvioletred:[199,21,133],darkviolet:[148,0,211],lawngreen:[124,252,0],steelblue:[70,130,180],springgreen:[0,255,127],slategrey:[112,128,144],indianred:[205,92,92],royalblue:[65,105,225],slateblue:[106,90,205],mediumspringgreen:[0,250,154],darkorchid:[153,50,204],lightslategrey:[119,136,153],yellowgreen:[154,205,50],cadetblue:[95,158,160],goldenrod:[218,165,32],orange:[255,165,0],deeppink:[255,20,147],tomato:[255,99,71],dodgerblue:[30,144,255],deepskyblue:[0,191,255],
coral:[255,127,80],mediumslateblue:[123,104,238],gold:[255,215,0],rosybrown:[188,143,143],greenyellow:[173,255,47],mediumaquamarine:[102,205,170],palevioletred:[219,112,147],darkkhaki:[189,183,107],mediumorchid:[186,85,211],mediumturquoise:[72,209,204],cornflowerblue:[100,149,237],salmon:[250,128,114],turquoise:[64,224,208],sandybrown:[244,164,96],darksalmon:[233,150,122],darkgrey:[169,169,169],yellow:[255,255,0],lightgreen:[144,238,144],tan:[210,180,140],lightsalmon:[255,160,122],hotpink:[255,105,
180],burlywood:[222,184,135],orchid:[218,112,214],palegreen:[152,251,152],skyblue:[135,206,235],lightskyblue:[135,206,250],lightsteelblue:[176,196,222],plum:[221,160,221],violet:[238,130,238],khaki:[240,230,140],lightblue:[173,216,230],thistle:[216,191,216],powderblue:[176,224,230],lightgrey:[211,211,211],palegoldenrod:[238,232,170],wheat:[245,222,179],pink:[255,192,203],paleturquoise:[175,238,238],peachpuff:[255,218,185],gainsboro:[220,220,220],moccasin:[255,228,181],bisque:[255,228,196],blanchedalmond:[255,
235,205],antiquewhite:[250,235,215],papayawhip:[255,239,213],mistyrose:[255,228,225],lightgoldenrodyellow:[250,250,210],linen:[250,240,230],cornsilk:[255,248,220],oldlace:[253,245,230],lightyellow:[255,255,224],whitesmoke:[245,245,245],seashell:[255,245,238],lavenderblush:[255,240,245],aliceblue:[240,248,255],floralwhite:[255,250,240],mintcream:[245,255,250],ghostwhite:[248,248,255],snow:[255,250,250],white:[255,255,255]};a.Color=b})(jQuery);(function(a){function b(b){var c=a('link[href$="dmxEditor\\.css"]'),
c=c.length?c[0].href.replace(/dmxEditor\.css$/,"dmxEditor/"):"";a(b).html('<table cellpadding="0" cellspacing="0" border="0" class="dmx-color-picker" title="Double click or press Enter to select the color">  <tr>    <td>      <div class="spectrum">        <div class="spectrum-gradient"></div>        <div class="sat-gradient"></div>        <img class="color-pos" src="'+c+'cross.gif" />      </div>    </td>    <td width="10">&nbsp;&nbsp;</td>    <td>      <div class="lum">        <div class="lum-gradient"></div>        <div class="lum-pos"></div>      </div>    </td>  </tr></table>');
if(a.browser.msie||window.opera)a(".spectrum-gradient",b).replaceWith('<img class="spectrum-gradient" src="'+c+'spectrum.jpg" alt="Select Color" />'),a(".lum-gradient",b).replaceWith('<img class="lum-gradient" src="'+c+'lum.png" />')}function c(b){if(!g[b]){var c="",d="",e=(a.browser.msie?' UNSELECTABLE="on"':"")+"></a>",j,k,q,o,n;if("grey"==b)for(j=0;256>j;j++)o='<a style="background-color:rgb('+j+","+j+","+j+')"  class="c_'+j+"_"+j+"_"+j+'"'+e,c+=o;else if("web"==b)for(j=n=0;256>j;j+=51)for(k=0;256>
k;k+=51)for(q=0;256>q;q+=51)0==n%18&&(o='<a style="background-color:rgb('+j+","+j+","+j+')"  class="c_'+j+"_"+j+"_"+j+'"'+e,128>k?c+=o:d+=o),o='<a style="background-color:rgb('+k+","+q+","+j+')"  class="c_'+k+"_"+q+"_"+j+'"'+e,128>k?c+=o:d+=o,n++;else if("named"==b)for(j in a.Color.namedColors)c+='<a style="background-color:'+j+'" class="c_'+j+'" title="'+j+'"'+e;g[b]='<div class="colorTable" UNSELECTABLE="on">'+c+d+"</div>"}return g[b]}function d(b,e){var g=new a.Color;a(b).empty().append(a(c(e)).bind("click mouseover",
function(c){"A"==c.target.nodeName?(g=a.Color.parse(c.target.style.backgroundColor),a(b).trigger("click"==c.type?"colorSelect":"colorPreview",[g])):a(b).find(".active").removeClass("active")}));b.setColor=function(b){g=a.Color.parse(b);a(".colorTable a.active",this).removeClass("active");a(".colorTable a.c_"+Math.round(g.getR())+"_"+Math.round(g.getG())+"_"+Math.round(g.getB()),this).addClass("active").trigger("mouseover");return this};b.getColor=function(){return g}}var g={};a.fn.dmxColorPicker=
function(c){var g=a.extend({color:"",type:"web",base:""},c);return"rich"==g.type?this.each(function(c,d){function e(b,c){var d=Math.min(Math.max(b-ra,t),y),f=Math.min(Math.max(c-u,B),v);G[0].style.top=f+"px";G[0].style.left=d+"px";z=d/y;C=1-f/v;d=a.Color.fromHSL(z,C,0.5);ga.css("backgroundColor",d.getString("rgb"));q()}function f(a){a=Math.min(Math.max(a-u,B),v);s[0].style.top=a+"px";D=1-a/v;q()}function q(){a(d).trigger("colorPreview",[a.Color.fromHSL(z,C,D)])}function o(){y=p.width();v=p.height();
ba=p.offset();ra=ba.left;u=ba.top;A=!0}b(d,g.base);var n=a(d),G=n.find(".color-pos"),p=n.find(".spectrum-gradient"),w=n.find(".sat-gradient"),Q=n.find(".lum-gradient"),s=n.find(".lum-pos"),ga=n.find(".lum"),T=a(a.browser.msie?document.documentElement:window),t=0,B=0,y=0,v=0,ra=0,u=0,ba={top:0,left:0},z=0,C=0.5,D=0.5,A=!1,I=window.opera||a.browser.mozilla?"keypress":"keydown";w.unbind(I).attr("tabindex","0").bind(I,function(b){switch(b.keyCode||0){case 37:z>=1/360&&d.setColor(a.Color.fromHSL(z-1/360,
C,D));break;case 38:99.99>=C&&d.setColor(a.Color.fromHSL(z,C+0.01,D));break;case 39:z<=1-1/360&&d.setColor(a.Color.fromHSL(z+1/360,C,D));break;case 40:0<C&&d.setColor(a.Color.fromHSL(z,Math.max(C-0.01,0),D));break;case 13:a(n).trigger("colorSelect",[a.Color.fromHSL(z,C,D)]);break;default:return!0}return!1});G.bind("dblclick",function(){a(n).trigger("colorSelect",[a.Color.fromHSL(z,C,D)])});Q.unbind(I).attr("tabindex","0").bind(I,function(b){switch(b.keyCode||0){case 38:99.99>=D&&d.setColor(a.Color.fromHSL(z,
C,D+0.01));break;case 40:0<D&&d.setColor(a.Color.fromHSL(z,C,Math.max(D-0.01,0)));break;case 13:a(n).trigger("colorSelect",[a.Color.fromHSL(z,C,D)]);break;default:return!0}return!1});s.bind("dblclick",function(){a(n).trigger("colorSelect",[a.Color.fromHSL(z,C,D)])});a(".dmx-color-picker",d).unbind("selectstart dragstart drag drop").bind("selectstart dragstart drag drop",function(){return!1});a(d).bind("mousedown.colorpicker",function(b){A||o();if(b.target===p[0]||b.target===w[0]||b.target===G[0])e(b.pageX,
b.pageY),T.bind("mousemove.colorpicker",function(a){e(a.pageX,a.pageY)}),b.target!==w[0]&&setTimeout(function(){w.trigger("focus")},10);else if(b.target===Q[0]||b.target===s[0])f(b.pageY),T.bind("mousemove.colorpicker",function(a){f(a.pageY)}),b.target!==Q[0]&&setTimeout(function(){Q.trigger("focus")},10);else return!0;T.one("mouseup.colorpicker",function(){a(this).unbind("mousemove.colorpicker")})});d.setColor=function(b){b=b instanceof a.Color?b:"string"==typeof b?a.Color.parse(b):new a.Color;z=
b.getHue();C=b.getSaturation();D=b.getLuminance();o();G.css({left:y*z,top:v-v*C});s.css({top:v-v*D});b.setLuminance(0.5);a(".lum",n).css("backgroundColor",b.getString("rgb"));b.setLuminance(D);a(n).trigger("colorPreview",[b]);return this};d.getColor=function(b){var c=a.Color.fromHSL(z,C,D);b&&(c=c.getString(b));return c};g.color&&p.is(":visible")&&d.setColor(g.color)}):this.each(function(a,b){d(b,g.type);g.color&&b.setColor(g.color)})}})(jQuery);(function(){function a(a,b){return(b||document).querySelectorAll("["+
a+"]")}function b(a,b){var c=a.attributes,d=c.length,e=[],f;if(c&&d)for(f=0;f<d;f++)b.test(c[f].name)&&e.push(c[f]);return e}function c(a,b){var c=a.attributes,d=c.length,e;if(c&&d)for(e=0;e<d;e++)if(b.test(c[e].name))return!0;return!1}function e(a){return b(a,/^dmx\:/i)}function g(a){return c(a,/^dmx\:/i)}function f(a){d(a).bind("controlselect.lock",function(){return!1});a.contentEditable=!1}d.dmxEditor.getElementsByAttributeName=a;d.dmxEditor.getDmxAttributes=e;d.dmxEditor.hasDmxAttributes=g;d.dmxEditor.getAttributesByNameExpression=
b;d.dmxEditor.hasAttributesByNameExpression=c;d.dmxEditor.nodeIsEditable=function(a,b){if(a){if(3==a.nodeType)return!0;for(var c=a,d;c&&c.getAttribute;){if("HEAD"==a.nodeName||"HTML"==a.nodeName)return!1;if("BODY"==a.nodeName)return"content"==b;d=(""+c.getAttribute("data-locked")).toLowerCase();if("true"==d||"false"==d)return"true"!=d;c=c.parentNode}return!0}return!1};d.dmxEditor.prototype.getElementsByAttributeName=function(b){return a(b,this.getBody())};d.dmxEditor.prototype.getDmxAttributes=function(a){return e(a,
this.getBody())};d.dmxEditor.prototype.hasDmxAttributes=function(a){return g(a)};d.dmxEditor.prototype.getNodesWithDmxAttributes=function(){for(var a=this.getBody().getElementsByTagName("*"),b=a.length,c=[];b--;)g(a[b])&&c.unshift(a[b]);return c};d.dmxEditor.prototype.getDmxNodes=function(){for(var a=this.getBody().getElementsByTagName("*"),b=a.length,c=[];b--;)"DMX:"==a[b].tagName.substr(0,4)&&c.unshift(a[b]);return c};d.dmxEditor.prototype.lockNode=function(a){f(a)};d.dmxEditor.prototype.unlockNode=
function(a){a.contentEditable=!0;d(a).unbind("controlselect.lock")}})();u.prototype.refresh=function(){var a=this.rows=[],b=this.element.getElementsByTagName("TBODY");if(0!==b.length){for(var b=b[0],c=[],b=b.firstChild;b;b=b.nextSibling)"TR"==b.nodeName&&c.push(b);for(var b=0,d;d=c[b];b++){var g=a[b];d=u.getChildCellElements(d);for(var f=0,i=0,h;h=d[i];i++){for(;g&&g.columns[f];)f++;h=new ia(h,b,f);for(var l=0;l<h.rowSpan;l++){var j=b+l,k=a[j];k||a.push(k=new Wa(c[j],j));j=f+h.colSpan;if(k.columns.length<
j)k.columns.length=j;for(j=0;j<h.colSpan;j++)k.columns[f+j]=h}f+=h.colSpan}}}};u.prototype.insertRow=function(a){var a=$(a,this.rows.length),b,c;0==a?(b=this.rows[0],c=!1):(b=this.rows[a-1],c=!0);for(var e=d("<tr/>")[0],g=0,f;f=b.columns[g];g+=1)c&&f.endRow>a||!c&&f.startRow<a?(f.setRowSpan(f.rowSpan+1),1<f.colSpan&&(g+=f.colSpan-1)):e.appendChild(this.createEmptyTd()),c?d(b.element).after(e):d(b.element).before(e);this.refresh();return e};u.prototype.insertColumn=function(a){for(var a=$(a,this.rows[0]&&
this.rows[0].columns.length||0),b=[],c=0,d;d=this.rows[c];c++)(d=d.columns[a])&&d.endCol>=a&&d.startCol<a?(d.setColSpan(d.colSpan+1),c+=d.rowSpan-1):(d=this.createEmptyTd(),d.style.width=u.OPTIMUM_EMPTY_CELL_WIDTH+"px",this.insertCellElement(d,c,a),b.push(d));this.refresh();return b};u.prototype.removeRow=function(a){var b=this.rows[a];if(b){for(var c=0,d;d=b.columns[c];c+=d.colSpan)1<d.rowSpan&&(d.setRowSpan(d.rowSpan-1),d.startRow==a&&this.insertCellElement(d.element,a+1,d.startCol));b.element.parentNode.removeChild(b.element);
this.refresh()}else A("Can't remove row at position "+a+": no such row.")};u.prototype.removeColumn=function(a){for(var b=0,c;c=this.rows[b];b++){c=c.columns[a];if(!c){A("Can't remove cell at position "+b+", "+a+": no such cell.");return}1<c.colSpan?c.setColSpan(c.colSpan-1):c.element.parentNode.removeChild(c.element);b+=c.rowSpan-1}this.refresh()};u.prototype.mergeCells=function(a,b,c,d){var g=[],f;if(a==c&&b==d)return this.logger_.warning("Can't merge single cell"),!1;for(var i=a;i<=c;i++)for(var h=
b;h<=d;h++){f=this.rows[i].columns[h];if(f.startRow<a||f.endRow>c||f.startCol<b||f.endCol>d)return A("Can't merge cells: the cell in row "+i+", column "+h+"extends outside the supplied rectangle."),!1;g.push(f)}for(var h=g[0],l=h.element,j=document,i=1;f=g[i];i++)if(f=f.element,f.parentNode&&f!=l){l.lastChild&&l.lastChild.nodeType==goog.dom.NodeType.TEXT&&l.appendChild(j.createTextNode(" "));for(var k;k=f.firstChild;)l.appendChild(k);f.parentNode.removeChild(f)}h.setColSpan(d-b+1);h.setRowSpan(c-
a+1);if(d>b)l.removeAttribute("width"),l.style.width=null;this.refresh();return!0};u.prototype.splitCell=function(a,b){for(var c=this.rows[a].columns[b],d=[],g=0;g<c.rowSpan;g++)for(var f=0;f<c.colSpan;f++)if(0<g||0<f){var i=this.createEmptyTd();this.insertCellElement(i,a+g,b+f);d.push(i)}c.setColSpan(1);c.setRowSpan(1);this.refresh();return d};u.prototype.insertCellElement=function(a,b,c){for(var d=this.rows[b],g=null,f;f=d.columns[c];c+=f.colSpan)if(f.startRow==b){g=f.element;break}d.element.insertBefore(a,
g)};u.prototype.createEmptyTd=function(){return d("<td>&nbsp;</td>")[0]};u.OPTIMUM_EMPTY_CELL_WIDTH=60;u.OPTIMUM_MAX_NEW_TABLE_WIDTH=600;u.DEFAULT_BORDER_COLOR="#888";u.getChildCellElements=function(a){for(var b=[],c=0,d;d=a.childNodes[c];c++)("TD"==d.nodeName||"TH"==d.nodeName)&&b.push(d);return b};u.formatTable=function(a,b,c){b=d.extend({borderCollapse:"collapse",borderColor:u.DEFAULT_BORDER_COLOR,borderWidth:1},b);c=d.extend({border:b.borderWidth,bordercolor:b.borderColor,cellspacing:0},c);d(a).css(b).attr(c);
a.width||d("tr",a).each(function(a,b){var c=d("td, th",b),i=c.length;if(0<i){var h=Math.max(10,Math.min(u.OPTIMUM_EMPTY_CELL_WIDTH,u.OPTIMUM_MAX_NEW_TABLE_WIDTH/i));c.each(function(a,b){d(b).css("width",h*$(b.colspan,1))})}});return a};u.createDomTable=function(a){for(var a=d.extend(!0,{rows:2,cols:2,width:null,widthExt:"",border:null,cellspacing:null,cellpadding:null,alignment:null,css:{}},a),b={},c="<table>",e=0;e<a.rows;e++){for(var c=c+"<tr>",g=0;g<a.cols;g++)c+="<td>&nbsp;</td>";c+="</tr>"}c=
d(c+"</table>");if(null!==a.width)b.width=a.width+""+(a.widthExt||"")+'"';if(null!==a.border)b.border=a.border;if(null!==a.cellspacing)b.cellspacing=a.cellspacing;if(null!==a.cellpadding)b.cellpadding=a.cellpadding;if(null!==a.alignment)b.align=a.alignment;u.formatTable(c[0],a.css,b);return c[0]};ia.prototype.updateCoordinates_=function(){this.endCol=this.startCol+this.colSpan-1;this.endRow=this.startRow+this.rowSpan-1};ia.prototype.setColSpan=function(a){if(a!=this.colSpan)1<a?this.element.colSpan=
a:(this.element.colSpan=1,this.element.removeAttribute("colSpan")),this.colSpan=a,this.updateCoordinates_()};ia.prototype.setRowSpan=function(a){if(a!=this.rowSpan)1<a?this.element.rowSpan=a.toString():(this.element.rowSpan="1",this.element.removeAttribute("rowSpan")),this.rowSpan=a,this.updateCoordinates_()};var Z={Table:null,useTable:function(a){if(this.Table){if(this.Table.element!==a)this.Table.element=a,this.Table.refresh()}else this.Table=new u(a)},deleteRow:function(a){this.Table.removeRow(a.sectionRowIndex)},
deleteCol:function(a){this.Table.removeColumn(a.cellIndex)},insertRowBefore:function(a){this.Table.insertRow(a.sectionRowIndex)},insertRowAfter:function(a){this.Table.insertRow(a.sectionRowIndex+1)},insertColBefore:function(a){this.Table.insertColumn(a.cellIndex)},insertColAfter:function(a){this.Table.insertColumn(a.cellIndex+1)},splitCell:function(a){this.Table.splitCell(a.parentNode.sectionRowIndex,a.cellIndex)}};d.dmxEditor.prototype.getTableEditor=function(){function a(){var a=g.getParentNode("TD",
!0);a||(a=g.getParentNode("TH",!0));return a}function b(){return g.getParentNode("TR",!0)}function c(){return!!a()}function d(){return!!b()}var g=this,f=this.getParentNode("TABLE",!0);f&&Z.useTable(f);return{canDeleteRow:d,canInsertRowBefore:d,canInsertRowAfter:d,canInsertColBefore:c,canInsertColAfter:c,canDeleteCol:c,canDeleteTable:function(){return!!f},canSplitCell:function(){var b=a();return b&&(1<$(b.colSpan)||1<$(b.rowSpan))?!0:!1},deleteTable:function(){f&&g.deleteNode(f)},deleteRow:function(){var a=
b();a&&(Z.deleteRow(a),g.dispatch("documentedited"),g.focus())},insertRowBefore:function(){var a=b();a&&(Z.insertRowBefore(a),g.dispatch("documentedited"),g.focus())},insertRowAfter:function(){var a=b();a&&(Z.insertRowAfter(a),g.dispatch("documentedited"),g.focus())},insertColBefore:function(){var b=a();b&&(Z.insertColBefore(b),g.dispatch("documentedited"),g.focus())},insertColAfter:function(){var b=a();b&&(Z.insertColAfter(b),g.dispatch("documentedited"),g.focus())},deleteCol:function(){var b=a();
b&&(Z.deleteCol(b),g.dispatch("documentedited"),g.focus())},splitCell:function(){this.canSplitCell()&&(Z.splitCell(a()),g.dispatch("documentedited"),g.focus())}}};d.dmxEditor.Defaults={width:600,height:300,iconSet:"default",locale:"auto",includeCss:"",autoIncludeCss:!1,noScript:!0,focusOnLoad:!1,lineBreak:"auto",allowUpload:!1,uploadPath:"",subFolder:"",uploadProcessor:"asp",allowResize:!1,resizeMaxWidth:600,resizeMaxHeight:300,allowLightbox:!1,lightboxPreset:"",idleTolerance:200,historyLimit:50,
autoSaveInterval:0,formatterSettings:{eol:"\r\n",forceXHTML:!0,linkType:"rel",indent:{enabled:!0,indentChar:" ",indentCount:4},alphaCase:{tags:"lower",attributeName:"auto",attributeValue:"auto",text:"auto",cdata:"auto"}},bodyStyle:"background-color: ##bgcolor; color: ##textcolor##;",textColor:"#000",bgColor:"#fff",toolbarsOrder:"History,Text,Format,Lists,Table,Insert,Search,Font,Style,Code,Common".split(","),toolbars:{Common:{enabled:!0,visible:!0,items:t.makeMap(["viewsource","togglefullscreen"])},
History:{enabled:!0,visible:!0,items:t.makeMap(["undo","redo"])},Text:{enabled:!0,visible:!0,items:t.makeMap("bold,italic,underline,strikethrough,subscript,superscript,-1,justifyleft,justifycenter,justifyfull,justifyright,-2,indent,outdent,-3,forecolor,bgcolor".split(","))},Format:{enabled:!0,visible:!0,items:t.makeMap(["removeformat"])},Lists:{enabled:!0,visible:!0,items:t.makeMap(["insertunorderedlist","insertorderedlist"])},Table:{enabled:!0,visible:!0,items:t.makeMap("inserttable,-1,editTable,editTableCell,-2,insertRowBefore,insertRowAfter,insertColBefore,insertColAfter,-3,deleteRow,deleteCol,deleteTable".split(","))},
Insert:{enabled:!0,visible:!0,items:t.makeMap("inserthorizontalrule,-1,addlink,deletelink,-2,addaoreditimage,insertspecialchar".split(","))},Search:{enabled:!0,visible:!0,items:t.makeMap(["find","replace"])},Font:{enabled:!0,visible:!0,items:t.makeMap(["fontname","fontsize","formatblock"])},Style:{enabled:!0,visible:!0,items:t.makeMap(["setClassName"])},Code:{enabled:!0,visible:!1,items:t.makeMap(["code_toggle_wrap","code_toggle_indent"])}},fonts:{"Sans Fonts":"Arial,Verdana,Geneva,Tahoma,Trebuchet MS,Comic Sans MS".split(","),
"Serif Fonts":["Times","Times New Roman","Georgia","Book Antiqua"],"Fixed Width Fonts":["monospace","Courier","Courier New","Lucida Console"]},fontSizes:[{label:"8px",value:"8px",style:"font-size:8px;"},{label:"9px",value:"9px",style:"font-size:9px;"},{label:"10px",value:"10px",style:"font-size:10px;"},{label:"11px",value:"11px",style:"font-size:11px;"},{label:"12px",value:"12px",style:"font-size:12px;"},{label:"13px",value:"13px",style:"font-size:13px;"},{label:"14px",value:"14px",style:"font-size:14px;"},
{label:"16px",value:"16px",style:"font-size:16px;"},{label:"18px",value:"18px",style:"font-size:18px;"},{label:"20px",value:"20px",style:"font-size:20px;"},{label:"24px",value:"24px",style:"font-size:24px;"},{label:"28px",value:"28px",style:"font-size:28px;"},"-",{label:"No size",value:""}],formatBlocks:[{label:"Heading 1",value:"h1",style:"font-size:30px;font-weight:bold;"},{label:"Heading 2",value:"h2",style:"font-size:26px;font-weight:bold;"},{label:"Heading 3",value:"h3",style:"font-size:22px;font-weight:bold;"},
{label:"Heading 4",value:"h4",style:"font-size:18px;font-weight:bold;"},{label:"Heading 5",value:"h5",style:"font-size:14px;font-weight:bold;"},{label:"Heading 6",value:"h6",style:"font-size:10px;font-weight:bold;"},{label:"Preformatted",value:"pre",style:"font-family:monospace;"},{label:"Div",value:"div"},{label:"Address",value:"address",style:"font-style:italic;"},{label:"Blockquote",value:"blockquote"},{label:"Paragraph",value:"p",style:"line-height:3em;"}]};(function(a){a.extend(a.dmxEditor.prototype,
{canInsertLockedRegion:function(){return this.selectionIsEditable()},canInsertEditableRegion:function(){return!this.selectionIsEditable()},insertLockedRegion:function(a,c){if(this.canInsertLockedRegion()){var d=c||prompt("Enter the locked content","");if(d){var g=this.getDocument().createElement("DIV");g.setAttribute("data-locked","true");g.setAttribute("data-label",a);g.innerHTML=d||"\u00a0";this.stopModificationsMonitoring();this.insertNode(g);this.startModificationsMonitoring()}}},insertEditableRegion:function(a,
c){if(this.canInsertEditableRegion()){var d=this.getDocument().createElement("DIV");d.setAttribute("data-locked","false");d.setAttribute("data-label",a);d.innerHTML=c||"\u00a0";this.stopModificationsMonitoring();this.insertNode(d);this.startModificationsMonitoring()}}});a(function(){a("body").bind({"editor:nodeselectionchange":function(b,c){var d=a(b.target).data("dmxEditor"),g=d.getDocument();if(!(1>a(c).closest("body").length)){d.stopModificationsMonitoring();a("[data-locked]",g).removeClass("dmx-region").find(".outline-label").remove();
if(0<a(c).closest("body").length&&(g=a(c).closest("[data-locked]"),1===g.length)){g.addClass("dmx-region");var f=g.attr("data-label");f&&(f=a('<span class="outline-label">'+f+"</span>"),"static"==g.css("position")&&g.css("position","relative"),f.appendTo(g),f.bind({selectstart:!1,mousedown:function(a){a.stopPropagation();a.preventDefault();d.setSelectedNode(this.parentNode)}}),a.browser.msie&&g.css("height","auto"))}d.startModificationsMonitoring()}},"editor:beforeSave":function(a,c){c.html=c.html.replace(/\s*<span\s*class="outline-label">.*?<\/span>/gi,
"")},"editor:beforeViewSource":function(a,c){c.source=c.source.replace(/\s*<span\s*class="outline-label">.*?<\/span>/gi,"")}})})})(jQuery);window.rangy=function(){function a(a,b){var c=typeof a[b];return c==j||!!(c==l&&a[b])||"unknown"==c}function b(a,b){return!!(typeof a[b]==l&&a[b])}function c(a,b){return typeof a[b]!=k}function d(a){return function(b,c){for(var d=c.length;d--;)if(!a(b,c[d]))return!1;return!0}}function g(a){return a&&p(a,G)&&Q(a,n)}function f(a){window.alert("Rangy not supported in your browser. Reason: "+
a);s.initialized=!0;s.supported=!1}function i(){if(!s.initialized){var c,d=!1,e=!1;a(document,"createRange")&&(c=document.createRange(),p(c,o)&&Q(c,q)&&(d=!0),c.detach());if((c=b(document,"body")?document.body:document.getElementsByTagName("body")[0])&&a(c,"createTextRange"))c=c.createTextRange(),g(c)&&(e=!0);!d&&!e&&f("Neither Range nor TextRange are implemented");s.initialized=!0;s.features={implementsDomRange:d,implementsTextRange:e};d=t.concat(ga);e=0;for(c=d.length;e<c;++e)try{d[e](s)}catch(h){b(window,
"console")&&a(window.console,"log")&&window.console.log("Init listener threw an exception. Continuing.",h)}}}function h(a){this.name=a;this.supported=this.initialized=!1}var l="object",j="function",k="undefined",q="startContainer,startOffset,endContainer,endOffset,collapsed,commonAncestorContainer,START_TO_START,START_TO_END,END_TO_START,END_TO_END".split(","),o="setStart,setStartBefore,setStartAfter,setEnd,setEndBefore,setEndAfter,collapse,selectNode,selectNodeContents,compareBoundaryPoints,deleteContents,extractContents,cloneContents,insertNode,surroundContents,cloneRange,toString,detach".split(","),
n="boundingHeight,boundingLeft,boundingTop,boundingWidth,htmlText,text".split(","),G="collapse,compareEndPoints,duplicate,getBookmark,moveToBookmark,moveToElementText,parentElement,pasteHTML,select,setEndPoint,getBoundingClientRect".split(","),p=d(a),w=d(b),Q=d(c),s={version:"1.2.2",initialized:!1,supported:!0,util:{isHostMethod:a,isHostObject:b,isHostProperty:c,areHostMethods:p,areHostObjects:w,areHostProperties:Q,isTextRange:g},features:{},modules:{},config:{alertOnWarn:!1,preferTextRange:!1}};
s.fail=f;s.warn=function(a){a="Rangy warning: "+a;s.config.alertOnWarn?window.alert(a):typeof window.console!=k&&typeof window.console.log!=k&&window.console.log(a)};({}).hasOwnProperty?s.util.extend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}:f("hasOwnProperty not supported");var ga=[],t=[];s.init=i;s.addInitListener=function(a){s.initialized?a(s):ga.push(a)};var u=[];s.addCreateMissingNativeApiListener=function(a){u.push(a)};s.createMissingNativeApi=function(a){a=a||window;i();
for(var b=0,c=u.length;b<c;++b)u[b](a)};h.prototype.fail=function(a){this.initialized=!0;this.supported=!1;throw Error("Module '"+this.name+"' failed to load: "+a);};h.prototype.warn=function(a){s.warn("Module "+this.name+": "+a)};h.prototype.createError=function(a){return Error("Error in Rangy "+this.name+" module: "+a)};s.createModule=function(a,b){var c=new h(a);s.modules[a]=c;t.push(function(a){b(a,c);c.initialized=!0;c.supported=!0})};s.requireModules=function(a){for(var b=0,c=a.length,d,e;b<
c;++b){e=a[b];d=s.modules[e];if(!d||!(d instanceof h))throw Error("Module '"+e+"' not found");if(!d.supported)throw Error("Module '"+e+"' not supported");}};var B=!1,w=function(){B||(B=!0,s.initialized||i())};if(typeof window==k)f("No window found");else if(typeof document==k)f("No document found");else return a(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",w,!1),a(window,"addEventListener")?window.addEventListener("load",w,!1):a(window,"attachEvent")?window.attachEvent("onload",
w):f("Window does not have required addEventListener or attachEvent method"),s}();rangy.createModule("DomUtil",function(a,b){function c(a){for(var b=0;a=a.previousSibling;)b++;return b}function d(a,b){var c=[],e;for(e=a;e;e=e.parentNode)c.push(e);for(e=b;e;e=e.parentNode)if(p(c,e))return e;return null}function g(a,b,c){for(c=c?a:a.parentNode;c;){a=c.parentNode;if(a===b)return c;c=a}return null}function f(a){a=a.nodeType;return 3==a||4==a||8==a}function i(a,b){var c=b.nextSibling,d=b.parentNode;c?
d.insertBefore(a,c):d.appendChild(a);return a}function h(a){if(9==a.nodeType)return a;if(typeof a.ownerDocument!=o)return a.ownerDocument;if(typeof a.document!=o)return a.document;if(a.parentNode)return h(a.parentNode);throw Error("getDocument: no document found for node");}function l(a){return!a?"[No node]":f(a)?'"'+a.data+'"':1==a.nodeType?"<"+a.nodeName+(a.id?' id="'+a.id+'"':"")+">["+a.childNodes.length+"]":a.nodeName}function j(a){this._next=this.root=a}function k(a,b){this.node=a;this.offset=
b}function q(a){this.code=this[a];this.codeName=a;this.message="DOMException: "+this.codeName}var o="undefined",n=a.util;n.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||b.fail("document missing a Node creation method");n.isHostMethod(document,"getElementsByTagName")||b.fail("document missing getElementsByTagName method");var G=document.createElement("div");n.areHostMethods(G,["insertBefore","appendChild","cloneNode"])||b.fail("Incomplete Element implementation");
n.isHostProperty(G,"innerHTML")||b.fail("Element is missing innerHTML property");G=document.createTextNode("test");n.areHostMethods(G,["splitText","deleteData","insertData","appendData","cloneNode"])||b.fail("Incomplete Text Node implementation");var p=function(a,b){for(var c=a.length;c--;)if(a[c]===b)return!0;return!1};j.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next,b;if(this._current){b=a.firstChild;if(!b)for(b=null;a!==this.root&&
!(b=a.nextSibling);)a=a.parentNode;this._next=b}return this._current},detach:function(){this._current=this._next=this.root=null}};k.prototype={equals:function(a){return this.node===a.node&this.offset==a.offset},inspect:function(){return"[DomPosition("+l(this.node)+":"+this.offset+")]"}};q.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11};q.prototype.toString=function(){return this.message};
a.dom={arrayContains:p,isHtmlNamespace:function(a){var b;return typeof a.namespaceURI==o||null===(b=a.namespaceURI)||"http://www.w3.org/1999/xhtml"==b},parentElement:function(a){a=a.parentNode;return 1==a.nodeType?a:null},getNodeIndex:c,getNodeLength:function(a){var b;return f(a)?a.length:(b=a.childNodes)?b.length:0},getCommonAncestor:d,isAncestorOf:function(a,b,c){for(b=c?b:b.parentNode;b;){if(b===a)return!0;b=b.parentNode}return!1},getClosestAncestorIn:g,isCharacterDataNode:f,insertAfter:i,splitDataNode:function(a,
b){var c=a.cloneNode(!1);c.deleteData(0,b);a.deleteData(b,a.length-b);i(c,a);return c},getDocument:h,getWindow:function(a){a=h(a);if(typeof a.defaultView!=o)return a.defaultView;if(typeof a.parentWindow!=o)return a.parentWindow;throw Error("Cannot get a window object for node");},getIframeWindow:function(a){if(typeof a.contentWindow!=o)return a.contentWindow;if(typeof a.contentDocument!=o)return a.contentDocument.defaultView;throw Error("getIframeWindow: No Window object found for iframe element");
},getIframeDocument:function(a){if(typeof a.contentDocument!=o)return a.contentDocument;if(typeof a.contentWindow!=o)return a.contentWindow.document;throw Error("getIframeWindow: No Document object found for iframe element");},getBody:function(a){return n.isHostObject(a,"body")?a.body:a.getElementsByTagName("body")[0]},getRootContainer:function(a){for(var b;b=a.parentNode;)a=b;return a},comparePoints:function(a,b,f,h){var i;if(a==f)return b===h?0:b<h?-1:1;if(i=g(f,a,!0))return b<=c(i)?-1:1;if(i=g(a,
f,!0))return c(i)<h?-1:1;b=d(a,f);a=a===b?b:g(a,b,!0);f=f===b?b:g(f,b,!0);if(a===f)throw Error("comparePoints got to case 4 and childA and childB are the same!");for(b=b.firstChild;b;){if(b===a)return-1;if(b===f)return 1;b=b.nextSibling}throw Error("Should not be here!");},inspectNode:l,fragmentFromNodeChildren:function(a){for(var b=h(a).createDocumentFragment(),c;c=a.firstChild;)b.appendChild(c);return b},createIterator:function(a){return new j(a)},DomPosition:k};a.DOMException=q});rangy.createModule("DomRange",
function(a){function b(a,b){return 3!=a.nodeType&&(m.isAncestorOf(a,b.startContainer,!0)||m.isAncestorOf(a,b.endContainer,!0))}function c(a){return m.getDocument(a.startContainer)}function d(a,b,c){if(b=a._listeners[b])for(var e=0,f=b.length;e<f;++e)b[e].call(a,{target:a,args:c})}function g(a){return new x(a.parentNode,m.getNodeIndex(a))}function f(a){return new x(a.parentNode,m.getNodeIndex(a)+1)}function i(a,b,c){var d=11==a.nodeType?a.firstChild:a;m.isCharacterDataNode(b)?c==b.length?m.insertAfter(a,
b):b.parentNode.insertBefore(a,0==c?b:m.splitDataNode(b,c)):c>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[c]);return d}function h(a){for(var b,d,e=c(a.range).createDocumentFragment();d=a.next();){b=a.isPartiallySelectedSubtree();d=d.cloneNode(!b);b&&(b=a.getSubtreeIterator(),d.appendChild(h(b)),b.detach(!0));if(10==d.nodeType)throw new N("HIERARCHY_REQUEST_ERR");e.appendChild(d)}return e}function l(a,b,c){for(var d,e,c=c||{stop:!1};d=a.next();)if(a.isPartiallySelectedSubtree())if(!1===
b(d)){c.stop=!0;break}else{if(d=a.getSubtreeIterator(),l(d,b,c),d.detach(!0),c.stop)break}else for(d=m.createIterator(d);e=d.next();)if(!1===b(e)){c.stop=!0;return}}function j(a){for(var b;a.next();)a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),j(b),b.detach(!0)):a.remove()}function k(a){for(var b,d=c(a.range).createDocumentFragment(),e;b=a.next();){a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),e=a.getSubtreeIterator(),b.appendChild(k(e)),e.detach(!0)):a.remove();if(10==b.nodeType)throw new N("HIERARCHY_REQUEST_ERR");
d.appendChild(b)}return d}function q(a,b,c){var d=!(!b||!b.length),e,f=!!c;d&&(e=RegExp("^("+b.join("|")+")$"));var g=[];l(new n(a,!1),function(a){(!d||e.test(a.nodeType))&&(!f||c(a))&&g.push(a)});return g}function o(a){return"["+("undefined"==typeof a.getName?"Range":a.getName())+"("+m.inspectNode(a.startContainer)+":"+a.startOffset+", "+m.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function n(a,b){this.range=a;this.clonePartiallySelectedTextNodes=b;if(!a.collapsed){this.sc=a.startContainer;
this.so=a.startOffset;this.ec=a.endContainer;this.eo=a.endOffset;var c=a.commonAncestorContainer;this.sc===this.ec&&m.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===c&&!m.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:m.getClosestAncestorIn(this.sc,c,!0),this._last=this.ec===c&&!m.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:m.getClosestAncestorIn(this.ec,c,!0))}}function G(a){this.code=
this[a];this.codeName=a;this.message="RangeException: "+this.codeName}function p(a,b,c){this.nodes=q(a,b,c);this._next=this.nodes[0];this._position=0}function w(a){return function(b,c){for(var d,e=c?b:b.parentNode;e;){d=e.nodeType;if(m.arrayContains(a,d))return e;e=e.parentNode}return null}}function Q(a,b){if(db(a,b))throw new G("INVALID_NODE_TYPE_ERR");}function s(a){if(!a.startContainer)throw new N("INVALID_STATE_ERR");}function t(a,b){if(!m.arrayContains(b,a.nodeType))throw new G("INVALID_NODE_TYPE_ERR");
}function u(a,b){if(0>b||b>(m.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new N("INDEX_SIZE_ERR");}function A(a,b){if(ja(a,!0)!==ja(b,!0))throw new N("WRONG_DOCUMENT_ERR");}function B(a){if(eb(a,!0))throw new N("NO_MODIFICATION_ALLOWED_ERR");}function y(a,b){if(!a)throw new N(b);}function v(a){s(a);if(!m.arrayContains(H,a.startContainer.nodeType)&&!ja(a.startContainer,!0)||!m.arrayContains(H,a.endContainer.nodeType)&&!ja(a.endContainer,!0)||!(a.startOffset<=(m.isCharacterDataNode(a.startContainer)?
a.startContainer.length:a.startContainer.childNodes.length))||!(a.endOffset<=(m.isCharacterDataNode(a.endContainer)?a.endContainer.length:a.endContainer.childNodes.length)))throw Error("Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")");}function E(){}function F(a){a.START_TO_START=L;a.START_TO_END=M;a.END_TO_END=$;a.END_TO_START=V;a.NODE_BEFORE=W;a.NODE_AFTER=X;a.NODE_BEFORE_AND_AFTER=Y;a.NODE_INSIDE=U}function ba(a){F(a);F(a.prototype)}function z(a,b){return function(){v(this);
var c=this.startContainer,d=this.startOffset,e=this.commonAncestorContainer,g=new n(this,!0);if(c!==e)c=m.getClosestAncestorIn(c,e,!0),d=f(c),c=d.node,d=d.offset;l(g,B);g.reset();e=a(g);g.detach();b(this,c,d,c,d);return e}}function C(c,d,e){function h(a,b){return function(c){s(this);t(c,J);t(S(c),H);c=(a?g:f)(c);(b?i:l)(this,c.node,c.offset)}}function i(a,b,c){var e=a.endContainer,f=a.endOffset;if(b!==a.startContainer||c!==a.startOffset){if(S(b)!=S(e)||1==m.comparePoints(b,c,e,f))e=b,f=c;d(a,b,c,
e,f)}}function l(a,b,c){var e=a.startContainer,f=a.startOffset;if(b!==a.endContainer||c!==a.endOffset){if(S(b)!=S(e)||-1==m.comparePoints(b,c,e,f))e=b,f=c;d(a,e,f,b,c)}}c.prototype=new E;a.util.extend(c.prototype,{setStart:function(a,b){s(this);Q(a,!0);u(a,b);i(this,a,b)},setEnd:function(a,b){s(this);Q(a,!0);u(a,b);l(this,a,b)},setStartBefore:h(!0,!0),setStartAfter:h(!1,!0),setEndBefore:h(!0,!1),setEndAfter:h(!1,!1),collapse:function(a){v(this);a?d(this,this.startContainer,this.startOffset,this.startContainer,
this.startOffset):d(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){s(this);Q(a,!0);d(this,a,0,a,m.getNodeLength(a))},selectNode:function(a){s(this);Q(a,!1);t(a,J);var b=g(a),a=f(a);d(this,b.node,b.offset,a.node,a.offset)},extractContents:z(k,d),deleteContents:z(j,d),canSurroundContents:function(){v(this);B(this.startContainer);B(this.endContainer);var a=new n(this,!0),c=a._first&&b(a._first,this)||a._last&&b(a._last,this);a.detach();return!c},
detach:function(){e(this)},splitBoundaries:function(){v(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,e=this.endOffset,f=a===c;m.isCharacterDataNode(c)&&0<e&&e<c.length&&m.splitDataNode(c,e);m.isCharacterDataNode(a)&&0<b&&b<a.length&&(a=m.splitDataNode(a,b),f?(e-=b,c=a):c==a.parentNode&&e>=m.getNodeIndex(a)&&e++,b=0);d(this,a,b,c,e)},normalizeBoundaries:function(){v(this);var a=this.startContainer,b=this.startOffset,c=this.endContainer,e=this.endOffset,f=function(a){var b=
a.nextSibling;if(b&&b.nodeType==a.nodeType)c=a,e=a.length,a.appendData(b.data),b.parentNode.removeChild(b)},g=function(d){var f=d.previousSibling;if(f&&f.nodeType==d.nodeType){a=d;var g=d.length;b=f.length;d.insertData(0,f.data);f.parentNode.removeChild(f);a==c?(e+=b,c=a):c==d.parentNode&&(f=m.getNodeIndex(d),e==f?(c=d,e=g):e>f&&e--)}},S=!0;m.isCharacterDataNode(c)?c.length==e&&f(c):(0<e&&(S=c.childNodes[e-1])&&m.isCharacterDataNode(S)&&f(S),S=!this.collapsed);S?m.isCharacterDataNode(a)?0==b&&g(a):
b<a.childNodes.length&&(f=a.childNodes[b])&&m.isCharacterDataNode(f)&&g(f):(a=c,b=e);d(this,a,b,c,e)},collapseToPoint:function(a,b){s(this);Q(a,!0);u(a,b);(a!==this.startContainer||b!==this.startOffset||a!==this.endContainer||b!==this.endOffset)&&d(this,a,b,a,b)}});ba(c)}function D(a){a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset;a.commonAncestorContainer=a.collapsed?a.startContainer:m.getCommonAncestor(a.startContainer,a.endContainer)}function K(a,b,c,f,g){var S=a.startContainer!==
b||a.startOffset!==c,h=a.endContainer!==f||a.endOffset!==g;a.startContainer=b;a.startOffset=c;a.endContainer=f;a.endOffset=g;D(a);d(a,"boundarychange",{startMoved:S,endMoved:h})}function I(a){this.startContainer=a;this.startOffset=0;this.endContainer=a;this.endOffset=0;this._listeners={boundarychange:[],detach:[]};D(this)}a.requireModules(["DomUtil"]);var m=a.dom,x=m.DomPosition,N=a.DOMException;n.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=
null;this._next=this._first},hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next;if(a)this._next=a!==this._last?a.nextSibling:null,m.isCharacterDataNode(a)&&this.clonePartiallySelectedTextNodes&&(a===this.ec&&(a=a.cloneNode(!0)).deleteData(this.eo,a.length-this.eo),this._current===this.sc&&(a=a.cloneNode(!0)).deleteData(0,this.so));return a},remove:function(){var a=this._current,b,c;m.isCharacterDataNode(a)&&(a===this.sc||a===this.ec)?(b=a===this.sc?this.so:0,c=a===
this.ec?this.eo:a.length,b!=c&&a.deleteData(b,c-b)):a.parentNode&&a.parentNode.removeChild(a)},isPartiallySelectedSubtree:function(){return b(this._current,this.range)},getSubtreeIterator:function(){var a;if(this.isSingleCharacterDataNode)a=this.range.cloneRange(),a.collapse();else{a=new I(c(this.range));var b=this._current,d=b,e=0,f=b,g=m.getNodeLength(b);if(m.isAncestorOf(b,this.sc,!0))d=this.sc,e=this.so;if(m.isAncestorOf(b,this.ec,!0))f=this.ec,g=this.eo;K(a,d,e,f,g)}return new n(a,this.clonePartiallySelectedTextNodes)},
detach:function(a){a&&this.range.detach();this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};G.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2};G.prototype.toString=function(){return this.message};p.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){this._current=this._next;this._next=this.nodes[++this._position];return this._current},detach:function(){this._current=this._next=this.nodes=null}};var J=[1,3,4,5,
7,8,10],H=[2,9,11],P=[1,3,4,5,7,8,10,11],R=[1,3,4,5,7,8],S=m.getRootContainer,ja=w([9,11]),eb=w([5,6,10,12]),db=w([6,10,12]),Ma=document.createElement("style"),ta=!1;try{Ma.innerHTML="<b>x</b>",ta=3==Ma.firstChild.nodeType}catch(Z){}a.features.htmlParsingConforms=ta;var O="startContainer,startOffset,endContainer,endOffset,collapsed,commonAncestorContainer".split(","),L=0,M=1,$=2,V=3,W=0,X=1,Y=2,U=3;E.prototype={attachListener:function(a,b){this._listeners[a].push(b)},compareBoundaryPoints:function(a,
b){v(this);A(this.startContainer,b.startContainer);var c=a==V||a==L?"start":"end",d=a==M||a==L?"start":"end";return m.comparePoints(this[c+"Container"],this[c+"Offset"],b[d+"Container"],b[d+"Offset"])},insertNode:function(a){v(this);t(a,P);B(this.startContainer);if(m.isAncestorOf(a,this.startContainer,!0))throw new N("HIERARCHY_REQUEST_ERR");this.setStartBefore(i(a,this.startContainer,this.startOffset))},cloneContents:function(){v(this);var a,b;if(this.collapsed)return c(this).createDocumentFragment();
if(this.startContainer===this.endContainer&&m.isCharacterDataNode(this.startContainer))return a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=c(this).createDocumentFragment(),b.appendChild(a),b;b=new n(this,!0);a=h(b);b.detach();return a},canSurroundContents:function(){v(this);B(this.startContainer);B(this.endContainer);var a=new n(this,!0),c=a._first&&b(a._first,this)||a._last&&b(a._last,this);a.detach();return!c},surroundContents:function(a){t(a,R);if(!this.canSurroundContents())throw new G("BAD_BOUNDARYPOINTS_ERR");
var b=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);i(a,this.startContainer,this.startOffset);a.appendChild(b);this.selectNode(a)},cloneRange:function(){v(this);for(var a=new I(c(this)),b=O.length,d;b--;)d=O[b],a[d]=this[d];return a},toString:function(){v(this);var a=this.startContainer;if(a===this.endContainer&&m.isCharacterDataNode(a))return 3==a.nodeType||4==a.nodeType?a.data.slice(this.startOffset,this.endOffset):"";var b=[],a=new n(this,!0);l(a,function(a){(3==
a.nodeType||4==a.nodeType)&&b.push(a.data)});a.detach();return b.join("")},compareNode:function(a){v(this);var b=a.parentNode,c=m.getNodeIndex(a);if(!b)throw new N("NOT_FOUND_ERR");a=this.comparePoint(b,c);b=this.comparePoint(b,c+1);return 0>a?0<b?Y:W:0<b?X:U},comparePoint:function(a,b){v(this);y(a,"HIERARCHY_REQUEST_ERR");A(a,this.startContainer);return 0>m.comparePoints(a,b,this.startContainer,this.startOffset)?-1:0<m.comparePoints(a,b,this.endContainer,this.endOffset)?1:0},createContextualFragment:ta?
function(a){var b=this.startContainer,c=m.getDocument(b);if(!b)throw new N("INVALID_STATE_ERR");var d=null;1==b.nodeType?d=b:m.isCharacterDataNode(b)&&(d=m.parentElement(b));d=null===d||"HTML"==d.nodeName&&m.isHtmlNamespace(m.getDocument(d).documentElement)&&m.isHtmlNamespace(d)?c.createElement("body"):d.cloneNode(!1);d.innerHTML=a;return m.fragmentFromNodeChildren(d)}:function(a){s(this);var b=c(this).createElement("body");b.innerHTML=a;return m.fragmentFromNodeChildren(b)},toHtml:function(){v(this);
var a=c(this).createElement("div");a.appendChild(this.cloneContents());return a.innerHTML},intersectsNode:function(a,b){v(this);y(a,"NOT_FOUND_ERR");if(m.getDocument(a)!==c(this))return!1;var d=a.parentNode,e=m.getNodeIndex(a);y(d,"NOT_FOUND_ERR");var f=m.comparePoints(d,e,this.endContainer,this.endOffset),d=m.comparePoints(d,e+1,this.startContainer,this.startOffset);return b?0>=f&&0<=d:0>f&&0<d},isPointInRange:function(a,b){v(this);y(a,"HIERARCHY_REQUEST_ERR");A(a,this.startContainer);return 0<=
m.comparePoints(a,b,this.startContainer,this.startOffset)&&0>=m.comparePoints(a,b,this.endContainer,this.endOffset)},intersectsRange:function(a,b){v(this);if(c(a)!=c(this))throw new N("WRONG_DOCUMENT_ERR");var d=m.comparePoints(this.startContainer,this.startOffset,a.endContainer,a.endOffset),e=m.comparePoints(this.endContainer,this.endOffset,a.startContainer,a.startOffset);return b?0>=d&&0<=e:0>d&&0<e},intersection:function(a){if(this.intersectsRange(a)){var b=m.comparePoints(this.startContainer,
this.startOffset,a.startContainer,a.startOffset),c=m.comparePoints(this.endContainer,this.endOffset,a.endContainer,a.endOffset),d=this.cloneRange();-1==b&&d.setStart(a.startContainer,a.startOffset);1==c&&d.setEnd(a.endContainer,a.endOffset);return d}return null},union:function(a){if(this.intersectsRange(a,!0)){var b=this.cloneRange();-1==m.comparePoints(a.startContainer,a.startOffset,this.startContainer,this.startOffset)&&b.setStart(a.startContainer,a.startOffset);1==m.comparePoints(a.endContainer,
a.endOffset,this.endContainer,this.endOffset)&&b.setEnd(a.endContainer,a.endOffset);return b}throw new G("Ranges do not intersect");},containsNode:function(a,b){return b?this.intersectsNode(a,!1):this.compareNode(a)==U},containsNodeContents:function(a){return 0<=this.comparePoint(a,0)&&0>=this.comparePoint(a,m.getNodeLength(a))},containsRange:function(a){return this.intersection(a).equals(a)},containsNodeText:function(a){var b=this.cloneRange();b.selectNode(a);var c=b.getNodes([3]);return 0<c.length?
(b.setStart(c[0],0),a=c.pop(),b.setEnd(a,a.length),a=this.containsRange(b),b.detach(),a):this.containsNodeContents(a)},createNodeIterator:function(a,b){v(this);return new p(this,a,b)},getNodes:function(a,b){v(this);return q(this,a,b)},getDocument:function(){return c(this)},collapseBefore:function(a){s(this);this.setEndBefore(a);this.collapse(!1)},collapseAfter:function(a){s(this);this.setStartAfter(a);this.collapse(!0)},getName:function(){return"DomRange"},equals:function(a){return I.rangesEqual(this,
a)},inspect:function(){return o(this)}};C(I,K,function(a){s(a);a.startContainer=a.startOffset=a.endContainer=a.endOffset=null;a.collapsed=a.commonAncestorContainer=null;d(a,"detach",null);a._listeners=null});a.rangePrototype=E.prototype;I.rangeProperties=O;I.RangeIterator=n;I.copyComparisonConstants=ba;I.createPrototypeRange=C;I.inspect=o;I.getRangeDocument=c;I.rangesEqual=function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===
b.endOffset};a.DomRange=I;a.RangeException=G});rangy.createModule("WrappedRange",function(a){function b(a,b,c,d){var e=a.duplicate();e.collapse(c);var h=e.parentElement();g.isAncestorOf(b,h,!0)||(h=b);if(!h.canHaveHTML)return new f(h.parentNode,g.getNodeIndex(h));var b=g.getDocument(h).createElement("span"),i,p=c?"StartToStart":"StartToEnd";do h.insertBefore(b,b.previousSibling),e.moveToElementText(b);while(0<(i=e.compareEndPoints(p,a))&&b.previousSibling);p=b.nextSibling;if(-1==i&&p&&g.isCharacterDataNode(p)){e.setEndPoint(c?
"EndToStart":"EndToEnd",a);if(/[\r\n]/.test(p.data)){h=e.duplicate();c=h.text.replace(/\r\n/g,"\r").length;for(c=h.moveStart("character",c);-1==h.compareEndPoints("StartToEnd",h);)c++,h.moveStart("character",1)}else c=e.text.length;h=new f(p,c)}else p=(d||!c)&&b.previousSibling,h=(c=(d||c)&&b.nextSibling)&&g.isCharacterDataNode(c)?new f(c,0):p&&g.isCharacterDataNode(p)?new f(p,p.length):new f(h,g.getNodeIndex(b));b.parentNode.removeChild(b);return h}function c(a,b){var c,d,e=a.offset,f=g.getDocument(a.node),
h=f.body.createTextRange(),i=g.isCharacterDataNode(a.node);i?(c=a.node,d=c.parentNode):(c=a.node.childNodes,c=e<c.length?c[e]:null,d=a.node);f=f.createElement("span");f.innerHTML="&#feff;";c?d.insertBefore(f,c):d.appendChild(f);h.moveToElementText(f);h.collapse(!b);d.removeChild(f);if(i)h[b?"moveStart":"moveEnd"]("character",e);return h}a.requireModules(["DomUtil","DomRange"]);var d,g=a.dom,f=g.DomPosition,i=a.DomRange;if(a.features.implementsDomRange&&(!a.features.implementsTextRange||!a.config.preferTextRange))(function(){function b(a){for(var c=
f.length,d;c--;)d=f[c],a[d]=a.nativeRange[d]}var c,f=i.rangeProperties,h;d=function(a){if(!a)throw Error("Range must be specified");this.nativeRange=a;b(this)};i.createPrototypeRange(d,function(a,b,c,d,e){var f=a.endContainer!==d||a.endOffset!=e;if(a.startContainer!==b||a.startOffset!=c||f)a.setEnd(d,e),a.setStart(b,c)},function(a){a.nativeRange.detach();a.detached=!0;for(var b=f.length,c;b--;)c=f[b],a[c]=null});c=d.prototype;c.selectNode=function(a){this.nativeRange.selectNode(a);b(this)};c.deleteContents=
function(){this.nativeRange.deleteContents();b(this)};c.extractContents=function(){var a=this.nativeRange.extractContents();b(this);return a};c.cloneContents=function(){return this.nativeRange.cloneContents()};c.surroundContents=function(a){this.nativeRange.surroundContents(a);b(this)};c.collapse=function(a){this.nativeRange.collapse(a);b(this)};c.cloneRange=function(){return new d(this.nativeRange.cloneRange())};c.refresh=function(){b(this)};c.toString=function(){return this.nativeRange.toString()};
var o=document.createTextNode("test");g.getBody(document).appendChild(o);var n=document.createRange();n.setStart(o,0);n.setEnd(o,0);try{n.setStart(o,1),c.setStart=function(a,c){this.nativeRange.setStart(a,c);b(this)},c.setEnd=function(a,c){this.nativeRange.setEnd(a,c);b(this)},h=function(a){return function(c){this.nativeRange[a](c);b(this)}}}catch(t){c.setStart=function(a,c){try{this.nativeRange.setStart(a,c)}catch(d){this.nativeRange.setEnd(a,c),this.nativeRange.setStart(a,c)}b(this)},c.setEnd=function(a,
c){try{this.nativeRange.setEnd(a,c)}catch(d){this.nativeRange.setStart(a,c),this.nativeRange.setEnd(a,c)}b(this)},h=function(a,c){return function(d){try{this.nativeRange[a](d)}catch(e){this.nativeRange[c](d),this.nativeRange[a](d)}b(this)}}}c.setStartBefore=h("setStartBefore","setEndBefore");c.setStartAfter=h("setStartAfter","setEndAfter");c.setEndBefore=h("setEndBefore","setStartBefore");c.setEndAfter=h("setEndAfter","setStartAfter");n.selectNodeContents(o);c.selectNodeContents=n.startContainer==
o&&n.endContainer==o&&0==n.startOffset&&n.endOffset==o.length?function(a){this.nativeRange.selectNodeContents(a);b(this)}:function(a){this.setStart(a,0);this.setEnd(a,i.getEndOffset(a))};n.selectNodeContents(o);n.setEnd(o,3);h=document.createRange();h.selectNodeContents(o);h.setEnd(o,4);h.setStart(o,2);c.compareBoundaryPoints=-1==n.compareBoundaryPoints(n.START_TO_END,h)&1==n.compareBoundaryPoints(n.END_TO_START,h)?function(a,b){b=b.nativeRange||b;if(a==b.START_TO_END)a=b.END_TO_START;else if(a==
b.END_TO_START)a=b.START_TO_END;return this.nativeRange.compareBoundaryPoints(a,b)}:function(a,b){return this.nativeRange.compareBoundaryPoints(a,b.nativeRange||b)};if(a.util.isHostMethod(n,"createContextualFragment"))c.createContextualFragment=function(a){return this.nativeRange.createContextualFragment(a)};g.getBody(document).removeChild(o);n.detach();h.detach()})(),a.createNativeRange=function(a){return(a||document).createRange()};else if(a.features.implementsTextRange){d=function(a){this.textRange=
a;this.refresh()};d.prototype=new i(document);d.prototype.refresh=function(){var a,c,d=this.textRange;a=d.parentElement();var e=d.duplicate();e.collapse(!0);c=e.parentElement();e=d.duplicate();e.collapse(!1);d=e.parentElement();c=c==d?c:g.getCommonAncestor(c,d);c=c==a?c:g.getCommonAncestor(a,c);0==this.textRange.compareEndPoints("StartToEnd",this.textRange)?c=a=b(this.textRange,c,!0,!0):(a=b(this.textRange,c,!0,!1),c=b(this.textRange,c,!1,!1));this.setStart(a.node,a.offset);this.setEnd(c.node,c.offset)};
i.copyComparisonConstants(d);var h=function(){return this}();if("undefined"==typeof h.Range)h.Range=d;a.createNativeRange=function(a){return(a||document).body.createTextRange()}}if(a.features.implementsTextRange)d.rangeToTextRange=function(a){if(a.collapsed)return c(new f(a.startContainer,a.startOffset),!0);var b=c(new f(a.startContainer,a.startOffset),!0),d=c(new f(a.endContainer,a.endOffset),!1),a=g.getDocument(a.startContainer).body.createTextRange();a.setEndPoint("StartToStart",b);a.setEndPoint("EndToEnd",
d);return a};d.prototype.getName=function(){return"WrappedRange"};a.WrappedRange=d;a.createRange=function(b){return new d(a.createNativeRange(b||document))};a.createRangyRange=function(a){return new i(a||document)};a.createIframeRange=function(b){return a.createRange(g.getIframeDocument(b))};a.createIframeRangyRange=function(b){return a.createRangyRange(g.getIframeDocument(b))};a.addCreateMissingNativeApiListener(function(b){b=b.document;if("undefined"==typeof b.createRange)b.createRange=function(){return a.createRange(this)};
b=b=null})});rangy.createModule("WrappedSelection",function(a,b){function c(a){return(a||window).getSelection()}function d(a){return(a||window).document.selection}function g(a,b,c){var d=c?"end":"start",c=c?"start":"end";a.anchorNode=b[d+"Container"];a.anchorOffset=b[d+"Offset"];a.focusNode=b[c+"Container"];a.focusOffset=b[c+"Offset"]}function f(a){a.anchorNode=a.focusNode=null;a.anchorOffset=a.focusOffset=0;a.rangeCount=0;a.isCollapsed=!0;a._ranges.length=0}function i(b){var c;if(b instanceof u){if(c=
b._selectionNativeRange,!c)c=a.createNativeRange(p.getDocument(b.startContainer)),c.setEnd(b.endContainer,b.endOffset),c.setStart(b.startContainer,b.startOffset),b._selectionNativeRange=c,b.attachListener("detach",function(){this._selectionNativeRange=null})}else b instanceof s?c=b.nativeRange:a.features.implementsDomRange&&b instanceof p.getWindow(b.startContainer).Range&&(c=b);return c}function h(a){var b=a.getNodes(),c;a:if(!b.length||1!=b[0].nodeType)c=!1;else{c=1;for(var d=b.length;c<d;++c)if(!p.isAncestorOf(b[0],
b[c])){c=!1;break a}c=!0}if(!c)throw Error("getSingleElementFromRange: range "+a.inspect()+" did not consist of a single element");return b[0]}function l(a,b){var c=new s(b);a._ranges=[c];g(a,c,!1);a.rangeCount=1;a.isCollapsed=c.collapsed}function j(b){b._ranges.length=0;if("None"==b.docSelection.type)f(b);else{var c=b.docSelection.createRange();if(c&&"undefined"!=typeof c.text)l(b,c);else{b.rangeCount=c.length;for(var d,e=p.getDocument(c.item(0)),h=0;h<b.rangeCount;++h)d=a.createRange(e),d.selectNode(c.item(h)),
b._ranges.push(d);b.isCollapsed=1==b.rangeCount&&b._ranges[0].collapsed;g(b,b._ranges[b.rangeCount-1],!1)}}}function k(a,b){for(var c=a.docSelection.createRange(),d=h(b),e=p.getDocument(c.item(0)),e=p.getBody(e).createControlRange(),f=0,g=c.length;f<g;++f)e.add(c.item(f));try{e.add(d)}catch(i){throw Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)");}e.select();j(a)}function q(a,b,c){this.nativeSelection=a;this.docSelection=b;this._ranges=
[];this.win=c;this.refresh()}function o(a,b){for(var c=p.getDocument(b[0].startContainer),c=p.getBody(c).createControlRange(),d=0,e;d<rangeCount;++d){e=h(b[d]);try{c.add(e)}catch(f){throw Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)");}}c.select();j(a)}function n(a,b){if(a.anchorNode&&p.getDocument(a.anchorNode)!==p.getDocument(b))throw new A("WRONG_DOCUMENT_ERR");}function t(a){var b=[],c=new E(a.anchorNode,a.anchorOffset),
d=new E(a.focusNode,a.focusOffset),e="function"==typeof a.getName?a.getName():"Selection";if("undefined"!=typeof a.rangeCount)for(var f=0,g=a.rangeCount;f<g;++f)b[f]=u.inspect(a.getRangeAt(f));return"["+e+"(Ranges: "+b.join(", ")+")(anchor: "+c.inspect()+", focus: "+d.inspect()+"]"}a.requireModules(["DomUtil","DomRange","WrappedRange"]);a.config.checkSelectionRanges=!0;var p=a.dom,w=a.util,u=a.DomRange,s=a.WrappedRange,A=a.DOMException,E=p.DomPosition,F,B,y=a.util.isHostMethod(window,"getSelection"),
v=a.util.isHostObject(document,"selection"),H=v&&(!y||a.config.preferTextRange);H?(F=d,a.isSelectionValid=function(a){var a=(a||window).document,b=a.selection,c;try{c=b.createRange()}catch(d){return!1}return"None"!=b.type||c&&p.getDocument(c.parentElement())==a}):y?(F=c,a.isSelectionValid=function(){return!0}):b.fail("Neither document.selection or window.getSelection() detected.");a.getNativeSelection=F;var y=F(),K=a.createNativeRange(document),J=p.getBody(document),z=w.areHostObjects(y,w.areHostProperties(y,
["anchorOffset","focusOffset"]));a.features.selectionHasAnchorAndFocus=z;var C=w.isHostMethod(y,"extend");a.features.selectionHasExtend=C;var D="number"==typeof y.rangeCount;a.features.selectionHasRangeCount=D;var O=!1,I=!0;w.areHostMethods(y,["addRange","getRangeAt","removeAllRanges"])&&"number"==typeof y.rangeCount&&a.features.implementsDomRange&&function(){var a=document.createElement("iframe");J.appendChild(a);var b=p.getIframeDocument(a);b.open();b.write("<html><head></head><body>12</body></html>");
b.close();var c=p.getIframeWindow(a).getSelection(),d=b.documentElement.lastChild.firstChild,b=b.createRange();b.setStart(d,1);b.collapse(!0);c.addRange(b);I=1==c.rangeCount;c.removeAllRanges();var e=b.cloneRange();b.setStart(d,0);e.setEnd(d,2);c.addRange(b);c.addRange(e);O=2==c.rangeCount;b.detach();e.detach();J.removeChild(a)}();a.features.selectionSupportsMultipleRanges=O;a.features.collapsedNonEditableSelectionsSupported=I;var m=!1,x;J&&w.isHostMethod(J,"createControlRange")&&(x=J.createControlRange(),
w.areHostProperties(x,["item","add"])&&(m=!0));a.features.implementsControlRange=m;B=z?function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1};var N;w.isHostMethod(y,"getRangeAt")?N=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:z&&(N=function(b){var c=p.getDocument(b.anchorNode),c=a.createRange(c);c.setStart(b.anchorNode,b.anchorOffset);c.setEnd(b.focusNode,b.focusOffset);c.collapsed!==
this.isCollapsed&&(c.setStart(b.focusNode,b.focusOffset),c.setEnd(b.anchorNode,b.anchorOffset));return c});a.getSelection=function(a){var a=a||window,b=a._rangySelection,c=F(a),f=v?d(a):null;b?(b.nativeSelection=c,b.docSelection=f,b.refresh(a)):(b=new q(c,f,a),a._rangySelection=b);return b};a.getIframeSelection=function(b){return a.getSelection(p.getIframeWindow(b))};x=q.prototype;if(!H&&z&&w.areHostMethods(y,["removeAllRanges","addRange"])){x.removeAllRanges=function(){this.nativeSelection.removeAllRanges();
f(this)};var P=function(b,c){var d=u.getRangeDocument(c),d=a.createRange(d);d.collapseToPoint(c.endContainer,c.endOffset);b.nativeSelection.addRange(i(d));b.nativeSelection.extend(c.startContainer,c.startOffset);b.refresh()};x.addRange=D?function(b,c){if(m&&v&&"Control"==this.docSelection.type)k(this,b);else if(c&&C)P(this,b);else{var d;O?d=this.rangeCount:(this.removeAllRanges(),d=0);this.nativeSelection.addRange(i(b));this.rangeCount=this.nativeSelection.rangeCount;this.rangeCount==d+1?(a.config.checkSelectionRanges&&
(d=N(this.nativeSelection,this.rangeCount-1))&&!u.rangesEqual(d,b)&&(b=new s(d)),this._ranges[this.rangeCount-1]=b,g(this,b,M(this.nativeSelection)),this.isCollapsed=B(this)):this.refresh()}}:function(a,b){b&&C?P(this,a):(this.nativeSelection.addRange(i(a)),this.refresh())};x.setRanges=function(a){if(m&&1<a.length)o(this,a);else{this.removeAllRanges();for(var b=0,c=a.length;b<c;++b)this.addRange(a[b])}}}else if(w.isHostMethod(y,"empty")&&w.isHostMethod(K,"select")&&m&&H)x.removeAllRanges=function(){try{if(this.docSelection.empty(),
"None"!=this.docSelection.type){var a;if(this.anchorNode)a=p.getDocument(this.anchorNode);else if("Control"==this.docSelection.type){var b=this.docSelection.createRange();b.length&&(a=p.getDocument(b.item(0)).body.createTextRange())}a&&(a.body.createTextRange().select(),this.docSelection.empty())}}catch(c){}f(this)},x.addRange=function(a){"Control"==this.docSelection.type?k(this,a):(s.rangeToTextRange(a).select(),this._ranges[0]=a,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,g(this,
a,!1))},x.setRanges=function(a){this.removeAllRanges();var b=a.length;1<b?o(this,a):b&&this.addRange(a[0])};else return b.fail("No means of selecting a Range or TextRange was found"),!1;x.getRangeAt=function(a){if(0>a||a>=this.rangeCount)throw new A("INDEX_SIZE_ERR");return this._ranges[a]};var L;if(H)L=function(b){var c;a.isSelectionValid(b.win)?c=b.docSelection.createRange():(c=p.getBody(b.win.document).createTextRange(),c.collapse(!0));"Control"==b.docSelection.type?j(b):c&&"undefined"!=typeof c.text?
l(b,c):f(b)};else if(w.isHostMethod(y,"getRangeAt")&&"number"==typeof y.rangeCount)L=function(b){if(m&&v&&"Control"==b.docSelection.type)j(b);else if(b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount,b.rangeCount){for(var c=0,d=b.rangeCount;c<d;++c)b._ranges[c]=new a.WrappedRange(b.nativeSelection.getRangeAt(c));g(b,b._ranges[b.rangeCount-1],M(b.nativeSelection));b.isCollapsed=B(b)}else f(b)};else if(z&&"boolean"==typeof y.isCollapsed&&"boolean"==typeof K.collapsed&&a.features.implementsDomRange)L=
function(a){var b;b=a.nativeSelection;b.anchorNode?(b=N(b,0),a._ranges=[b],a.rangeCount=1,b=a.nativeSelection,a.anchorNode=b.anchorNode,a.anchorOffset=b.anchorOffset,a.focusNode=b.focusNode,a.focusOffset=b.focusOffset,a.isCollapsed=B(a)):f(a)};else return b.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;x.refresh=function(a){var b=a?this._ranges.slice(0):null;L(this);if(a){a=b.length;if(a!=this._ranges.length)return!1;for(;a--;)if(!u.rangesEqual(b[a],this._ranges[a]))return!1;
return!0}};var R=function(a,b){var c=a.getAllRanges(),d=!1;a.removeAllRanges();for(var e=0,g=c.length;e<g;++e)d||b!==c[e]?a.addRange(c[e]):d=!0;a.rangeCount||f(a)};x.removeRange=m?function(a){if("Control"==this.docSelection.type){for(var b=this.docSelection.createRange(),a=h(a),c=p.getDocument(b.item(0)),c=p.getBody(c).createControlRange(),d,e=!1,f=0,g=b.length;f<g;++f)d=b.item(f),d!==a||e?c.add(b.item(f)):e=!0;c.select();j(this)}else R(this,a)}:function(a){R(this,a)};var M;!H&&z&&a.features.implementsDomRange?
(M=function(a){var b=!1;a.anchorNode&&(b=1==p.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset));return b},x.isBackwards=function(){return M(this)}):M=x.isBackwards=function(){return!1};x.toString=function(){for(var a=[],b=0,c=this.rangeCount;b<c;++b)a[b]=""+this._ranges[b];return a.join("")};x.collapse=function(b,c){n(this,b);var d=a.createRange(p.getDocument(b));d.collapseToPoint(b,c);this.removeAllRanges();this.addRange(d);this.isCollapsed=!0};x.collapseToStart=function(){if(this.rangeCount){var a=
this._ranges[0];this.collapse(a.startContainer,a.startOffset)}else throw new A("INVALID_STATE_ERR");};x.collapseToEnd=function(){if(this.rangeCount){var a=this._ranges[this.rangeCount-1];this.collapse(a.endContainer,a.endOffset)}else throw new A("INVALID_STATE_ERR");};x.selectAllChildren=function(b){n(this,b);var c=a.createRange(p.getDocument(b));c.selectNodeContents(b);this.removeAllRanges();this.addRange(c)};x.deleteFromDocument=function(){if(m&&v&&"Control"==this.docSelection.type){for(var a=this.docSelection.createRange(),
b;a.length;)b=a.item(0),a.remove(b),b.parentNode.removeChild(b);this.refresh()}else if(this.rangeCount){a=this.getAllRanges();this.removeAllRanges();b=0;for(var c=a.length;b<c;++b)a[b].deleteContents();this.addRange(a[c-1])}};x.getAllRanges=function(){return this._ranges.slice(0)};x.setSingleRange=function(a){this.setRanges([a])};x.containsNode=function(a,b){for(var c=0,d=this._ranges.length;c<d;++c)if(this._ranges[c].containsNode(a,b))return!0;return!1};x.toHtml=function(){var a="";if(this.rangeCount){for(var a=
u.getRangeDocument(this._ranges[0]).createElement("div"),b=0,c=this._ranges.length;b<c;++b)a.appendChild(this._ranges[b].cloneContents());a=a.innerHTML}return a};x.getName=function(){return"WrappedSelection"};x.inspect=function(){return t(this)};x.detach=function(){this.win=this.anchorNode=this.focusNode=this.win._rangySelection=null};q.inspect=t;a.Selection=q;a.selectionPrototype=x;a.addCreateMissingNativeApiListener(function(b){if("undefined"==typeof b.getSelection)b.getSelection=function(){return a.getSelection(this)};
b=null})});J("$.dmxEditor.ui");var F=X.extend({init:function(a){this.editor=a;this.wrapper=d('<div class="dmx-editor-menu"></div>').data("dmxEditorMenu",this);M&&this.wrapper.addClass("ie").attr("unselectable","on")},addItem:function(a,b){this.wrapper.is(":empty")&&this.wrapper.append('<ul class="dmx-editor-menu-items"></ul>');this.wrapper.find("> ul")[b?"prepend":"append"](a.wrapper);a.editor=this.editor;return a},addControl:function(a,b){var c=this.editor.getControl(a);if(c instanceof sa){for(var d=
P(c.settings.values,c),g=this.addItem(new MenuItem(c),b),f=0,i=d.length;f<i;f++)(function(a){if("-"==a)g.addSeparator();else{var b="string"==typeof a?a:a.value;g.addItem(new MenuItem({label:b,execute:function(){c.command.execute(b)}}))}})(d[f]);return g}return c instanceof U?this.addItem(new DialogMenuItem(c),b):this.addItem(new MenuItem(c),b)},addSeparator:function(a){return this.addItem(new MenuSeparator,a)},isEmpty:function(){return this.wrapper.is(":empty")},empty:function(){this.wrapper.empty()}});
d.dmxEditor.ui.Menu=F;d.dmxEditor.ui.hideMenus=function(){d(".dmx-menu").each(function(){var a=d(this).data("settings");if(a&&d.isFunction(a.onHide))a.onHide()});d("#dmx-editor-dialog-contextmenu").remove();d(".dmx-menu,#dmx-editor-overlay").remove();document.removeEventListener&&document.removeEventListener("mousedown",na,!0)};d.dmxEditor.ui.createMenu=function(a){if(a&&a.data){var b=d('<div class="dmx-menu"></div>').appendTo("body").bind("mousedown",ya).bind("repositionmenu",Ea).css({position:"absolute",
width:"auto"}).data("settings",a);if(d.isFunction(a.data))a.data=a.data();("string"===typeof a.data||a.data.jquery)&&b.append(a.data);Ea();document.addEventListener&&document.addEventListener("mousedown",na,!0)}};J("$.dmxEditor.ui");var Na=X.extend({init:function(a,b,c){this.id=a;this.editor=b;this.settings=c;this.selector="div.dmx-editor-toolbar[data-id='"+a+"']";this.visible=!0;this.config()},config:function(a){d.extend(!0,this.settings,a||{});if(!d.isArray(this.settings.items)){var a=[],b;for(b in this.settings.items)this.settings.items[b]&&
(0==b.indexOf("-")&&(b="-"),a.push(b));this.settings.items=a}},getHtml:function(){for(var a="",b=this.settings.items,c=0,d=b.length;c<d;c++)b[c]in this.editor.controls?a+=this.editor.controls[b[c]].getHtml():A("["+this.editor.id+"] Control '"+b[c]+"' doesn't exists in editor");return'<div data-id="'+this.id+'" class="dmx-editor-toolbar"><div class="dmx-editor-toolbar-start"></div>'+a+'<div class="dmx-editor-toolbar-end"></div></div>'},addControl:function(a,b){this.settings.items.splice(b,0,a)},insertControlBefore:function(a,
b){for(var c=this.settings.items,d=0;d<c.length;d++)if(c[d]==b){this.addControl(a,d);return}c.push(a)},insertControlAfter:function(a,b){for(var c=this.settings.items,d=0;d<c.length;d++)if(c[d]==b){this.addControl(a,d+1);return}c.push(a)},update:function(){var a=this.settings,b=a.items;this.visible=d.isFunction(a.visible)?a.visible(this.editor):a.visible;this.editor.wrapper.find(this.selector).toggle(this.visible);if(this.visible&&this.editor.controls)for(a=0;a<b.length;a++)b[a]in this.editor.controls&&
this.editor.controls[b[a]].update()}});d.dmxEditor.ui.Toolbar=Na;J("$.dmxEditor.ui");F=X.extend({init:function(a,b){if(a){if(this.id=a,this.editor=b&&b.editor,this.settings=b,this.selector=".dmx-editor-control[data-id='"+this.id+"']",this.classPrefix="dmx-editor-",this.active=this.disabled=!1,this.command=b&&b.command,"string"===typeof this.command)this.command=this.editor.getCommand(this.command)}else A("Control with no ID")},setActive:function(a){d(this.selector,this.editor.wrapper).toggleClass("dmx-editor-active",
a);this.active=a},isActive:function(){return this.active},setDisabled:function(a){d(this.selector,this.editor.wrapper).toggleClass("dmx-editor-disabled",a);this.disabled=a},isDisabled:function(){return this.disabled},getHtml:function(){return'<span data-id="'+this.id+'" class="dmx-editor-control"></span>'},update:function(){var a=this.command;a&&a.queryState&&a.queryEnabled&&(this.setDisabled(!a.queryEnabled()),this.isDisabled()?this.setActive(!1):this.setActive(a.queryState()))},onClick:function(){var a=
this,b=this.command;this.isDisabled()||(b&&b.execute&&this.editor.execute(b.id),this.settings.execute&&this.settings.execute(),setTimeout(function(){a.editor.refreshSelection();a.editor.updateControls()},0))}});d.dmxEditor.ui.Control=F;J("$.dmxEditor.ui");var fb=F.extend({init:function(a,b){this._super(a,b)},getHtml:function(){return'<div class="'+this.classPrefix+'separator"></div>'},update:d.noop});d.dmxEditor.ui.Separator=fb;J("$.dmxEditor.ui");F=F.extend({init:function(a,b){this._super(a,b)},
getHtml:function(){var a=this.classPrefix,b=this.settings,c='<span data-id="'+this.id+'" class="'+a+"control "+a+'button"';b.tooltip&&(c+=' title="'+this.editor.translate(b.tooltip)+'"');c+=">";if(b.icon)var e=d.isFunction(b.icon)?b.icon(this.editor):b.icon,c=-1!=e.indexOf("://")?c+('<div style="background-image:url('+e+');"  class="'+a+'icon"></div>'):c+('<div class="'+a+"icon "+a+"icon-"+e+'"></div>');b.label&&(c+='<span class="'+a+'label">'+this.editor.translate(b.label)+"</span>");return c+"</span>"}});
d.dmxEditor.ui.Button=F;J("$.dmxEditor.ui");var U=F.extend({init:function(a,b){b.position=b.position||"down";this._super(a,b);var c=this,e=this.settings;this.dialog=new R(this.id,this.editor,d.extend({parent:this.selector,onSuccess:function(){var a=c.command;a&&a.execute&&a.execute(this.value||this.data);e.execute&&e.execute.call(this,this.value||this.data)},onClose:function(){c.setActive(!1)}},e))},getHtml:function(){var a=this.classPrefix,b=this.settings,c='<span data-id="'+this.id+'" class="'+
a+"control "+a+'button"';b.tooltip&&(c+=' title="'+this.editor.translate(b.tooltip)+'"');c+=">";"left"==b.position&&(c+='<span class="'+a+'dropdown">&#9668;</span>');if(b.icon)var e=d.isFunction(b.icon)?b.icon(this.editor):b.icon,c=-1!=e.indexOf("://")?c+('<div style="background-image:url('+e+');"  class="'+a+'icon"></div>'):c+('<div class="'+a+"icon "+a+"icon-"+e+'"></div>');b.label&&(c+='<span class="'+a+'label">'+this.editor.translate(b.label)+"</span>");"right"==b.position?c+='<span class="'+
a+'dropdown">&#9658;</span>':"left"!=b.position&&"right"!=b.position&&"center"!=b.position&&(/* START BIZAMAJIG Customization - Removing DownArrow because float: left; is not working properly, causing icons to grow vertically adding a scrollbar to the content by mistake; c+='<span class="'+
a+'dropdown">&#9660;</span>' */c+=''/* END BIZAMAJIG Customization*/);return c+"</span>"},update:function(){d.isFunction(this.settings.disable)?this.setDisabled(this.settings.disable.apply(this)):this.command&&this.setDisabled(!this.command.queryEnabled())},openDialog:function(){this.setActive(!0);if(this.command){var a=this.command.queryValue();d.isPlainObject(a)?this.dialog.data=a:this.dialog.value=a}this.settings.url?this.dialog.open(d.isFunction(this.settings.url)?
this.settings.url(this.editor):this.settings.url):this.dialog.create(d.isFunction(this.getDialog)?this.getDialog():"No dialog")},onClick:function(){if(this.isDisabled()||this.isActive())return!1;this.openDialog()}});d.dmxEditor.ui.DialogButton=U;J("$.dmxEditor.ui");F=U.extend({init:function(a,b){this.type="web";this.value="";this._super(a,b)},getHtml:function(){var a=this.classPrefix,b=this.settings,c='<span data-id="'+this.id+'" class="'+a+"control "+a+'button"';b.tooltip&&(c+=' title="'+this.editor.translate(b.tooltip)+
'"');c+='><div class="'+a+"icon "+a+"icon-"+b.icon+'"></div>';b.label&&(c+='<span class="'+a+'label">'+this.editor.translate(b.label)+"</span>");return c+/* START BIZAMAJIG Customization ('<span class="'+a+'dropdown">&#9660;</span>')+ */"</span>"/* END BIZAMAJIG Customization */},setValue:function(a){this.value=a},update:function(){this.command&&(this.setDisabled(!this.command.queryEnabled()),this.setValue(this.command.queryValue()))},getDialog:function(){var a=this,b=d('<div class="menu-items-wrapper"></div>');d(this.editor.wrapper).find(this.selector);b.append(d('<div class="picker"></div>').dmxColorPicker({type:this.type,
color:this.value})).prepend(d('<div style="padding: 0 0 22px 0; vertical-align:top;"><input type="text" style="width:40px;height:16px;float:left;border:1px solid #000;margin:0 -1px 0 0" class="color-preview" disabled="disabled"/><input type="text" style="width:90px;height:16px;float:left;border:1px solid #000;margin:0 2px" class="color-hex-preview" spellcheck="false" unselectable="off"/></div>').append(d('<span class="dmx-editor-control dmx-editor-button" style="float:left;" title="'+this.editor.translate("Clear Color")+
'"><div class="dmx-editor-icon dmx-editor-icon-no-color" style="float:left;"/></span>').click(function(){a.dialog.value="clear";a.dialog.close(!0)})));b.bind("colorPreview",function(b,e){var g=e.getString(a.editor.storage.useColorCode[a.type]||"hex");d(".color-preview",this).css("backgroundColor",g);d(".color-hex-preview",this).val(e.getName()||g)}).bind("colorSelect",function(b,d){a.dialog.value=d.getString("hex");a.dialog.close(!0)});return b}});d.dmxEditor.ui.ColorButton=F;J("$.dmxEditor.ui");
var sa=U.extend({init:function(a,b){this._super(a,b);var c=this;this.value="";if(this.command)this.value=this.command.queryValue();this.dialog=new R(this.id,this.editor,{dialog:"select",parent:this.selector,minWidth:function(){return parseInt(d(c.selector,c.editor.wrapper).width(),10)||10},onSuccess:function(){var a=c.command;a&&a.execute&&this.editor.execute(a.id,this.value);b.execute&&b.execute.call(c,this.value)},onShow:function(){this.dialog.find("li[data-value]").click(function(){c.dialog.value=
d(this).data("value");c.dialog.close(!0)})},onClose:function(){c.setActive(!1)}})},getHtml:function(){var a=this.classPrefix,b=this.settings,c='<span data-id="'+this.id+'" class="'+a+"control "+a+'select"';b.tooltip&&(c+=' title="'+this.editor.translate(b.tooltip)+'"');c+=">";if(b.icon)var e=d.isFunction(b.icon)?b.icon(this.editor):b.icon,c=-1!=e.indexOf("://")?c+('<div style="background-image:url('+e+');"  class="'+a+'icon"></div>'):c+('<div class="'+a+"icon "+a+"icon-"+e+'"></div>');e="";b.width&&
(e=' style="width:'+b.width+'"');c=b.editable?c+('<input class="'+a+'label"'+e+' value="'+this.value+'" />'):c+('<span class="'+a+'label"'+e+">"+ca(this.value)+"</span>");return c+/* START BIZAMAJIG Customization ('<span class="'+a+'dropdown">&#9660;</span>')+ */"</span>"/* END BIZAMAJIG Customization */},getDialog:function(){var a=this.settings,b="",c=[],c=d.isFunction(a.values)?a.values():a.values,e=d(this.editor.selectedElement,this.editor.frame).parents().andSelf().map(function(){return this.tagName.toLowerCase()}).get();if(d.isArray(c)){b+='<ul class="dmx-editor-select-menu">';
for(a=0;a<c.length;a++){var g=c[a];"string"==typeof g?b="-"==g?b+'<li class="dmx-editor-select-separator"></li>':b+('<li data-value="'+g+'" class="dmx-editor-select-item">'+this.editor.translate(g)+"</span></li>"):g.tag?-1<d.inArray(g.tag.toLowerCase(),e)&&(b+='<li data-value="'+g.tag+"."+g.value+'" class="dmx-editor-select-item"'+(g.style?' style="'+g.style+'"':"")+">"+this.editor.translate(g.label)+"</li>"):b+='<li data-value="'+g.value+'" class="dmx-editor-select-item"'+(g.style?' style="'+g.style+
'"':"")+">"+this.editor.translate(g.label)+"</li>"}}else{var b=b+'<ul class="dmx-editor-select-menu">',f;for(f in c){b+='<li class="dmx-editor-select-group">'+f+"</li>";e=c[f];for(a=0;a<e.length;a++)g=e[a],b="string"==typeof g?"-"==g?b+'<li class="dmx-editor-select-separator"></li>':b+('<li data-value="'+g+'" class="dmx-editor-select-item">'+this.editor.translate(g)+"</li>"):b+('<li data-value="'+g.value+'" class="dmx-editor-select-item"'+(g.style?' style="'+g.style+'"':"")+">"+this.editor.translate(g.label)+
"</li>")}}return b+"</ul>"},update:function(){var a=this.settings;d.isFunction(a.disable)?this.setDisabled(a.disable.apply(this)):this.command&&this.setDisabled(!this.command.queryEnabled());if(this.command){var b=this.command.queryValue(),a=d.isFunction(a.values)?a.values():a.values;if(d.isArray(a))for(var c=0;c<a.length;c++)if(a[c].value&&b.toLowerCase()==a[c].value.toLowerCase()){b=this.editor.translate(a[c].label);break}this.value=b||""}d(this.selector,this.editor.wrapper).find("."+this.classPrefix+
"label").attr("title",this.value).text(this.value)}});d.dmxEditor.ui.Select=sa;J("$.dmxEditor.ui");F=U.extend({init:function(a,b){this._super(a,b);var c=this;this.value=[];if(this.command)this.value=this.command.queryValue();this.dialog=new R(this.id,this.editor,{dialog:"select",parent:this.selector,minWidth:function(){return parseInt(d(c.selector,c.editor.wrapper).width(),10)||10},onShow:function(){this.dialog.find("input").each(function(){for(var a=0;a<c.value.length;a++){var b=c.value[a],d=c.value[a].split(".")[1];
if(this.value==b||this.value==d)this.checked=!0}}).change(function(){var a=c.command;a&&a.execute&&c.editor.execute(a.id,{value:this.value,checked:this.checked});b.execute&&b.execute.call(c,{value:this.value,checked:this.checked})})},onClose:function(){c.setActive(!1)}})},getHtml:function(){var a=this.classPrefix,b=this.settings,c='<span data-id="'+this.id+'" class="'+a+"control "+a+'select"';b.tooltip&&(c+=' title="'+this.editor.translate(b.tooltip)+'"');c+=">";if(b.icon)var e=d.isFunction(b.icon)?
b.icon(this.editor):b.icon,c=-1!=e.indexOf("://")?c+('<div style="background-image:url('+e+');"  class="'+a+'icon"></div>'):c+('<div class="'+a+"icon "+a+"icon-"+e+'"></div>');e="";b.width&&(e=' style="width:'+b.width+'"');c=b.editable?c+('<input class="'+a+'label"'+e+' value="'+this.value.join(", ")+'" />'):c+('<span class="'+a+'label"'+e+">"+ca(this.value.join(", "))+"</span>");return c+/* START BIZAMAJIG Customization ('<span class="'+a+'dropdown">&#9660;</span>')+ */"</span>"/* END BIZAMAJIG Customization */},getDialog:function(){var a=this.settings,b="",c=[],
c=d.isFunction(a.values)?a.values():a.values,a=d(this.editor.selectedElement,this.editor.frame).parents().andSelf().map(function(){return this.tagName.toUpperCase()}).get();if(d.isArray(c))for(var b=b+'<ul class="dmx-editor-select-menu">',e=0;e<c.length;e++){var g=c[e];"string"==typeof g?"-"==g?b+='<li class="dmx-editor-select-separator"></li>':(b+='<li class="dmx-editor-select-item">',b+='<label><input type="checkbox" value="'+g+'" />',b+=this.editor.translate(g)+"</label></li>"):g.tag&&-1<d.inArray(g.tag,
a)?(b+='<li class="dmx-editor-select-item"'+(g.style?' style="'+g.style+'"':"")+">",b+='<label><input type="checkbox" value="'+g.tag+"."+g.value+'" />',b+=this.editor.translate(g.label)+"</label></li>"):g.tag||(b+='<li class="dmx-editor-select-item"'+(g.style?' style="'+g.style+'"':"")+">",b+='<label><input type="checkbox" value="'+g.value+'" />',b+=this.editor.translate(g.label)+"</label></li>")}else{var b=b+'<ul class="dmx-editor-select-menu">',f;for(f in c)if("General"==f&&this.editor.getBlockNode()||
-1<d.inArray(f,a))for(var b=b+('<li class="dmx-editor-select-group">'+f+"</li>"),i=c[f],e=0;e<i.length;e++)g=i[e],"string"==typeof g?"-"==g?b+='<li class="dmx-editor-select-separator"></li>':(b+='<li class="dmx-editor-select-item">',b+='<label><input type="checkbox" value="'+g+'" />',b+=this.editor.translate(g)+"</label></li>"):(g.tag&&"*"!=g.tag?(b+='<li class="dmx-editor-select-item"'+(g.style?' style="'+g.style+'"':"")+">",b+='<label><input type="checkbox" value="'+g.tag+"."+g.value+'" />'):(b+=
'<li class="dmx-editor-select-item"'+(g.style?' style="'+g.style+'"':"")+">",b+='<label><input type="checkbox" value="'+g.value+'" />'),b+=this.editor.translate(g.label)+"</label></li>")}return b+"</ul>"},update:function(){var a=this.settings;d.isFunction(a.disable)?this.setDisabled(a.disable.apply(this)):this.command&&this.setDisabled(!this.command.queryEnabled());if(this.command){var b=this.command.queryValue(),a=d.isFunction(a.values)?a.values():a.values;if(d.isArray(a))for(var c=0;c<a.length&&
!(a[c].value&&-1<$inArray(a[c].value.toLowerCase(),b));c++);this.value=b||[]}b=this.value.join(", ");d(this.selector,this.editor.wrapper).find("."+this.classPrefix+"label").attr("title",b).text(b)}});d.dmxEditor.ui.MultiSelect=F;R.cache={};R.init=null;R.prototype={open:function(a,b){-1==a.indexOf("://")&&(a=d.dmxEditor.basePath+"dmxEditor/"+a);if(this.options.cache&&a in d.dmxEditor.Dialog.cache)this.create(d.dmxEditor.Dialog.cache[a],b);else{var c=this;this.url=a;d.ajax({url:a,dataType:"html",success:function(e){d.dmxEditor.Dialog.cache[a]=
e;c.create(e,b)},error:function(a,b,c){O(b,c)}})}},close:function(a){var b=this.options;this.parent.unbind(".dialog").css("z-index","");this.success=!!a;this.getData();d.isFunction(b.onClose)&&!1===b.onClose.call(this)?this.success=!1:(this.options.retFocus&&this.editor.focus(),a&&d.isFunction(b.onSuccess)&&b.onSuccess.call(this),this.unbindEvents(),this.dialog.remove(),0===d("."+this.cls).length&&d.dmxEditor.removeOverlay())},create:function(a,b){var c=this.options,e;"none"!=c.position?(this.overlay=
d.dmxEditor.createOverlay(c.darken),e=parseFloat(this.overlay.css("z-index"))||1E6):xIndex=1;d.dmxEditor.Dialog.init=null;window.DMXAjaxDialog={init:null};this.success=!1;if(d.isPlainObject(b))this.data=b;this.parent="string"==typeof c.parent?d(c.parent,this.editor.wrapper):d(c.parent);d("#"+this.id).remove();this.dialog=d('<div id="'+this.id+'" tabindex="0" class="'+this.cls+'" style="z-index:'+(e+1)+";min-width:"+(d.isFunction(c.minWidth)?c.minWidth():c.minWidth)+"px;min-height:"+(d.isFunction(c.minHeight)?
c.minWidth():c.minWidth)+'px;"></div>').data("dialog",this).appendTo(c.container);"string"==typeof a?(this.url&&(e=this.url.split("?")[0],a=a.replace(/\$\{url\}/g,e.substring(0,e.lastIndexOf("/")+1))),this.dialog.html(this.editor.translateHtml(a))):this.dialog.append(d(a));"default"!==this.editor.options.skin&&this.dialog.addClass(this.editor.options.skin);this.setData();if(d.isFunction(DMXAjaxDialog.init))try{DMXAjaxDialog.init.call(this,this.editor)}catch(g){O(g)}if(d.isFunction(d.dmxEditor.Dialog.init))try{d.dmxEditor.Dialog.init.call(this)}catch(f){O(f)}this.bindEvents();
this.reposition();e=this.dialog.find(":input:first");0!=e.length?e.focus():this.dialog.focus();d.isFunction(c.onShow)&&c.onShow.call(this)},getData:function(){function a(a,b,c){var e;for(var d,b=b.split(".");b[1];)d=b.shift(),e=a[d]=a[d]||{},a=e;a[b.shift()]=c}var b=this,c;this.dialog.find("input,textarea,select").each(function(){if(this.name&&!this.disabled){c=null;if("input"==this.nodeName.toLowerCase())switch(this.getAttribute("type")){case "checkbox":var e=b.dialog.find('input[name="'+this.name+
'"]');1==e.length?c=!!this.checked:(c=[],e.filter(":checked").each(function(){c.push(this.value)}),0==c.length&&(c=null));break;case "number":c=this.value-0||null;break;case "radio":c=b.dialog.find('input["'+this.name+'"]:checked').val()||null;break;default:c=d(this).val()||null}else c=d(this).val()||null;a(b.data,this.name,c)}})},setData:function(){function a(a){for(var c,f=d.extend({},b.data),a=a.split(".");a[0];){c=a.shift();if(null==f[c])return null;f=f[c]}return f}var b=this,c;this.dialog.find("input,textarea,select").each(function(){if(this.name&&
(c=a(this.name),null!=c))c instanceof Array?"select"==this.nodeName.toLowerCase()?d(this).val():b.dialog.find('input["'+this.name+'"]').each(function(){this.checked=-1!=d.inArray(this.value,c)}):"checkbox"==this.type?this.checked="boolean"==typeof c?c:c==this.value:d(this).val(c)})},bindEvents:function(){var a=this,b=this.options;this.overlay&&this.overlay.bind("mousedown."+this.id,function(c){c.preventDefault();b.modal||a.close(!1)});this.dialog.find(".dmx-editor-OK").bind("click",function(){a.close(!0)});
this.dialog.find(".dmx-editor-CANCEL").bind("click",function(){a.close(!1)});"center"!==b.position&&d(window).bind("resize."+this.id,function(){a.reposition()});this.dialog.bind("keypress."+this.id,function(b){27===b.keyCode?a.close(!1):13===b.keyCode&&"textarea"!=b.target.nodeName.toLowerCase()&&a.close(!0)})},unbindEvents:function(){this.overlay&&this.overlay.unbind("."+this.id);d(window).unbind("."+this.id)},reposition:function(){var a=this.options,b=a.parent.jQuery?a.parent:d(a.parent,this.editor.wrapper),
c=b.offset(),e=this.dialog.outerWidth(),g=this.dialog.outerHeight(),f=d(window).width();d(window).height();switch(a.position){case "none":this.dialog.css({position:"relative",left:0,top:0});break;case "center":this.dialog.css({position:"fixed",left:"50%",top:"50%",marginLeft:"-"+e/2+"px",marginTop:"-"+g/2+"px"});break;case "left":this.dialog.css({left:c.left-e,top:c.top});break;case "right":this.dialog.css({left:c.left+b.outerWidth(),top:c.top});break;case "down-r":a=c.left+b.outerWidth()-e;this.dialog.css({left:0>
a?0:a,top:c.top+b.outerHeight()});break;default:this.dialog.css({left:c.left+e>f?f-e:c.left,top:c.top+b.outerHeight()})}}};d.dmxEditor.Dialog=R;d.dmxEditor.createOverlay=function(a){d.dmxEditor.removeOverlay();var b=d('<div id="dmx-editor-overlay"></div>').appendTo("body");a&&b.addClass("dmx-editor-darken");return b};d.dmxEditor.removeOverlay=function(){d("#dmx-editor-overlay").remove()};var cb=X.extend({init:function(a,b){var c=this;this.editor=a;this.tolerance=b||200;this.idle=!0;d(a.frame).bind("editor:*",
function(a,b){"editor:idle"!=b.type&&"editor:documentedited"!=b.type&&c.activity()})},enterIdle:function(){this.clearIdleTimer();if(!this.idle)this.idle=!0,this.editor.dispatch("editor:idle")},activity:function(){this.clearIdleTimer();if(this.idle)this.idle=!1;this.idleTimer=window.setTimeout(L(this,this.enterIdle),this.tolerance)},clearIdleTimer:function(){this.idleTimer&&(window.clearTimeout(this.idleTimer),delete this.idleTimer)},destruct:function(){this.clearIdleTimer()}});d.extend(d.dmxEditor.prototype,
{tokenize:function(a,b){var c=this;if(!this.tokens)this.tokens=[];return a.replace(b,function(a){c.tokens.push(a);return"_dmxEditorToken_"+c.tokens.length+"_dmx_"})},unTokenize:function(a){var b=this;if(this.tokens)a=a.replace(/_dmxEditorToken_(\d+)_dmx_(?:="")?/gi,function(a,d){return b.tokens[d-1]||""}),this.tokens=null;return a}});var bb=X.extend({init:function(a){this.editor=a;this.items=[];this.position=-1;this.limit=a.options.historyLimit},notify:function(a){"saveUndoPoint"!=a&&(this.editor.stopModificationsMonitoring(),
this.editor.setHTML(this.items[this.position].content),this.editor.startModificationsMonitoring());this.editor.dispatch("editor:historychange",this,this.items,this.position)},saveUndoPoint:function(a,b){var c=this.limit,d=this.items.length;0<c&&d>=c&&this.items.splice(1,d-c);this.position=this.items.push({content:a,name:b||"Unknown command"})-1;this.notify("saveUndoPoint");return this.position},undo:function(){this.canUndo()&&(this.position--,this.notify("undo"));return this.position},redo:function(){this.canRedo()&&
(this.position++,this.notify("redo"));return this.position},moveTo:function(a){this.position=a;this.notify("moveTo");return this.position},canUndo:function(){return 0<this.position},canRedo:function(){return this.position<this.items.length-1},getLength:function(){return this.items.length},clear:function(){if(0<this.items.length){for(this.position=this.items.length;--this.position;)items.splice(this.position,1);notify("clear")}},getAll:function(){return this.items},setLimit:function(a){this.limit=
a}});d.extend(d.dmxEditor.prototype,{focus:function(){this.getWindow().focus()},resizeUI:function(){this.wrapper.hasClass("fullscreen")&&(this.wrapper.width(d(window).width()),this.wrapper.height(d(window).height()));var a=this.wrapper.find(".dmx-editor-frame-wrapper"),b=this.wrapper.parents(":hidden").filter(function(){return"none"==d(this).css("display")}),c=0;b.show();a.siblings(":visible").each(function(){"absolute"!=d(this).css("position")&&(c+=d(this).outerHeight())});b.hide();Y?a.height(this.wrapper.height()-
18-c):a.height(this.wrapper.height()-2-c)},resizeTo:function(a,b){a&&this.wrapper.width(a);b&&this.wrapper.height(b);this.resizeUI()},resizeBy:function(a,b){this.resizeTo(this.wrapper.width()+a,this.wrapper.height()+b)},resizeWith:function(a,b){this.resizeTo(this.wrapper.width()+a,this.wrapper.height()+b)},setSkin:function(a){var b=this,c=d("link[href*='dmxEditor.css']"),e=d.dmxEditor.basePath,g=e+"../styles/dmxEditor/";0<c.length&&(g=c[0].href.replace(/dmxEditor.css$/i,"dmxEditor/"));d("link[href*='"+
g+"']").each(function(){b.wrapper.removeClass(this.href.match(/\/([^\/\.]*)\.css$/i)[1])});"string"!=typeof a||""===a||"default"===a||require([e+"css.js!"+g+a+"/"+a+".css"],function(){b.wrapper.addClass(a);b.resizeUI();b.options.skin=a})},setIconSet:function(a){var b=this,c=d.dmxEditor.basePath,e=c+"dmxEditor/iconsets/";this.wrapper.removeClass(function(a,b){for(var c=b.split(" "),d=[],e=0;e<c.length;e++)/^dmx-editor-iconset-/.test(c[e])&&d.push(c[e]);return d.join(" ")});"string"!=typeof a||"default"===
a||require([c+"css.js!"+e+a+"/"+a+".css"],function(){b.wrapper.addClass("dmx-editor-iconset-"+a);b.resizeUI();b.options.iconSet=a})},toggleFullscreen:function(a){var b=this.getBody(),c=this,e=this.wrapper;this.toggleFullscreen.oldDim=this.toggleFullscreen.oldDim||{};if(ea)this.frame.blur(),b.contentEditable=!1,b.removeAttribute("contenteditable");if(!e.hasClass("fullscreen"))this.toggleFullscreen.oldDim.width=e.width(),this.toggleFullscreen.oldDim.height=e.height();a?(e.css({width:"",height:""}).addClass("fullscreen"),
d(window).bind("resize.fullscreeneditor",function(){c.resizeUI()}).triggerHandler("resize.fullscreeneditor")):(d(window).unbind("resize.fullscreeneditor"),e.removeClass("fullscreen"),this.resizeTo(this.toggleFullscreen.oldDim.width,this.toggleFullscreen.oldDim.height));this.dispatch(a?"enterfullscreen":"leavefullscreen");if(ea)try{b.setAttribute("contenteditable","true"),b.contentEditable=!0}catch(g){}this.focus()},createToolbars:function(){var a=this;this.wrapper.find(".dmx-editor-toolbars").empty();
for(var b=this.options.toolbarsOrder,c,e={},g=0;g<b.length;g++)c=b[g],this.options.toolbars[c].enabled&&(e[c]=1,this.reloadToolbar(c,this.options.toolbars[c]));for(c in this.options.toolbars)!e[c]&&this.options.toolbars[c].enabled&&(e[c]=g++,this.reloadToolbar(c,this.options.toolbars[c]));new Xa(this.wrapper.find(".dmx-editor-toolbars")[0]);this.wrapper.find(".dmx-editor-toolbars").unbind("click.editor").bind("click.editor",function(b){var c=d(b.target).closest(".dmx-editor-control").data("id");c&&
(c=a.controls[c],c.onClick.call(c,b))});this.refreshToolbars()},reloadToolbar:function(a,b){var c=this.getToolbar(a);c&&(b&&c.config(b),$tb=this.wrapper.find(c.selector),0<$tb.length?$tb.replaceWith(c.getHtml()):this.wrapper.find(".dmx-editor-toolbars").append(c.getHtml()),c.update())},reloadAllToolbars:function(){var a=this;this.wrapper.find(".dmx-editor-toolbar").each(function(){a.reloadToolbar(d(this).data("id"))})},getToolbar:function(a){return this.Toolbars[a]||this.addToolbar(a)},addToolbar:function(a){a=
this.Toolbars[a]=new Na(a,this,{visible:!0,items:[]});this.wrapper.find(".dmx-editor-toolbars").append(a.getHtml());return a},refreshToolbars:function(){for(var a in this.Toolbars)this.Toolbars[a].update();this.resizeUI()},getView:function(){return this.currentView},getIconPath:function(a){return d.dmxEditor.basePath+"dmxEditor/iconsets/"+this.options.iconSet+"/"+a}});d.extend(d.dmxEditor.prototype,{initEvents:function(){var a=this;M&&d(this.frame).bind("beforedeactivate",L(this,this.saveSelection)).bind("activate beforeeditfocus",
L(this,this.restoreSelection));ea&&d(this.designview.document).bind("focus.editor",function(){var b=a.getBody().firstElementChild;if(d(b).is("p")&&"\u200b"==b.innerHTML){try{a.getSelection().collapse(b.firstChild,0)}catch(e){}a.refreshSelection()}});Y&&function(){var b=!1;d(a.designview.document).bind("touchstart",function(){b=!0}).bind("touchmove",function(){b=!1}).bind("touchend",function(d){if(b&&"IMG"==d.target.nodeName){var g=a.getDocument().createRange();g.selectNode(d.target);a.selection.setSingleRange(g);
return!1}})}();var b="selectionchange.editor";Y||(b="keyup.editor mouseup.editor");d(this.designview.document).bind(b,L(this,this.refreshSelection)).bind("contextmenu.editor",ka).bind("unload.editor blur.editor focus.editor",L(this,this.dispatch)).bind("keydown.editor",L(this,this.handleKeyDown)).bind("mouseup.editor",function(b){d("body").trigger("hidemenus");3==b.which&&setTimeout(function(){var e=d(a.frame).offset(),g=b.clientX+e.left+2,e=b.clientY+e.top,f=new DMXMenu(a),i,h=!!a.getBlockNode(!0);
a.refreshSelection();"default"!=a.options.skin&&f.wrapper.addClass(a.options.skin);"default"!=a.options.iconSet&&f.wrapper.addClass("dmx-editor-iconset-"+a.options.iconSet);if(a.getCommand("undo").queryEnabled()||a.getCommand("redo").queryEnabled())f.addControl("undo"),f.addControl("redo"),f.addSeparator();h&&(i=f.addSubMenu(a.translate("Align")),i.addControl("justifyleft"),i.addControl("justifycenter"),i.addControl("justifyfull"),i.addControl("justifyright"),a.getBlockNode(!1)&&(i.addSeparator(),
i.addControl("indent"),i.addControl("outdent")));a.hasTextSelection()&&(i=f.addSubMenu(a.translate("Toggle selection formatting")),i.addControl("bold"),i.addControl("italic"),i.addControl("underline"),i.addControl("strikethrough"),i.addControl("subscript"),i.addControl("superscript"));f.addSeparator();a.hasParentNode("TABLE",!0)&&!a.hasTextSelection()&&(f.addControl("editTable"),f.addControl("editTableCell"),f.addSeparator(),f.addControl("insertColBefore"),f.addControl("insertColAfter"),f.addControl("insertRowBefore"),
f.addControl("insertRowAfter"),f.addSeparator(),f.addControl("deleteRow"),f.addControl("deleteCol"),f.addControl("deleteTable"));f.addSeparator();(a.hasTextSelection()||a.hasParentNode("IMG",!0))&&f.addControl("addlink");a.hasParentNode("A",!0)&&f.addControl("deletelink");a.hasParentNode("IMG",!0)&&!a.getParentNode("IMG",!0).hasAttribute("data-translated")&&f.addControl("addaoreditimage");h&&(f.addSeparator(),f.addControl("formatblock"));if(!f.isEmpty()){i=new jQuery.Event("beforecontextmenu");d(b.target).trigger(i,
[f,a,b]);i.isPropagationStopped()&&!b.isPropagationStopped()&&b.stopPropagation();if(i.isImmediatePropagationStopped()&&!b.isImmediatePropagationStopped())try{b.stopImmediatePropagation()}catch(l){}if(!i.isDefaultPrevented())f.overlay=d.dmxEditor.createOverlay(),zIndex=parseFloat(f.overlay.css("z-index"))||1E6,f.wrapper.css("z-index",zIndex+1),f.wrapper.addClass("contextmenu").appendTo("body"),f.showAt(g,e)}},0)})},handleKeyDown:function(a){d(this.designview.document).unbind("keyup.preventDefault keypress.preventDefault",
ka);if(!(a.keyCode in Ja||!(a.keyCode in Ka)||a.keyCode in ab&&!a.ctrlKey&&!a.metaKey&&!a.altKey)){var b=new jQuery.Event("editor:keydown");this.dispatch(b);if(!b.isDefaultPrevented()){b="";a.shiftKey&&(b+="SHIFT+");if(a.ctrlKey||a.metaKey)b+="CTRL+";a.altKey&&(b+="ALT+");b+=Ka[a.keyCode];if(b in this.Keys){if(!0===this.Keys[b].call(this))return!0;a.preventDefault();d(this.designview.document).one("keyup.preventDefault keypress.preventDefault",ka);return!1}}}},dispatch:function(a){var b,c=Array.prototype.slice.call(arguments,
1);b="string"==typeof a?a:a.type;b=b.replace(/^(editor\:)?/,"editor:");if("editor:nodeselectionchange"==b&&!this.isValidSelectionChange(c))return!1;b=new jQuery.Event(b);d(this.frame).trigger("editor:*",b,c).trigger(b,c);"string"!=typeof a&&(b.isDefaultPrevented()&&a.preventDefault(),b.isPropagationStopped()&&a.stopPropagation(),b.isImmediatePropagationStopped()&&a.stopImmediatePropagation());return b.result},isValidSelectionChange:function(a){return a[0]&&a[0]!==this.getDocument()&&1===d(a[0]).closest("body").length?
!0:!1}});d.extend(d.dmxEditor.prototype,{insertBR:function(){var a=this.range,b=this.getDocument(),c=b.createElement("br");a.insertNode(c);a.collapseAfter(c);if(3==a.endContainer.nodeType&&a.endOffset==a.endContainer.length||1==a.endContainer.nodeType&&a.endOffset==a.endContainer.childNodes.length)b=b.createTextNode("\u200b"),a.insertNode(b);this.updateSelection()},insertBlock:function(a){var b;this.getDocument();b=this.range;b.deleteContents();var c=b.endContainer;if(3==c.nodeType)c=c.parentNode;
c.nodeName in pa&&b.collapseAfter(c);a=this.getDocument().createElement(a);b.insertNode(a);b.selectNodeContents(a);a=this.getDocument().createTextNode("\u200b");b.insertNode(a);this.updateSelection();this.refreshSelection();this.checkForDocChange()},getWindow:function(){return rangy.dom.getIframeWindow(this.frame)},getBody:function(a){return rangy.dom.getBody(a||this.getDocument())},getDocument:function(){return rangy.dom.getIframeDocument(this.frame)},getRootElement:function(){return this.getDocument().documentElement||
this.getBody()},findText:function(a,b,c){var d=this.getWindow(),g=this.getDocument(),f=!1,i=!1;if(!a)return!1;if(d.find)f=!0,i=d.find(a,b||!1,c||!1);else if(g.selection&&g.selection.createRange&&(this.editor.focus(),c=g.selection.createRange(),c.findText&&(f=!0,c.collapse(!1),i=c.findText(a,1E9,b?4:0))))c.select(),this.refreshSelection();f||A("Searching text inside iframe is not supported!");return i},getText:function(){var a=rangy.createRange(this.getDocument()),b="";a.selectNodeContents(this.getBody());
b=a.toString();a.detach();return b},getHTML:function(){return this.getBody().innerHTML},css:function(a,b){var c=this.getSelectedNode();return 1===arguments.length?d(c).css(a):d(c).css(a,b)},hasParentNode:function(a,b){return!!this.getParentNode(a,b)},getParentNode:function(a,b){var c=d(this.getSelectedNode());b||(c=c.parent());c=c.closest(a);return 0==c.length?null:c[0]},getBlockNode:function(a,b){for(var c=a?pa:Ha,d=b||this.getSelectedNode();d&&d.nodeName&&!(d.nodeName in c)&&d.parentNode;)d=d.parentNode;
return d&&d.nodeName&&d.nodeName in c?d:null},getBlockFormat:function(a){var b="Normal";try{b=this.queryCommandValue("formatblock")}catch(c){}if(!b||"Normal"==b)if(b="Normal",a=this.getBlockNode(a))return pa[a.nodeName];return b},removeBlockFormat:function(){var a=this.getBlockNode();a&&this.removeNode(a)}});d.extend(d.dmxEditor.prototype,{initSelection:function(){rangy.init();rangy.supported?(this.selection=rangy.getIframeSelection(this.frame),this.refreshSelection("init")):O("The browser doesn't support rangy to handle selections")},
checkForSelectionChange:function(){var a=this.range;if(!this.oldRange)this.oldRange=this.range;if(!a.equals(this.oldRange))this.dispatch("editor:selectionchange"),this.oldElem!==this.selectedElement&&(this.dispatch("editor:nodeselectionchange",this.selectedElement,this.oldElem),this.controlSelection&&this.dispatch("editor:controlselect",this.selectedElement,this.oldElem)),this.oldElem=this.selectedElement,this.oldRange=a},refreshSelection:function(a){if(!(a&&"keyup"==a.type)||!(a.keyCode in Ja||(32==
a.keyCode||48<=a.keyCode&&90>=a.keyCode)&&!a.altKey&&!a.ctrlKey&&!a.metaKey)){if(a&&"touchend"==a.type&&"IMG"==a.target.nodeName){var b=this.getDocument().createRange();b.selectNode(a.target);this.selection.setSingleRange(b);return!1}if(d(this.frame).is(":visible")){this.selection=rangy.getIframeSelection(this.frame);this.range=0==this.selection.rangeCount?rangy.createRange(this.getDocument()):this.selection.getRangeAt(0);var a=this.range.startContainer,b=this.range.startOffset,c=this.range.endContainer,
e=this.range.endOffset;this.controlSelection=!1;if(!this.range.collapsed&&1==a.nodeType&&a==c&&1==e-b){if(this.selectedElement=a.childNodes[b],this.selectedElement.nodeName in Ia)this.controlSelection=!0}else this.selectedElement=this.range.commonAncestorContainer;if(3==this.selectedElement.nodeType)this.selectedElement=this.selectedElement.parentNode;if(!this.selectedElement||!this.selectedElement.ownerDocument)this.selectedElement=this.getBody();this.refreshToolbars();this.prevRange=this.range}this.focus()}},
updateSelection:function(){this.selection.setSingleRange(this.range);this.refreshSelection("UPDATE")},hasTextSelection:function(){return!this.range.collapsed&&!this.controlSelection},collapseSelection:function(a){this.range.collapse(a);this.updateSelection()},saveSelection:function(){if(9!=this.getRange().commonAncestorContainer.nodeType)this.savedSelectionRange=this.getRange().cloneRange()},restoreSelection:function(){if(this.savedSelectionRange)this.range=this.savedSelectionRange,this.updateSelection(),
this.refreshSelection()},getSelectedNode:function(a){a&&this.refreshSelection("NOCACHE");return this.selectedElement},selectionIsEditable:function(a,b){var c=a||this.getRange();return!(!d.dmxEditor.nodeIsEditable(this.getSelectionStartNode(c),b)||!d.dmxEditor.nodeIsEditable(this.getSelectionEndNode(c),b))},getSelectionEndNode:function(a){var b=a||this.getRange(),a=b.endContainer,b=b.endOffset;1==a.nodeType&&a.hasChildNodes()&&(a=a.childNodes[0<b?b-1:b]);return a&&3==a.nodeType?a.parentNode:a},getSelectionStartNode:function(a){var a=
a||this.getRange(),b;b=a.startContainer;1==b.nodeType&&b.hasChildNodes()&&(b=b.childNodes[Math.min(b.childNodes.length-1,a.startOffset)]);return b&&3==b.nodeType?b.parentNode:b},getSelection:function(){this.selection.refresh();this.range=this.getRange(this.selection);return this.selection},getRange:function(a){return(a=a||this.getSelection())&&0<a.rangeCount?a.getRangeAt(0):this.createRange()},createRange:function(){return rangy.createRange(this.designview.document)},getSelectionText:function(){var a=
this.getSelection();return 0<a.rangeCount?a.getRangeAt(0).toString():""},getSelectionHTML:function(){return d("<p/>").append(this.getRange().cloneContents()).html()},getSelectionRange:function(){var a=this.getBody(),b=-1,c=-1,d=this.getSelection(),g=this.createRange();g.setStart(a,0);if(d.focusNode)g.setEnd(d.focusNode,d.focusOffset),b=g.toString().length;if(d.anchorNode)g.setEnd(d.anchorNode,d.anchorOffset),c=g.toString().length;g.detach();return[Math.min(b,c),Math.max(b,c)]},setSelectionRange:function(a,
b){function c(a){for(var a=a.childNodes,b=a.length,d=[],e=0;e<b;e++)3==a[e].nodeType?d.push(a[e]):1===a[e].nodeType&&(d=d.concat(c(a[e])));return d}var e=Math.min(a,b),g=Math.max(a,b),f=this.getBody(),i=c(f),h=this.createRange(),l=0,j=!1,k=!1,q=f;d.each(i,function(a,b){q=b;!j&&l+b.length>e&&(h.setStart(q,e-l),j=!0);!k&&l+b.length>g&&(h.setEnd(q,g-l),k=!0);if(j&&k)return!1;l+=b.length});j||h.setStart(f,0);k||h.setEnd(h.startContainer,h.startOffset);f=this.getSelection();f.removeAllRanges();f.addRange(h)}});
var K=d.dmxEditor.Locale={languages:{en:{}},translate:function(a,b){return b&&this.languages[b]&&this.languages[b][a]?this.languages[b][a]:a in this.languages.en?this.languages.en[a]:a},translateString:function(a,b){return a.replace(/@\{([^\}]*)\}/g,function(a,d){return K.translate(d,b)})},translateHtml:function(a,b){return a.replace(/@\{([^\}]*)\}/g,function(a,d){return ca(K.translate(d,b))})},detectLanguage:function(){return(navigator.language||navigator.userLanguage).toLowerCase().split("-")[0]},
setLanguage:function(a,b){a.options.locale=b;d.each(a.Commands,function(a,d){d.notifyLocaleChange(b);d.locale=b;d.update()});a.ready&&(a.reloadAllToolbars(),a.dispatch("editor:localChange",b))}};d.dmxEditor.locales=K.languages;d.extend(d.dmxEditor.prototype,{translate:function(a,b){return K.translate(a,b||this.options.locale)},translateString:function(a,b){return K.translateString(a,b||this.options.locale)},translateHtml:function(a,b){return K.translateHtml(a,b||this.options.locale)},setLocale:function(a){var b=
this;require([d.dmxEditor.basePath+"dmxEditor/translations/en.js"]);"auto"==a&&(a=K.detectLanguage());a in K.languages?K.setLanguage(this,a):require([d.dmxEditor.basePath+"dmxEditor/translations/"+a+".js"],function(){K.setLanguage(b,a)})},registerTranslations:function(a){d.each(a,function(a,c){d.dmxEditor.locales[a]=d.dmxEditor.locales[a]||{};d.extend(d.dmxEditor.locales[a],c)})}});(function(a){a.extend(a.dmxEditor.prototype,{loadExtension:function(b,c,d){var g=this;a.isArray(b)||(b=[b]);for(var f=
0,i=b.length;f<i;f++)b[f]=b[f]+"/"+b[f];require({baseUrl:a.dmxEditor.basePath+"dmxEditor/extensions/"},b,function(){for(var b=0;b<arguments.length;b++){var f=arguments[b],i=f.dep||[];a.isArray(i)||(i=[i]);for(var k=0;k<i.length;k++){var q;g.extensions[i[k]]?q=g.extensions[i[k]]:(q=require(i[k]+"/"+i[k]),g.registerExtension(q));f[i[k]]=q}f.editor=g;f.env=a.extend({},qa,{__DIR__:a.dmxEditor.basePath+"dmxEditor/extensions/"+f.id+"/"});g.registerExtension(f)}c.call(d||g)})},registerExtension:function(b){b.translation&&
this.registerTranslations(b.translation);b.commands&&this.registerCommands(b.commands);b.toolbars&&this.registerToolbars(b.toolbars);b.translators&&this.registerTranslators(b.translators);b.locale&&this.registerTranslations(b.locale);b.controls&&this.registerControls(b.controls);this.extensions[b.id]=b;b.extLang&&(va(a.dmxEditor.basePath+"dmxEditor/extensions/"+b.id+"/en.js"),"en"!=this.options.locale&&va(a.dmxEditor.basePath+"dmxEditor/extensions/"+b.id+"/"+this.options.locale+".js"));if(a.isFunction(b.init))try{b.init(this,
a.extend({},qa,{__DIR__:a.dmxEditor.basePath+"dmxEditor/extensions/"+b.id+"/"}))}catch(c){O(c)}},registerCommands:function(a){for(var c in a)this.addCommand(c,a[c])},registerControls:function(a){for(var c in a)this.addControl(c,a[c])},registerToolbars:function(b){a.isArray(b)||(b=[b]);for(var c=0,d=b.length;c<d;c++){var g=b[c];g.id&&(this.options.toolbars[g.id]=a.extend(this.options.toolbars[g.id]||{},g),this.reloadToolbar(g.id))}},registerTranslators:function(b){a.isArray(b)||(b=[b]);for(var c=a(this.frame),
d,g=0,f=b.length;g<f;g++)d=b[g],a.isFunction(d.htmlToCode)&&c.bind("editor:untranslate",function(a,b){b.inStr=d.htmlToCode(b.inStr,b.editor)}),a.isFunction(d.codeToHtml)&&c.bind("editor:translate",function(a,b){b.inStr=d.codeToHtml(b.inStr,b.editor)})}})})(jQuery);J("$.dmxEditor");var ua=X.extend({init:function(a,b,c){this.id=a;this.editor=b;c&&d.extend(this,c)},queryEnabled:function(){return"design"!=this.editor.currentView?!1:!0},queryState:xa,queryValue:xa,execute:d.noop});d.dmxEditor.Command=
ua;var Oa=ua.extend({init:function(a,b,c){this._super(a,b,c)},queryEnabled:function(){if("design"!=this.editor.currentView)return!1;try{return this.editor.getDocument().queryCommandEnabled(this.id)}catch(a){return!0}},queryState:function(){if("design"!=this.editor.currentView)return!1;try{return this.editor.getDocument().queryCommandState(this.id)}catch(a){return!1}},queryValue:function(){if("design"!=this.editor.currentView)return null;try{return this.editor.getDocument().queryCommandValue(this.id)}catch(a){return null}},
execute:function(a){if("design"!=this.editor.currentView)return!1;if(ea)try{this.editor.getDocument().execCommand("styleWithCSS",!1,null),this.editor.getDocument().execCommand("useCSS",!1,null)}catch(b){}try{this.editor.getDocument().execCommand(this.id,!1,a||null)}catch(c){A("Error executing "+this.id)}this.editor.refreshSelection()}});d.dmxEditor.NativeCommand=Oa;d.extend(d.dmxEditor.prototype,{initCommands:function(){this.commands=this.commands||{};for(var a in d.dmxEditor.commands)this.addCommand(a,
d.dmxEditor.commands[a])},addCommand:function(a,b){a=a.toLowerCase();this.commands[a]=b.isNative?new Oa(a,this,b):new ua(a,this,b)},execCommand:function(a,b,c){a=a.toLowerCase();return this.queryCommandSupported(a)&&this.queryCommandEnabled?(this.commands[a].execute(c),this.checkForDocChange(),!0):!1},getCommand:function(a){return this.commands[a.toLowerCase()]},execute:function(a,b){a=a.toLowerCase();a in this.commands&&this.commands[a].queryEnabled()&&!1!==this.commands[a].execute(b)&&this.checkForDocChange()},
queryCommandAvailable:function(a){a=a.toLowerCase();return a in this.commands},queryCommandEnabled:function(a){a=a.toLowerCase();return!this.queryCommandAvailable(a)?(A(a+" is not available in the commands collection"),!1):this.commands[a].queryEnabled()},queryCommandIndeterm:function(a){a=a.toLowerCase();return!this.queryCommandAvailable(a)?(A(a+" is not available in the commands collection"),!1):null==this.commands[a].queryState()},queryCommandState:function(a){a=a.toLowerCase();return!this.queryCommandAvailable(a)?
(A(a+" is not available in the commands collection"),!1):this.commands[a].queryState()},queryCommandValue:function(a){a=a.toLowerCase();return!this.queryCommandAvailable(a)?(A(a+" is not available in the commands collection"),!1):this.commands[a].queryValue()}});d.dmxEditor.commands={bold:{isNative:!0},italic:{isNative:!0},underline:{isNative:!0},strikethrough:{isNative:!0},superscript:{isNative:!0},subscript:{isNative:!0},insertunorderedlist:{isNative:!0},insertorderedlist:{isNative:!0},inserthorizontalrule:{isNative:!0},
removeformat:{isNative:!0},fontname:{isNative:!0},"delete":{isNative:!0},noop:{},justifyleft:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.hasParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0)},queryState:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0);return a?"left"==d(a).css("textAlign")||"start"==d(a).css("textAlign")&&"ltr"==d(a).css("direction")||"end"==d(a).css("textAlign")&&"rtl"==
d(a).css("direction"):!1},execute:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0);a&&(this.queryState()?d(a).removeAttr("align").css("textAlign",""):d(a).removeAttr("align").css("textAlign","left"))}},justifycenter:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.hasParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0)},queryState:function(){if("design"!=this.editor.currentView)return!1;var a=
this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0);return a?"center"==d(a).css("textAlign")||"center"==d(a).attr("align"):!1},execute:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0);a&&(this.queryState()?d(a).removeAttr("align").css("textAlign",""):d(a).removeAttr("align").css("textAlign","center"))}},justifyfull:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.hasParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",
!0)},queryState:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0);return a?"justify"==d(a).css("textAlign")||"justify"==d(a).attr("align"):!1},execute:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0);a&&(this.queryState()?d(a).removeAttr("align").css("textAlign",""):d(a).removeAttr("align").css("textAlign","justify"))}},justifyright:{queryEnabled:function(){return"design"!=
this.editor.currentView?!1:this.editor.hasParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0)},queryState:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",!0);return a?"right"==d(a).css("textAlign")||"start"==d(a).css("textAlign")&&"rtl"==d(a).css("direction")||"end"==d(a).css("textAlign")&&"ltr"==d(a).css("direction"):!1},execute:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("DIV,H1,H2,H3,H4,H5,H6,P,TD,TH,LI",
!0);a&&(this.queryState()?d(a).removeAttr("align").css("textAlign",""):d(a).removeAttr("align").css("textAlign","right"))}},indent:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:!!this.editor.getBlockNode(!0)||this.editor.hasParentNode("LI",!0)},execute:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("LI",!0);if(a)this.editor.getDocument().execCommand("indent",!1,null);else if(a=this.editor.getBlockNode(!0)){var b=parseInt(d(a).css("marginLeft"))||
0;d(a).css("marginLeft",b+40)}}},outdent:{queryEnabled:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("LI",!0);if(a)return!0;return(a=this.editor.getBlockNode(!0))?(marginLeft=parseInt(d(a).css("marginLeft"))||0,0<marginLeft):!1},execute:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("LI",!0);if(a)this.editor.getDocument().execCommand("outdent",!1,null);else if(a=this.editor.getBlockNode(!0)){var b=parseInt(d(a).css("marginLeft"))||
0;40<b?d(a).css("marginLeft",b-40):d(a).css("marginLeft","")}}},inserthtml:{execute:function(a){a&&this.editor.insertHtml(a,!0)}},fontsize:{queryValue:function(){return"design"!=this.editor.currentView?"":this.editor.css("fontSize")||""},execute:function(a){function b(a,b){a=d(a?a:g);a.css("fontSize",b);a.is("font[size]")&&a.removeAttr("size")}function c(a){a=d(a?a:g);0!=a.length?(a.is("font[size]")&&a.removeAttr("size"),a[0].style.removeProperty?a[0].style.removeProperty("font-size"):a[0].style.fontSize=
"inherit",""===a.attr("style")&&a.removeAttr("style")):A("no font node?")}if("design"!=this.editor.currentView)return!1;var e=this.editor,g=d(e.getSelectedNode(!0));e.hasTextSelection()?(e.getDocument().execCommand("FontSize",!1,3),e=g.is("font")?g:g.find("font"),0<e.length&&(""==a?c(e):b(e,a))):""==a?c(g):b(g,a);this.editor.updateSelection()}},formatblock:{queryValue:function(){if("design"!=this.editor.currentView)return"";var a=this.editor.getBlockNode();return a&&a.nodeName||""},execute:function(a){if("design"!=
this.editor.currentView)return!1;try{this.editor.getDocument().execCommand("formatblock",!1,"<"+a+">"),this.editor.refreshSelection()}catch(b){O("can't execute formatblock command",b)}}},find:{queryEnabled:V,queryValue:function(){return{textToFind:this.editor.getRange().toString()}},execute:function(a){a=a||{textToFind:this.editor.getRange().toString()};this.editor.findText(a.textToFind,a.matchCase,a.searchUpward)||alert("Text not found!")}},replace:{queryEnabled:V,execute:function(a){if(a&&a.textToFind){var b=
this.editor.getRange(),c=b.toString();if(!a.matchCase)c=c.toLowerCase(),a.textToFind=a.textToFind.toLowerCase();c==a.textToFind?(b.deleteContents(),b.collapse(!0),a.replaceWith&&(c=this.editor.getDocument().createTextNode(a.replaceWith),b.insertNode(c),b.selectNode(c)),this.editor.findText(a.textToFind,a.matchCase)):this.editor.findText(a.textToFind,a.matchCase)||alert("Nothing to replace!")}}},replaceAll:{queryEnabled:V,execute:function(a){if(a&&a.textToFind){this.editor.saveSelection();var b=this.editor.getRange(),
c=this.editor.getBody(),d=!1;b.selectNode(c.firstChild);for(b.collapse(!0);this.editor.findText(a.textToFind,a.matchCase);)b=this.editor.getRange(),b.deleteContents(),b.collapse(!0),d=!0,a.replaceWith&&(c=this.editor.getDocument().createTextNode(a.replaceWith),b.insertNode(c),b.selectNode(c));d||(this.editor.restoreSelection(),alert("Nothing to replace!"))}}},setClassName:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.selectedElement&&"BODY"!=this.editor.selectedElement.tagName},
queryValue:function(){if("design"!=this.editor.currentView)return"";var a=[];d(this.editor.selectedElement).parents("[class]").andSelf().each(function(){var b=d(this).attr("class");if(b)for(var b=b.replace(/\bdmx[^\s]*/gi,"").replace(/^\s+|\s+$/g).split(" "),c=0;c<b.length;c++)a.push(this.tagName+"."+b[c])});return a},execute:function(a){if("design"!=this.editor.currentView||!a.value)return!1;var b=d(this.editor.getBlockNode()),c=a.value;0<a.value.indexOf(".")&&(c=a.value.split("."),b=d(this.editor.selectedElement).closest(c[0]),
c=c[1]);a.checked?b.addClass(c):b.removeClass(c)}},forecolor:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.getDocument().queryCommandEnabled("forecolor")},queryValue:function(){if("design"!=this.editor.currentView)return null;try{return this.editor.getDocument().queryCommandValue("forecolor")}catch(a){return null}},execute:function(a){if("design"!=this.editor.currentView)return!1;if("clear"==a)for(a=this.editor.selectedElement;a&&"BODY"!=a.nodeName;){if(a.style.color){a.style.color=
"";break}a=a.parentNode}else if(this.editor.hasTextSelection())this.editor.getDocument().execCommand("forecolor",!1,a);else{var b=this.editor.getBlockNode();if(b)b.style.color=a}}},bgcolor:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.selectionIsEditable(null,"content")},queryValue:function(){if("design"!=this.editor.currentView)return null;try{return this.editor.getDocument().queryCommandValue(M||d.browser.webkit?"backcolor":"hilitecolor")}catch(a){return null}},
execute:function(a){if("design"!=this.editor.currentView)return!1;if("clear"==a)for(a=this.editor.selectedElement;a&&"BODY"!=a.nodeName;){if(a.style.backgroundColor){a.style.backgroundColor="";break}a=a.parentNode}else if(this.editor.hasTextSelection())this.editor.getDocument().execCommand(M?"backcolor":"hilitecolor",!1,a);else{var b=this.editor.getBlockNode();if(b)b.style.backgroundColor=a}}},insertTable:{execute:function(a){if("design"!=this.editor.currentView)return!1;if(d.isPlainObject(a)){var b=
"<table";""!=a.width&&(b+=' width="'+a.width+a.widthExt+'"');""!=a.border&&(b+=' border="'+a.border+'"');""!=a.cellspacing&&(b+=' cellspacing="'+a.cellspacing+'"');""!=a.cellpadding&&(b+=' cellpadding="'+a.cellpadding+'"');""!=a.align&&(b+=' align="'+a.align+'"');for(var b=b+">",c=0;c<a.rows;c++){for(var b=b+"<tr>",e=0;e<a.cols;e++)b+="<td><br /></td>";b+="</tr>"}b+="</table>";"center"==a.align&&(b="<br />"+b+"<br />");this.editor.insertHtml(b)}}},editTable:{queryEnabled:function(){return"design"!=
this.editor.currentView?!1:!!this.editor.hasParentNode("TABLE",!0)},queryValue:function(){if("design"!=this.editor.currentView)return{};var a={};if(this.editor.hasParentNode("TABLE",!0)){var b,c=d(this.editor.getParentNode("TABLE",!0));if(b=c.attr("width"))a.width=parseInt(b,10)||"",a.widthExt=-1!=b.indexOf("%")?"%":"";a.border=c.attr("border")||"";a.cellspacing=c.attr("cellspacing")||"";a.cellpadding=c.attr("cellpadding")||"";a.align=c.attr("align")||""}return a},execute:function(a){if("design"!=
this.editor.currentView)return!1;if(d.isPlainObject(a)&&this.editor.hasParentNode("TABLE",!0)){var b=d(this.editor.getParentNode("TABLE",!0));""!=a.width?b.attr("width",a.width+a.widthExt):b.removeAttr("width");""!=a.border?b.attr("border",a.border):b.removeAttr("border");""!=a.cellspacing?b.attr("cellspacing",a.cellspacing):b.removeAttr("cellspacing");""!=a.cellpadding?b.attr("cellpadding",a.cellpadding):b.removeAttr("cellpadding");""!=a.align?b.attr("align",a.align):b.removeAttr("align")}}},editTableCell:{queryEnabled:function(){return"design"!=
this.editor.currentView?!1:!!this.editor.hasParentNode("td,th",!0)}},hyperlink:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.hasTextSelection()||this.editor.hasParentNode("IMG",!0)||this.editor.hasParentNode("A",!0)},queryValue:function(){if("design"!=this.editor.currentView)return{};if(this.editor.hasParentNode("A",!0)){var a=d(this.editor.getParentNode("A",!0)),b,c,e,g,f,i=a[0].href.match(/^\w+:(\/\/)?/);b=a.attr("href");c=b.match(/utm_source=([^&]*)/i);e=b.match(/utm_medium=([^&]*)/i);
g=b.match(/utm_content=([^&]*)/i);f=b.match(/utm_campaign=([^&]*)/i);b=b.replace(/&(amp;)?utm_(source|medium|content|campaign)=([^&]*)/gi,"");var h="dmxLightbox"==a.attr("rel"),l=a.attr("rev"),j={};h&&l&&(j=eval("("+l+")"));return{lb_use:h,lb_width:j.width||"",lb_height:j.height||"",lb_group:j.group||"",utm_source:c?c[1]:"",utm_medium:e?e[1]:"",utm_content:g?g[1]:"",utm_campaign:f?f[1]:"",url:b,title:a.attr("title")||"",target:a.attr("target")||"",scheme:i?i[0]:""}}return{}},execute:function(a){if("design"!=
this.editor.currentView)return!1;if(d.isPlainObject(a)){var b,c=a.url;this.editor.hasParentNode("A",!0)?b=d(this.editor.getParentNode("A",!0)):(b="javascript:void("+(new Date).getTime()+");",this.editor.getDocument().execCommand("createlink",!1,b),b=d('a[href="'+b+'"]',this.editor.getBody()));a.utm_source&&(c+="&utm_source="+a.utm_source);a.utm_medium&&(c+="&utm_medium="+a.utm_medium);a.utm_content&&(c+="&utm_content="+a.utm_content);a.utm_campaign&&(c+="&utm_campaign="+a.utm_campaign);b.attr("href",
c);a.title?b.attr("title",a.title):b.removeAttr("title");if(a.lb_use){var c="",e=parseInt(a.lb_width),g=parseInt(a.lb_height);"number"==typeof e&&0<e&&(c+="width:"+e+",");"number"==typeof g&&0<g&&(c+="height:"+g+",");this.editor.options.lb_preset&&(c+="preset:'"+this.editor.options.lb_preset+"',");a.lb_group&&""!=a.lb_group&&(c+="group:'"+a.lb_group+"',");a.target="_blank";b.attr("rel","dmxLightbox");""!=c&&b.attr("rev","{"+c.substr(0,c.length-1)+"}")}else"dmxLightbox"==b.attr("rel")&&(b.removeAttr("rel"),
b.removeAttr("rev"));a.target?b.attr("target",a.target):b.removeAttr("target")}}},unlink:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.hasParentNode("A",!0)},execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.removeNode(this.editor.getParentNode("A",!0))}},addaoreditimage:{queryEnabled:function(){if("design"!=this.editor.currentView)return!1;var a=this.editor.getParentNode("IMG",!0);return a&&a.hasAttribute("data-translated")?!1:!0},queryValue:function(){if("design"!=
this.editor.currentView)return{};if(this.editor.hasParentNode("IMG",!0)){var a=d(this.editor.getParentNode("IMG",!0)),b={src:"",alt:"",align:"",border:0,hspace:"",vspace:"",width:"",height:""},c;for(c in b)b[c]=a.attr(c)||"";return b}return{}},execute:function(a){if("design"!=this.editor.currentView)return!1;if(d.isPlainObject(a))if(this.editor.hasParentNode("IMG",!0)){var b=d(this.editor.getParentNode("IMG",!0));b.css({width:"",height:""});for(var c in a)""===a[c]?b.removeAttr(c):b.attr(c,a[c])}else b=
"<img",a.src&&(b+=' src="'+a.src+'"'),a.alt&&(b+=' alt="'+a.alt+'"'),a.align&&(b+=' align="'+a.align+'"'),a.border&&(b+=' border="'+a.border+'"'),a.hspace&&(b+=' hspace="'+a.hspace+'"'),a.vspace&&(b+=' vspace="'+a.vspace+'"'),a.width&&(b+=' width="'+a.width+'"'),a.height&&(b+=' height="'+a.height+'"'),this.editor.insertHtml(b+"/>")}},save:{queryEnabled:function(){return this.editor.isDocumentModified()},execute:function(){this.editor.save();return!1}},close:{queryEnabled:V,execute:function(){this.editor.isDocumentModified()&&
confirm(this.editor.translate("msgAskSaveBeforeClose"))&&this.editor.save();var a=this;setTimeout(function(){a.editor.destruct()},10);return!1}},viewsource:{queryEnabled:V,queryState:function(){return"code"==this.editor.getView()},execute:function(){this.editor.setView("code"==this.editor.getView()?"design":"code")}},togglefullscreen:{queryEnabled:V,queryState:function(){return this.editor.wrapper.hasClass("fullscreen")},execute:function(){this.editor.toggleFullscreen(!this.editor.wrapper.hasClass("fullscreen"))}},
undo:{queryEnabled:function(){return this.editor.history.canUndo()},execute:function(){this.editor.history.undo()}},redo:{queryEnabled:function(){return this.editor.history.canRedo()},execute:function(){this.editor.history.redo()}},deleteRow:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.getTableEditor().canDeleteRow()},execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.getTableEditor().deleteRow()}},insertRowBefore:{queryEnabled:function(){return"design"!=
this.editor.currentView?!1:this.editor.getTableEditor().canInsertRowBefore()},execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.getTableEditor().insertRowBefore()}},insertRowAfter:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.getTableEditor().canInsertRowAfter()},execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.getTableEditor().insertRowAfter()}},insertColBefore:{queryEnabled:function(){return"design"!=this.editor.currentView?
!1:this.editor.getTableEditor().canInsertColBefore()},execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.getTableEditor().insertColBefore()}},insertColAfter:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.getTableEditor().canInsertColAfter()},execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.getTableEditor().insertColAfter()}},deleteCol:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.getTableEditor().canDeleteCol()},
execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.getTableEditor().deleteCol()}},deleteTable:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.getTableEditor().canDeleteTable()},execute:function(){if("design"!=this.editor.currentView)return!1;this.editor.getTableEditor().deleteTable()}},splitCell:{queryEnabled:function(){return"design"!=this.editor.currentView?!1:this.editor.getTableEditor().canSplitCell()},execute:function(){if("design"!=this.editor.currentView)return!1;
this.editor.getTableEditor().splitCell()}}};d.extend(d.dmxEditor.prototype,{initControls:function(){this.controls={};for(var a in d.dmxEditor.controls)this.addControl(a,d.dmxEditor.controls[a])},addControl:function(a,b){b=d.extend({type:"Control",editor:this},b||{});d.dmxEditor.ui[b.type]?this.controls[a]=new d.dmxEditor.ui[b.type](a,b):O("Control not found: "+b.type);return this.controls[a]},getControl:function(a){return this.controls[a]},updateControls:function(){for(var a in this.controls)this.controls[a].update()}});
d.dmxEditor.controls={"-":{type:"Separator"},save:{type:"Button",icon:"save",tooltip:"Save",command:"save"},close:{type:"Button",icon:"close",tooltip:"Close",command:"close"},viewsource:{type:"Button",icon:"source",tooltip:"View Source",command:"viewsource"},togglefullscreen:{type:"Button",icon:"fullscreen",tooltip:"Toggle Fulscreen Mode",command:"togglefullscreen"},undo:{type:"Button",icon:"undo",tooltip:"Undo",command:"undo"},redo:{type:"Button",icon:"redo",tooltip:"Redo",command:"redo"},find:{type:"DialogButton",
icon:"find",tooltip:"Find",url:"dialogs/find.html",command:"find",cache:!0},replace:{type:"DialogButton",icon:"replace",tooltip:"Find and Replace",url:"dialogs/replace.html",command:"find",cache:!0},bold:{type:"Button",icon:"bold",tooltip:"Bold",command:"bold"},italic:{type:"Button",icon:"italic",tooltip:"Italic",command:"italic"},underline:{type:"Button",icon:"underline",tooltip:"Underline",command:"underline"},strikethrough:{type:"Button",icon:"strikethrough",tooltip:"Strike Through",command:"strikethrough"},
superscript:{type:"Button",icon:"superscript",tooltip:"Superscript",command:"superscript"},subscript:{type:"Button",icon:"subscript",tooltip:"Subscript",command:"subscript"},justifyleft:{type:"Button",icon:"align-left",tooltip:"Justify Left",command:"justifyleft"},justifycenter:{type:"Button",icon:"align-center",tooltip:"Justify Center",command:"justifycenter"},justifyfull:{type:"Button",icon:"align-justify",tooltip:"Justify Full",command:"justifyfull"},justifyright:{type:"Button",icon:"align-right",
tooltip:"Justify Right",command:"justifyright"},indent:{type:"Button",icon:"indent",tooltip:"Indent",command:"indent"},outdent:{type:"Button",icon:"outdent",tooltip:"Outdent",command:"outdent"},forecolor:{type:"ColorButton",icon:"fore-color",tooltip:"Text Color",command:"forecolor"},bgcolor:{type:"ColorButton",icon:"back-color",tooltip:"Background Color",command:"bgcolor"},removeformat:{type:"Button",icon:"remove-format",tooltip:"Remove formatting",command:"removeformat"},insertunorderedlist:{type:"Button",
icon:"list-bullets",tooltip:"UnorderedList",command:"insertunorderedlist"},insertorderedlist:{type:"Button",icon:"list-numbers",tooltip:"OrderedList",command:"insertorderedlist"},inserttable:{type:"DialogButton",icon:"table-insert",tooltip:"Insert Table",command:"insertTable",url:"dialogs/insert_table.html",cache:!0},editTable:{type:"DialogButton",icon:"table-edit",tooltip:"Table properties",command:"editTable",url:"dialogs/edit_table.html",cache:!0},editTableCell:{type:"DialogButton",icon:"table-cell",
tooltip:"Cell properties",command:"editTableCell",url:"dialogs/table_cell.html",cache:!0},insertRowBefore:{type:"Button",icon:"table-insert-row-before",tooltip:"Insert row above",command:"insertRowBefore"},insertRowAfter:{type:"Button",icon:"table-insert-row-after",tooltip:"Insert row below",command:"insertRowAfter"},insertColBefore:{type:"Button",icon:"table-insert-column-before",tooltip:"Insert column on the left",command:"insertColBefore"},insertColAfter:{type:"Button",icon:"table-insert-column-after",
tooltip:"Insert column on the right",command:"insertColAfter"},deleteRow:{type:"Button",icon:"table-delete-row",tooltip:"Delete row",command:"deleteRow"},deleteCol:{type:"Button",icon:"table-delete-column",tooltip:"Delete column",command:"deleteCol"},deleteTable:{type:"Button",icon:"table-delete",tooltip:"Delete table",command:"deleteTable"},inserthorizontalrule:{type:"Button",icon:"horizontal-rule",tooltip:"Horizontal rule",command:"inserthorizontalrule"},addlink:{type:"DialogButton",icon:"link",
tooltip:"Add Link",command:"hyperlink",url:"dialogs/link.html",cache:!0},deletelink:{type:"Button",icon:"unlink",tooltip:"Remove Link",command:"unlink"},addaoreditimage:{type:"DialogButton",icon:"image",tooltip:"Add/Edit Image",command:"addaoreditimage",url:"dialogs/image.html",modal:!0,cache:!0},insertspecialchar:{type:"DialogButton",icon:"special",tooltip:"Insert Special Character",url:"dialogs/specialchars.html",cache:!0},fontname:{type:"Select",icon:"font",tooltip:"Font Family",width:"80px",command:"fontname",
values:function(){var a=d.extend(!0,{},this.editor.options.fonts),b;for(b in a)for(var c=0;c<a[b].length;c++){var e=a[b][c];a[b][c]={label:e,value:e,style:"padding-left:10px;font-size:12px;font-family:"+e}}return a}},fontsize:{type:"Select",tooltip:"Font size",width:"40px",command:"fontsize",values:function(){return this.editor.options.fontSizes}},formatblock:{type:"Select",tooltip:"Format block",width:"100px",command:"formatblock",values:function(){return this.editor.options.formatBlocks}},setClassName:{type:"MultiSelect",
tooltip:"CSS class",width:"120px",command:"setClassName",values:function(){return this.editor.userStyles}},code_toggle_wrap:{type:"Button",icon:"text-wrap",tooltip:"Wrap lines",command:"code_toggle_wrap"},code_toggle_indent:{type:"Button",icon:"text-indent",tooltip:"Indent Source",command:"code_toggle_indent"}};d.extend(d.dmxEditor.prototype,{initKeys:function(){for(var a in d.dmxEditor.Keys)this.registerKey(a,d.dmxEditor.Keys[a])},registerKey:function(a,b){for(var c=a.split(" "),d=0;d<c.length;d++)this.Keys[this.normalizeKey(c[d])]=
b},normalizeKey:function(a){for(var a=a.toUpperCase().split("+"),b="",c="",d=!1,g=!1,f=!1,i=0;i<a.length;i++)switch(a[i]){case "ALT":d=!0;break;case "CMD":case "COMMAND":case "META":case "CTRL":case "CONTROL":g=!0;break;case "SHIFT":f=!0;break;default:c=a[i]}f&&(b+="SHIFT+");g&&(b+="CTRL+");d&&(b+="ALT+");return b+c}});d.dmxEditor.Keys={Enter:function(){var a=this.options.lineBreak.toUpperCase(),b=this.getBlockNode(!0);this.refreshSelection();if("design"!=this.currentView)this.insertBR();else if(!b&&
"BR"!=a&&3==this.selectedElement.firstChild.nodeType)a="AUTO"==a||"BR"==a?"P":a,d(this.selectedElement.firstChild).wrap("<"+a+">"),this.insertBlock(a);else if(b){if(/^(LI|UL|DL|DT|DD|OL)$/.test(b.nodeName)){if(/^[\s\r\n\t\f(&nbsp;)(<br>)]*$/.test(b.innerHTML)){d(b).remove();this.insertBlock("AUTO"==a||"BR"==a?"P":a);return}return!0}if("BR"==a&&/^(P|DIV)$/.test(b.nodeName))this.insertBR();else{b=this.selection;b.isCollapsed||b.deleteFromDocument();var c=!1;rangy.dom.isCharacterDataNode(b.focusNode)&&
b.focusOffset==b.focusNode.length&&(c=!0);if(!c)return!0;this.insertBlock("AUTO"==a||"BR"==a?"P":a)}}else this.insertBR()},"Shift+Enter":function(){var a=this.getBlockNode(!0,this.getSelectedNode(!0));if(a&&"PRE"==a.nodeName){a=this.selection;a.isCollapsed||a.deleteFromDocument();var a=this.range,b=this.getDocument().createTextNode("\r\n");a.insertNode(b);a.collapseAfter(b);this.updateSelection()}else this.insertBR()},"Ctrl+1":function(){this.execute("formatblock","h1")},"Ctrl+2":function(){this.execute("formatblock",
"h2")},"Ctrl+3":function(){this.execute("formatblock","h3")},"Ctrl+4":function(){this.execute("formatblock","h4")},"Ctrl+5":function(){this.execute("formatblock","h5")},"Ctrl+6":function(){this.execute("formatblock","h6")},"Ctrl+S":function(){this.execute("save")},"Ctrl+Q":function(){this.execute("close")},"Ctrl+Z":function(){this.execute("undo")},"Ctrl+Y Ctrl+Shift+Z":function(){this.execute("redo")},"Ctrl+B":function(){this.execute("bold")},"Ctrl+I":function(){this.execute("italic")},"Ctrl+U":function(){this.execute("underline")},
Tab:function(){return"code"==this.currentView?(this.insertHtml("&nbsp;&nbsp;"),!1):!0},"Ctrl+Tab":function(){this.execute("indent")},"Shift+Ctrl+Tab":function(){this.execute("outdent")},"Ctrl+F":function(){var a=this.getControl("find");a&&a.openDialog()},"Ctrl+H":function(){var a=this.getControl("replace");a&&a.openDialog()},F3:function(){this.execute("find")}};d.fn.dmxEditorDestruct=function(){return this.each(function(a,b){var c=d.data(b,"dmxEditor");c&&(c.destruct(),d(b).removeData("dmxEditor"))})};
d.fn.dmxEditor=function(a){rangy.init();H&&(console.log("new editor"),console.log("IS_IOS:"+Fa),console.log("IS_IOS5:"+Y),console.log("HAS_SELECTION_EVENT:"+Y));return this.each(function(){var b=d.data(this,"dmxEditor");b?b.config(a||{}):d.dmxEditor.replaceElement(this,a||{})})}}})();

