Files
SIG/Scripts/AjaxControlToolkit/Release/HtmlEditor.DesignPanel.js
JORGE LUIS CAUDILLO ESPARZA c35cf91883 Commit inicial Ventas Productivo
2019-08-14 16:40:54 -07:00

1 line
58 KiB
JavaScript

Type.registerNamespace("Sys.Extended.UI.HtmlEditor");Sys.Extended.UI.HtmlEditor.DesignPanel=function(n){Sys.Extended.UI.HtmlEditor.DesignPanel.initializeBase(this,[n]);this._doc=null;this._updated_now=!1;this._updateTimer=null;this._popup=null;this._contextElement=null;this._a_prize=!1;this.__stack=null;this._StyleForTyping=null;this.isWord=!1;this.isPlainText=!1;this.dfltBlockElement="P";this._FontNotSet=!0;this._design_timer1=null;this._events$delegate=Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.DesignPanelEventHandler);this._blur$delegate=Function.createDelegate(this,this._blur);this._focus$delegate=Function.createDelegate(this,this._focus_event)};Sys.Extended.UI.HtmlEditor.DesignPanel.prototype={initialize:function(){Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"initialize")},dispose:function(){Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"dispose")},_activate:function(n){Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"_activate");this._wasFocused=!1;this._initIframe(n);this._onDocumentLoaded()},_deactivate:function(){this._deactivateCommon();Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.open(),this._doc.write(""),this._doc.close(),this.get_element().src="javascript:false;");this._doc=null;Sys.Extended.UI.HtmlEditor.DesignPanel.callBaseMethod(this,"_deactivate")},_deactivateCommon:function(){var t,n;for(this._editPanel.__blured=!1,t=this._doc.body.getElementsByTagName("IMG"),n=0;n<t.length;n++)if(t[n].getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute)&&t[n].getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute).length>0)try{Sys.Extended.UI.HtmlEditor.isIE?$removeHandler(t[n],"dragstart",Sys.Extended.UI.HtmlEditor.stopDrag):$removeHandler(t[n],"draggesture",Sys.Extended.UI.HtmlEditor.stopDrag)}catch(i){}Sys.Extended.UI.HtmlEditor._removeEvents(this._doc,["keydown","keypress","mousedown","mouseup","dblclick"],this._events$delegate);Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow,["blur"],this._blur$delegate);Sys.Extended.UI.HtmlEditor._removeEvents(this.get_element().contentWindow,["focus"],this._focus$delegate)},_initIframe:function(n){Sys.Extended.UI.HtmlEditor.isIE||(this._savedValue=n,this._absAndFixedParents=this._getAbsAndFixedParents());var t=Sys.Extended.UI.HtmlEditor.Trim(this._prepareContent(n));this._doc=this.get_element().contentWindow.document;Sys.Extended.UI.HtmlEditor.isIE||(this._doc.designMode="on");this._doc.open();this._doc.write('<html><head><link rel="stylesheet" href="'+this._editPanel.get_documentCssPath()+'" media="all" /><link rel="stylesheet" href="'+this._editPanel.get_designPanelCssPath()+'" media="all" /><\/head><body>'+t+"<\/body><\/html>");this._doc.close();this._doc.id="EditorDocument";Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.body.contentEditable=!0,this._tryForward=!0)},_blur:function(n){return this._editPanel.__blured=!0,Sys.Extended.UI.HtmlEditor.isIE||this._design_timer1==null||(clearTimeout(this._design_timer1),this._design_timer1=null),this.isPopup||this._editPanel._validate(n,null),!0},_focus_event:function(){if(this._editPanel.__blured=!1,Sys.Extended.UI.HtmlEditor.isIE)this._really_focused();else{var n=this;Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel=this._editPanel;this._design_timer1==null&&(this._design_timer1=setTimeout(function(){n._really_focused();n._design_timer1=null},0))}return!0},_getAbsAndFixedParents:function(){for(var n=this.get_element(),t="";n!=null&&n.tagName&&n.tagName.toLowerCase()!="body";)t+=n.tagName,(n.style.position=="absolute"||n.style.position=="fixed")&&(t+=": "+n.style.position),t+="\n",n=n.parentNode;return t},_onDocumentLoaded:function(){var n=this,t,i;if(!Sys.Extended.UI.HtmlEditor.isIE&&(t=this._getAbsAndFixedParents(),t!=this._absAndFixedParents)){this._initIframe(this._savedValue);setTimeout(function(){n._onDocumentLoaded()},10);return}try{if(!Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.queryCommandValue("forecolor"),(Sys.Extended.UI.HtmlEditor.isSafari||Sys.Extended.UI.HtmlEditor.isOpera)&&!Sys.Extended.UI.HtmlEditor.isReallyVisible(this.get_element()))){setTimeout(function(){n._onDocumentLoaded()},10);return}i=n._doc.body.innerHTML}catch(r){setTimeout(function(){n._onDocumentLoaded()},10);return}this._afterBodyIsFormed();setTimeout(function(){n._activateFinished();Sys.Extended.UI.HtmlEditor.isIE&&!n._editPanel.get_autofocus()&&n._getSelection().empty()},0)},_afterBodyIsFormed:function(){var i=this,n,t;if(Sys.Extended.UI.HtmlEditor._addEvents(this._doc,["keydown","keypress","mousedown","mouseup","dblclick"],this._events$delegate),Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow,["blur"],this._blur$delegate),Sys.Extended.UI.HtmlEditor._addEvents(this.get_element().contentWindow,["focus"],this._focus$delegate),Sys.Extended.UI.HtmlEditor.inspectForShadows(i._doc.body),n=this._doc.body,n.childNodes.length==1&&n.firstChild.tagName&&n.firstChild.tagName.toUpperCase()=="DIV"&&n.firstChild.style.cssText.length>0&&n.firstChild.style.direction.length>0&&Sys.Extended.UI.HtmlEditor.getStyle(n.firstChild,"position")!="absolute"){for(n.style.cssText=n.firstChild.style.cssText,t=n.firstChild;t.firstChild;)n.insertBefore(t.firstChild,t);n.removeChild(t)}i._clearP()},_getContent:function(){var p,n,w,u,a,v,s,h,t,c,f,l,i,e;if(this._popup!=null&&typeof this._popup._forceImClose=="function"&&(p=this._popup._forceImClose,p(this._popup._iframe.contentWindow)),this._clearP(),Sys.Extended.UI.HtmlEditor.isIE)Sys.Extended.UI.HtmlEditor.spanJoiner(this._doc.body,this._doc),n=Sys.Extended.UI.HtmlEditor.getHTML(this._doc.body,!1,!0),n=n.replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/ig,"$1&nbsp;$3").replace(/(<td[^>]*?>)\s*(&nbsp;)\s*(<\/td[^>]*?>)/ig,"$1<br/>$3").replace(/(<p[^>]*?>)\s*(&nbsp;)\s*(<\/p[^>]*?>)/ig,"$1<br/>$3"),n=(this._doc.body.style.cssText.length>0?'<div style="'+this._doc.body.style.cssText.replace('"',"'")+'">':"")+n+(this._doc.body.style.cssText.length>0?"<\/div>":""),this._editPanel.get_noScript()&&(n=n.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/gi,"")),/<embed/ig.test(n)&&(n=n.replace(/(<embed(?:.*?))(\sloop=\"true\")((?:.*?)>)/ig,"$1$3").replace(/(<embed(?:.*?))(\splay=\"true\")((?:.*?)>)/ig,"$1$3").replace(/(<embed(?:.*?))(\sbgcolor=\"\")((?:.*?)>)/ig,"$1$3").replace(/(<embed(?:.*?))(\sscale=\"\")((?:.*?)>)/ig,"$1$3").replace(/(<embed(?:.*?))(\shspace=\"0\")((?:.*?)>)/ig,"$1$3").replace(/(<embed(?:.*?))(\svspace=\"0\")((?:.*?)>)/ig,"$1$3").replace(/(<embed(?:.*?))(\swmode=\"[^\"]+\")((?:.*?)>)/ig,"$1$3").replace(/(<embed(?:.*?))(pseudomode=)(\"[^\"]*\")((?:.*?)>)/ig,"$1wmode=$3$4").replace(/(<embed(?:.*?))(\swmode=\"\")((?:.*?)>)/ig,"$1$3")),w=new RegExp("(<[/]?)(teo"+Sys.Extended.UI.HtmlEditor.smartClassName+":)","ig"),n=n.replace(w,"$1");else{for(u=this._doc.createElement("DIV"),a=new Sys.Extended.UI.HtmlEditor.DesignPanel.ScriptRecover,u.style.cssText=this._doc.body.style.cssText,this._editPanel.get_noScript()||this._doc.body.innerHTML.replace(/<script(?:[^>]*?)>(.*?)<\/script(?:[^>]*?>)/gi,function(n,t){return a.regReplScript1(n,t)}),u.innerHTML=Sys.Extended.UI.HtmlEditor.Trim(this._doc.body.innerHTML),v=u.getElementsByTagName("IMG"),s=[],f=0;f<v.length;f++)s.push(v[f]);for(h=0;h<s.length;h++)if(t=s[h],c=t.getAttribute("dummytag"),c&&c.length>0&&c.toLowerCase()=="embed"){var k=t.getAttribute("dummysrc"),o=t.getAttribute("dummybgcolor"),y=t.getAttribute("pseudomode"),b=t.attributes,r=this._doc.createElement("EMBED");for(r.src=k,r.width=t.width,r.height=t.height,o&&o.length>0&&(o=Sys.Extended.UI.HtmlEditor.tryReplaceRgb(o),r.setAttribute("bgcolor",o)),y&&y.length>0&&r.setAttribute("wmode",y),f=0;f<b.length;++f)(l=b.item(f),l.specified)&&(i=l.name.toLowerCase(),e=l.value,i!="dummytag"&&i!="dummysrc"&&i!="dummybgcolor"&&i!="style"&&i!="wmode"&&i!="pseudomode"&&i!="src")&&(i!="loop"||e!="true")&&(i!="play"||e!="true")&&(i!="hspace"||e!="0")&&(i!="vspace"||e!="0")&&(i!="scale"||e.length!=0)&&(i!="align"||e.length!=0)&&r.setAttribute(i,e);t.style.width&&t.style.width.length>0&&(r.style.width=t.style.width);t.style.height&&t.style.height.length>0&&(r.style.height=t.style.height);t.parentNode.insertBefore(r,t);t.parentNode.removeChild(t)}Sys.Extended.UI.HtmlEditor.spanJoiner(u,this._doc);n=Sys.Extended.UI.HtmlEditor.getHTML(u,u.style.cssText.length>0?!0:!1,!0);n=this._editPanel.get_noScript()?n.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/gi,""):n.replace(/(<script(?:[^>]*?)>)(.*?)(<\/script(?:[^>]*?)>)/gi,function(n,t,i,r){return a.regReplFromScript1(n,t,i,r)});delete u}return n=Sys.Extended.UI.HtmlEditor.brXHTML(n.replace(/^([\n|\r]+)/,"")),this._editPanel.get_noUnicode()&&(n=n.replace(/([\u0080-\uFFFF])/g,function(n,t){return"&#"+t.charCodeAt(0).toString(10)+";"})),Sys.Extended.UI.HtmlEditor.Trim(n)=="<br />"&&(n=""),n},_setContent:function(n){this._deactivateCommon();var t=Sys.Extended.UI.HtmlEditor.Trim(this._prepareContent(n));this._doc.open();this._doc.write('<html><head><link rel="stylesheet" href="'+this._editPanel.get_documentCssPath()+'" media="all" /><link rel="stylesheet" href="'+this._editPanel.get_designPanelCssPath()+'" media="all" /><\/head><body>'+t+"<\/body><\/html>");this._doc.close();Sys.Extended.UI.HtmlEditor.isIE&&(this._doc.body.contentEditable=!0,this._tryForward=!0);this._afterBodyIsFormed();this._editPanel.get_autofocus()&&this._focus();Sys.Extended.UI.HtmlEditor.isIE&&!this._editPanel.get_autofocus()&&this._getSelection().empty()},_focus:function(n){this.focusEditor();this._focused(n)},focusEditor:function(){try{this.get_element().contentWindow.focus()}catch(n){}this._wasFocused||(this._wasFocused=!0,this._editPanel.get_startEnd()||this._setToEnd())},_prepareContent:function(n){var t=n,o,e,l,s,h,r,c,f,n;if(t=t.replace(/<object(?:[^>]*?)>(?:[^\u0000]*?)(<embed(?:[^>]*?)>)(?:[^\u0000]*?)<\/object(?:[^>]*?)>/gi,"$1"),Sys.Extended.UI.HtmlEditor.isIE)return t=Sys.Extended.UI.HtmlEditor.Trim(t.replace(/([\n\r]+<)/g,"<").replace(/([^>])([\n\r]+)([^<])/g,"$1 $3")).replace(/(&amp;)/g,"&amp;amp;").replace(/<br\s*[\/]*>\s*<\/td>/ig,"<\/td>").replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/ig,"$1&nbsp;$3").replace(/(<p[^>]*?>)\s*(<br[^>]*?>)\s*(<\/p[^>]*?>)/ig,"$1&nbsp;$3"),/<embed/ig.test(t)&&(t=t.replace(/(<embed(?:.*?))(wmode=)(\"[^\"]*\")((?:.*?)>)/ig,"$1pseudomode=$3$4").replace(/(<embed)([^>]*?>)/ig,'$1 wmode="transparent"$2')),t.replace(/&amp;/ig,"&");for(o=new Sys.Extended.UI.HtmlEditor.DesignPanel.ScriptRecover,e=document.createElement("DIV"),this._editPanel.get_noScript()||t.replace(/<script(?:[^>]*?)>(.*?)<\/script(?:[^>]*?>)/gi,function(n,t){return o.regReplScript1(n,t)}),e.innerHTML=Sys.Extended.UI.HtmlEditor.Trim(t.replace(/([^>])([\n\r]+)([^<])/g,"$1 $3")),l=e.getElementsByTagName("EMBED"),s=[],r=0;r<l.length;r++)s.push(l[r]);for(h=0;h<s.length;h++){var i=s[h],u=document.createElement("IMG"),a=i.attributes;for(u.src=this._editPanel.get_imagePath_1x1(),u.setAttribute("dummytag","embed"),r=0;r<a.length;++r)(c=a.item(r),c.specified)&&(f=c.name.toLowerCase(),n=c.value,f=="src"?f="dummysrc":f=="bgcolor"?f="dummybgcolor":f=="wmode"&&(f="pseudomode"),u.setAttribute(f,n));u.style.cssText="border: 1px dotted #000000; background-image: url('"+(u.getAttribute("type").toLowerCase()=="application/x-mplayer2"?this._editPanel.get_imagePath_media():tthis._editPanel.get_imagePath_flash())+"'); background-position: center; background-repeat: no-repeat; background-color: #c0c0c0;";i.style.width&&i.style.width.length>0&&(u.style.width=i.style.width);i.style.height&&i.style.height.length>0&&(u.style.height=i.style.height);i.parentNode.insertBefore(u,i);i.parentNode.removeChild(i)}return Sys.Extended.UI.HtmlEditor.spanJoiner(e,document),t=Sys.Extended.UI.HtmlEditor.Trim(Sys.Extended.UI.HtmlEditor.getHTML(e,!1,!0)),this._editPanel.get_noScript()||(t=t.replace(/(<script(?:[^>]*?)>)(.*?)(<\/script(?:[^>]*?)>)/gi,function(n,t,i,r){return o.regReplFromScript1(n,t,i,r)})),delete e,delete o,t=Sys.Extended.UI.HtmlEditor.brXHTML(t),t.length==0&&(t="<br/>"),t},_clearP:function(){var n,i,t,r,u;try{if(n=this._doc.body,n.firstChild&&n.firstChild.nodeType==3&&(i=Sys.Extended.UI.HtmlEditor.Trim(""+n.firstChild.data+""),i.length==0?n.removeChild(n.firstChild):i!=""+n.firstChild.data+""&&(n.firstChild.data=i)),Sys.Extended.UI.HtmlEditor.isIE&&n.childNodes.length==1&&(n=n.firstChild,n.nodeType==1&&(t=n.tagName.toLowerCase(),t=="p"||t=="ul"||t=="ol"))){r=!1;u=t=="ul"||t=="ol";function f(n){var i=!1,t;if(n.nodeType==1){if((t=n.tagName.toUpperCase(),!(u&&t=="LI")&&(Sys.Extended.UI.HtmlEditor.isRestricted(n)||t=="IMG"||t=="IFRAME"||t=="EMBED"||t=="SCRIPT"))||n.childNodes.length>1)return!0;if(n.childNodes.length==0)return!1;i|=f(n.firstChild)}else n.nodeType==3&&(i|=!0);return i}n.childNodes.length==1&&(f(n.firstChild)||n.removeChild(n.firstChild));r=!0;(r||n.parentNode.innerHTML.toLowerCase()=="<p>&nbsp;<\/p>")&&this._doc.body.removeChild(n)}}catch(e){}},isControl:function(){var i,n,t;try{return i=this._getSelection(),Sys.Extended.UI.HtmlEditor.isIE?i.type.toLowerCase()=="control"?!0:!1:(n=this._createRange(i),t=this._getParent(n),t.nodeType!=3&&n.startContainer==n.endContainer?t.tagName?n.startContainer.childNodes.item(n.startOffset)==null?!1:n.startOffset==n.endOffset&&n.startContainer.childNodes.item(n.startOffset).tagName&&(n.startContainer.childNodes.item(n.startOffset).tagName.toUpperCase()=="BR"||Sys.Extended.UI.HtmlEditor.isStyleTag(n.startContainer.childNodes.item(n.startOffset).tagName))?!1:t.tagName.toUpperCase()=="BODY"&&n.startOffset==0&&n.endOffset>0&&n.endOffset==t.childNodes.length?!1:n.startOffset==n.endOffset&&n.startContainer.childNodes.item(n.startOffset).nodeType==3?!1:!0:!1:!1)}catch(r){return!0}},isPopup:function(){return this._popup!=null},_getSelection:function(){var n,t,i,r;if(Sys.Extended.UI.HtmlEditor.isIE)return n=this._doc.selection;this.focusEditor();r=this.get_element().contentWindow;n=r.getSelection();t=this._createRange(n);i=t.startContainer;try{while(i&&i.nodeType)i=i.parentNode}catch(u){this._removeAllRanges(n);t=this._createRange(n);t.setStart(this._saved_startContainer,this._saved_startOffset);t.setEnd(this._saved_startContainer,this._saved_startOffset);this._selectRange(n,t);n=r.getSelection()}return n},_createRange:function(n){if(Sys.Extended.UI.HtmlEditor.isIE)return typeof n=="undefined"?this._doc.body.createTextRange():n.createRange();if(this.focusEditor(),typeof n=="undefined")return this._doc.createRange();try{return n.getRangeAt(0)}catch(i){return this._doc.createRange()}},toEndOfProtected:function(){var i=this,f=this._getSelection(),n,u,r,t;try{t=this._createRange(f)}catch(e){return!1}if(Sys.Extended.UI.HtmlEditor.isIE?n=Sys.Extended.UI.HtmlEditor.contentEditable(Sys.Extended.UI.HtmlEditor.getSelParent(i)):(n=Sys.Extended.UI.HtmlEditor.contentEditable(t.startContainer),n==null&&(n=Sys.Extended.UI.HtmlEditor.contentEditable(t.endContainer))),Sys.Extended.UI.HtmlEditor.isIE&&n!=null){try{t.remove(n)}catch(o){}t=i._doc.body.createControlRange();t.add(n);t.select()}else Sys.Extended.UI.HtmlEditor.isIE||n==null||(u=i._getSelection(),n.nextSibling!=null&&n.nextSibling.nodeType==3?r=n.nextSibling:(r=i._doc.createTextNode(""),n.nextSibling!=null?n.parentNode.insertBefore(r,n.nextSibling):n.parentNode.appendChild(r)),i._removeAllRanges(u),t=i._createRange(u),t.setStart(r,0),t.setEnd(r,0),i._selectRange(u,t));return!0},_commonPaste:function(n){var t=this,r,i,f,u;this._saveContent();Sys.Extended.UI.HtmlEditor.isIE?(this.openWait(),setTimeout(function(){t._paste(!t._editPanel.get_noPaste());t.closeWait()},0),Sys.Extended.UI.HtmlEditor._stopEvent(n)):this.isPlainText||this.isWord||this._editPanel.get_noPaste()?(r=t._getSafePlace(),r!=null?(i=t._doc.createElement("div"),i.style.display="inline",i.style.borderStyle="none",r.parentNode.insertBefore(i,r),i.appendChild(r),i.removeChild(r),i.innerHTML="xx",f=t._getSelection(),u=t._createRange(),t._removeAllRanges(f),u.setStart(i.firstChild,0),u.setEnd(i.firstChild,1),t._selectRange(f,u),t.openWait(),setTimeout(function(){var h=i.parentNode,f,o,r,n,u,s,e;for(i.lastChild.deleteData(i.lastChild.length-1,1),t.isWord?(i.innerHTML=Sys.Extended.UI.HtmlEditor.cleanUp(i.innerHTML),Sys.Extended.UI.HtmlEditor.replaceOldTags(i,t),Sys.Extended.UI.HtmlEditor.spanJoiner(i,t._doc)):(f=document.createElement("div"),f.innerHTML=Sys.Extended.UI.HtmlEditor.cleanUp(i.innerHTML),o=new Sys.Extended.UI.HtmlEditor.jsDocument(!0),Sys.Extended.UI.HtmlEditor.__MozillaGetInnerText(f,o),i.innerHTML=o.toString().replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"").replace(/\n/g,"<br/>").replace(/\t/g,"&nbsp;"),delete f);i.firstChild;)h.insertBefore(i.firstChild,i);r=null;n=null;i.nextSibling&&i.nextSibling.nodeType==3&&i.previousSibling&&i.previousSibling.nodeType==3&&(r=i.nextSibling,n=i.previousSibling);h.removeChild(i);u=null;r!=null&&n!=null&&(u=n.data.length,n.data=""+n.data+""+r.data+"",r.parentNode.removeChild(r));t.isWord=!1;t.isPlainText=!1;t.closeWait();u!=null&&(s=t._getSelection(),e=t._createRange(),t._removeAllRanges(s),e.setStart(n,u),e.setEnd(n,u),t._selectRange(s,e));t.onContentChanged()},0)):Sys.Extended.UI.HtmlEditor._stopEvent(n)):setTimeout(function(){Sys.Extended.UI.HtmlEditor.operateAnchors(t,t._doc,!t._editPanel.get_showAnchors());Sys.Extended.UI.HtmlEditor.operatePlaceHolders(t,t._doc,!t._editPanel.get_showPlaceHolders());Sys.Extended.UI.HtmlEditor.inspectForShadows(t._doc.body);t._checkImages(t._doc.body);t.onContentChanged()},0)},_selectRange:function(n,t){n.addRange(t);this.focusEditor()},_selectRng:function(n){var i=this._getSelection(),r,e;if(Sys.Extended.UI.HtmlEditor.isIE){var t=this._createRange(i),u=this._createRange(i),o=this._doc.createElement("span"),f=this._doc.createElement("span");n[0].parentNode.insertBefore(o,n[0]);n[n.length-1].nextSibling?n[n.length-1].parentNode.insertBefore(f,n[n.length-1].nextSibling):n[n.length-1].parentNode.appendChild(f);try{t.moveToElementText(o);e=t.moveStart("character",1);t.moveStart("character",-e);u.moveToElementText(f);e=u.moveEnd("character",-1);u.moveEnd("character",-e);t.setEndPoint("EndToEnd",u);t.select()}catch(s){}n[0].parentNode.removeChild(o);n[n.length-1].parentNode.removeChild(f)}else r=this._doc.createRange(),r.setStart(n[0],0),r.setEnd(n[n.length-1],(""+n[n.length-1].data+"").length),this._removeAllRanges(i),this._selectRange(i,r)},_removeAllRanges:function(n){n.removeAllRanges()},_setToEnd:function(){var n=this;setTimeout(function(){n._setToEnd_();n._editPanel.updateToolbar()},0)},_setToEnd_:function(){var n=this,e,u,r,i;if(Sys.Extended.UI.HtmlEditor.isIE){u=n._getSelection();r=n._createRange(u);u.type.toLowerCase()!="control"&&(r.moveEnd("textedit",1),r.collapse(!1));r.select();n.focusEditor();return}var f=0,t=n._doc.body,i=null;if(t.lastChild&&t.lastChild.nodeType==3?(t=t.lastChild,f=(""+t.data+"").length):(e=n._doc.createTextNode(""),t.lastChild&&t.lastChild.nodeType==1&&t.lastChild.tagName.toUpperCase()=="BR"?t.insertBefore(e,t.lastChild):t.appendChild(e),t=e,f=0),u=n._getSelection(),n._removeAllRanges(u),r=n._createRange(),r.setStart(t,f),r.setEnd(t,f),n._selectRange(u,r),i!=null&&n._doc.body.removeChild(i),n.focusEditor(),!Sys.Extended.UI.HtmlEditor.isSafari&&!Sys.Extended.UI.HtmlEditor.isOpera)try{i=n._doc.createElement("button");i.style.width="0px";i.style.height="20px";n._doc.body.appendChild(i);i.focus();i.blur();n.focusEditor();n._doc.body.removeChild(i)}catch(o){}},isShadowed:function(){var t,n,i,r,u;if(!this.isControl())return!1;if(t=this._getSelection(),n=this._createRange(t),i=Sys.Extended.UI.HtmlEditor.isIE?n.item(0):n.startContainer.childNodes.item(n.startOffset),i.tagName&&i.tagName.toUpperCase()=="IMG"&&i.getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute)&&i.getAttribute(Sys.Extended.UI.HtmlEditor.attachedIdAttribute).length>0){if(r=this.getAttachedElement(i),r!=null){if(Sys.Extended.UI.HtmlEditor.isIE)n=this._doc.body.createControlRange(),n.add(r),n.select();else try{u=Sys.Extended.UI.HtmlEditor.__getIndex(r);t.collapseToEnd();this._removeAllRanges(t);n=this._createRange(t);n.setStart(r.parentNode,u);n.setEnd(r.parentNode,u+1);this._selectRange(t,n)}catch(f){return!0}return!1}return!0}return!1},_ifShadow:function(){var e,f,u,t;if(Sys.Extended.UI.HtmlEditor.isIE)try{e=this._doc.selection}catch(o){return!1}for(var i=this,r=null,n=Sys.Extended.UI.HtmlEditor.getSelParent(i);n&&(n.nodeType==3||n.tagName&&n.tagName.toUpperCase()!="BODY");){if(n.nodeType==3||!n.tagName){n=n.parentNode;continue}if(f=n.tagName.toUpperCase(),f=="TABLE"&&n.getAttribute(Sys.Extended.UI.HtmlEditor.noContextMenuAttribute)&&n.getAttribute(Sys.Extended.UI.HtmlEditor.noContextMenuAttribute)=="yes"){r=n.rows.item(0).cells.item(0).firstChild;Sys.Extended.UI.HtmlEditor.isIE&&f=="P"&&(r=r.firstChild);break}n=n.parentNode}if(r!=null)if(u=i._getSelection(),t=i._createRange(u),Sys.Extended.UI.HtmlEditor.isIE)t=i._doc.body.createControlRange(),t.add(r),t.select();else try{u.collapseToEnd();i._removeAllRanges(u);t=i._createRange(u);t.setStart(r.parentNode,0);t.setEnd(r.parentNode,1);i._selectRange(u,t)}catch(o){}},_saveContent:function(){var n,t,i;try{try{n=this._getSelection();t=this._createRange(n)}catch(r){}i=new Sys.Extended.UI.HtmlEditor._Marker(this,t,n)}catch(r){return}for(this.__stack||(this.__stack=[],this.__stackPos=0);this.__stackPos<this.__stack.length;)this.__stack.pop();this.__stack.length==Sys.Extended.UI.HtmlEditor.__stackMaxSize&&(this.__stack.reverse(),this.__stack.pop(),this.__stack.reverse());this.__stack.push(i);this.__stackPos=this.__stack.length},_restoreContent:function(){var t,u,r,c,e,o,f,s,l,h,v,i,n,a;if(this.__stack&&this.__stackPos>=0&&this.__stackPos<this.__stack.length){if(t=this.__stack[this.__stackPos],Sys.Extended.UI.HtmlEditor.isIE){function y(n,t,i,r,u){return t.replace(/\salign=[^\s>]*/ig,"")+(r=='"X"'?"":"align="+r)+u.replace(/\salign=[^\s>]*/ig,"")}for(c=this._doc.body.getElementsByTagName("EMBED"),e=[],n=0;n<c.length;n++)e.push(c[n]);for(o=0;o<e.length;o++)e[o].parentNode.removeChild(e[o]);if(f=t._save.replace(/&amp;/ig,"&"),f=f.replace(/(<embed(?:.*?))(teoalign=)(\"[^\"]*\")((?:.*?)>)/ig,y),this._doc.body.innerHTML="!!!<span><\/span>"+Sys.Extended.UI.HtmlEditor.Trim(f),this._doc.body.firstChild&&this._doc.body.removeChild(this._doc.body.firstChild),this._doc.body.firstChild&&this._doc.body.removeChild(this._doc.body.firstChild),s=Sys.Extended.UI.HtmlEditor.getHrefsText(f),Sys.Extended.UI.HtmlEditor.setHrefsText(this._doc.body,s),this._editPanel.get_relativeImages()&&(s=Sys.Extended.UI.HtmlEditor.getImagesText(f),Sys.Extended.UI.HtmlEditor.setImagesText(this._doc.body,s)),Sys.Extended.UI.HtmlEditor.setNames(this._doc.body,t._nArr),Sys.Extended.UI.HtmlEditor.operateAnchors(this,this._doc,!this._editPanel.get_showAnchors()),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,this._doc,!this._editPanel.get_showPlaceHolders()),t._tree!=null){i=this._doc.body;try{for(n=t._tree.length-1;n>=0;n--)i=i.childNodes.item(t._tree[n])}catch(p){this.__stackPos>0&&(this.__stackPos--,this._restoreContent(),this.__stackPos++);return}try{l=this._doc.body.createControlRange();l.add(i);l.select()}catch(p){}}else h=this,setTimeout(function(){try{if(h._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel){if(u=h._getSelection(),r=h._createRange(u),u.type.toLowerCase()!="control")try{r.moveToPoint(t._offsetLeft,t._offsetTop)}catch(n){}r.select()}}catch(n){}},0)}else{if(Sys.Extended.UI.HtmlEditor.isOpera)this._doc.body.innerHTML=Sys.Extended.UI.HtmlEditor.Trim(t._save);else for(this._doc.body.innerHTML="",n=0;n<t._save.childNodes.length;n++)this._doc.body.appendChild(t._save.childNodes.item(n).cloneNode(!0));Sys.Extended.UI.HtmlEditor.operateAnchors(this,this._doc,!this._editPanel.get_showAnchors());Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,this._doc,!this._editPanel.get_showPlaceHolders());try{u=this._getSelection();r=this._createRange();this._removeAllRanges(u)}catch(p){}for(v="",i=this._doc.body,n=t._tree.length-1;n>=0;n--)v+=" "+t._tree[n],i=i.childNodes.item(t._tree[n]);a=t._offset;try{r.setStart(i,a);r.setEnd(i,a)}catch(p){Sys.Extended.UI.HtmlEditor.inspectForShadows(this._doc.body);return}try{this._selectRange(u,r)}catch(p){}}try{Sys.Extended.UI.HtmlEditor.inspectForShadows(this._doc.body)}catch(p){}}},SaveContent:function(){this._saveContent()},RestoreContent:function(){this._undo(!1)},_undo:function(n){var i,t;if(this.__stack&&this.__stackPos>0){this.__stackPos==this.__stack.length&&n&&this._saveContent();do i=Sys.Extended.UI.HtmlEditor.Trim(this._doc.body.innerHTML),this.__stackPos--,this._restoreContent();while(Sys.Extended.UI.HtmlEditor.Trim(this._doc.body.innerHTML)==i&&this.__stackPos>0&&n);t=this;setTimeout(function(){try{t._ifShadow()}catch(i){}if(t._editPanel==Sys.Extended.UI.HtmlEditor.LastFocusedEditPanel)try{t._editPanel.updateToolbar()}catch(i){}n||t.onContentChanged()},0)}},_redo:function(){var i,t,n;this.__stack&&this.__stackPos<this.__stack.length-1&&(this.__stackPos++,n=this,Sys.Extended.UI.HtmlEditor.isIE&&(i=n._doc.body.getElementsByTagName("EMBED").length,i>0&&(t=n._body.ownerDocument.createElement("div"),n._body.appendChild(t),setTimeout(function(){n._body.removeChild(t)},0))),this._restoreContent(),n=this,setTimeout(function(){n._ifShadow();n._editPanel.updateToolbar()},0))},undo:function(){this._undo(!0);this.onContentChanged()},redo:function(){this._redo();this.onContentChanged()},_contextMenuCallP:function(){},onContentChanged:function(){},_copyCut:function(n,t){var v=this,c,f,l,e,a,u,h,y,r,i;if(Sys.Extended.UI.HtmlEditor.isIE){var r=this._getSelection(),i=this._createRange(r),s=!1,o="";if(n=="x"&&this._saveContent(),r.type.toLowerCase()=="control")s=!0,o=Sys.Extended.UI.HtmlEditor.getHTML(i.item(0),!0);else if(i.text!=""){if(s=!0,o=i.htmlText,c=i.duplicate(),f=this._getTextNodeCollection(),f.length<1)return;if(l=Sys.Extended.UI.HtmlEditor._commonParent(f[0],f[f.length-1]),l!=null&&f[0].previousSibling&&f[0].previousSibling.nodeType==3)for(e=l.parent;e&&e.tagName.toUpperCase()!="BODY"&&Sys.Extended.UI.HtmlEditor.isStyleTag(e.tagName);)a=e.cloneNode(!1),a.innerHTML=o,o=a.outerHTML,e=e.parentNode;r=this._getSelection();r.empty();i=this._createRange(r);i.setEndPoint("EndToEnd",c);i.setEndPoint("StartToStart",c);i.select()}else i.htmlText!=""&&(s=!0,o=i.htmlText);s?(u=this._doc.createElement("DIV"),u.innerHTML="!!!<span><\/span>"+o,u.removeChild(u.firstChild),u.removeChild(u.firstChild),h=Sys.Extended.UI.HtmlEditor.getHTML(u,!1,!0),y=new RegExp("(<[/]?)(teo"+Sys.Extended.UI.HtmlEditor.smartClassName+":)","ig"),h=h.replace(y,"$1"),delete u,this._contentCopy(h,!0),i.select(),n=="x"&&(r.clear(),this._clearP())):n=="x"&&(r.clear(),this._clearP());t&&setTimeout(function(){v._editPanel.updateToolbar()},0)}else n=="x"?(this._saveContent(),r=this._getSelection(),i=this._createRange(r),this._removeAllRanges(r),i.deleteContents(),this._doc.body.innerHTML==""&&(this._doc.body.innerHTML="<br/>",i.setStart(this._doc.body,0),i.setEnd(this._doc.body,0)),v.onContentChanged(),this._selectRange(r,i)):(r=this._getSelection(),i=this._createRange(r),this._removeAllRanges(r),alert(String.format(Sys.Extended.UI.Resources.HTMLEditor_toolbar_button_Use_verb,Sys.Extended.UI.HtmlEditor.isSafari&&navigator.userAgent.indexOf("mac")!=-1?"Apple-C":"Ctrl-C")),this._selectRange(r,i))},_paste:function(n,t){var f=this,v=this._getSelection(),o=this._createRange(v),l,a,r,i,s,h,e,c,u;if(!n){l=o.offsetLeft;a=o.offsetTop;this.insertHTML(this._getPlain());f.onContentChanged();return}if(!this._editPanel.get_noPaste()){if(l=o.offsetLeft,a=o.offsetTop,r=this._doc.createElement("span"),s=this._contentCopy("",!1,t),/<[\/]*p[\s>]+/i.test(s)||/<[\/]*h/i.test(s))i=this._getSafePlace();else{if(i=this._doc.createElement("SPAN"),i.id=Sys.Extended.UI.HtmlEditor.smartClassName,!this.insertHTML(Sys.Extended.UI.HtmlEditor.getHTML(i,!0)))return;i=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName);i&&(i.id=null,i.removeAttribute("id"),i.setAttribute("para","no"))}if(r.innerHTML=s,i){if(this._checkImages(r),h=i.parentNode,e=i.getAttribute("para"),e!="no"){if(e.indexOf("left")>=0&&r.firstChild&&r.firstChild.tagName&&r.firstChild.tagName.toUpperCase()=="P"){while(r.firstChild.firstChild)i.previousSibling.appendChild(r.firstChild.firstChild);r.removeChild(r.firstChild)}if(e.indexOf("right")>=0&&r.lastChild&&r.lastChild.tagName&&r.lastChild.tagName.toUpperCase()=="P"){while(r.lastChild.lastChild)i.nextSibling.insertBefore(r.lastChild.lastChild,i.nextSibling.firstChild);r.removeChild(r.lastChild)}}if(c=i,u=null,r.childNodes.length==0&&e.indexOf("left")>=0&&e.indexOf("right")>=0){for(i.nextSibling.firstChild&&(u=this._doc.createElement("span"),c=u,u.innerHTML="111",i.previousSibling.appendChild(u));i.nextSibling.firstChild;)i.previousSibling.appendChild(i.nextSibling.firstChild);h.removeChild(i.nextSibling)}else while(r.firstChild)h.insertBefore(r.firstChild,i);setTimeout(function(){var t=f._getSelection(),n=f._createRange(t);if(t.type.toLowerCase()=="control")while(n.length>0)n.remove(0);try{n.collapse(!1)}catch(r){}f.focusEditor();Sys.Extended.UI.HtmlEditor._setCursor(c,f);u&&u.parentNode.removeChild(u);h.removeChild(i);Sys.Extended.UI.HtmlEditor.inspectForShadows(f._doc.body);f.onContentChanged();n.select()},0)}}},_contentCopy:function(n,t,i){var o,r,c,a,v,h,f,l,s,u,e,y;if(n!=""&&(n=n.replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/ig,"$1&nbsp;$3").replace(/(<td[^>]*?>)\s*(&nbsp;)\s*(<\/td[^>]*?>)/ig,"$1<br/>$3").replace(/(<p[^>]*?>)\s*(&nbsp;)\s*(<\/p[^>]*?>)/ig,"$1<br/>$3")),o=this._doc.createElement("iframe"),o.width="0",o.height="0",Sys.Extended.UI.HtmlEditor.isIE&&(o.src="javascript:false;"),this._doc.appendChild(o),r=o.contentWindow.document,r.write("<html><head><\/head><body>"+n+"<\/body><\/html>"),r.close(),r.body.contentEditable=!0,c=r.body.createTextRange(),a=!1,n==""){for(c.execCommand("paste"),v=r.createElement("DIV"),u=0;u<r.body.childNodes.length;u++)if(h=r.body.childNodes.item(u),h.nodeType==8&&(f=""+h.data+"",f.search(/StartFragment/i)>=0&&h.nextSibling&&h.nextSibling.nodeType==3&&(f=""+h.nextSibling.data+"",f.length&&f.charCodeAt(0)==160))){f=f.substr(1);h.nextSibling.data=f;a=!0;break}if(typeof i!="undefined"&&i&&(r.body.innerHTML=Sys.Extended.UI.HtmlEditor.cleanUp(r.body.innerHTML)),f=Sys.Extended.UI.HtmlEditor.Trim(Sys.Extended.UI.HtmlEditor.getHTML(r.body,!1,!0)),f=f.replace(/(<script(?:[^>]*?)>(?:[^<]*?)<\/script(?:[^>]*?)>)/gi,""),r.body.innerHTML=f,!t){for(Sys.Extended.UI.HtmlEditor.operateAnchors(this,r,!this.showAnchors),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,r,!this.showPlaceHolders),l=r.body.getElementsByTagName("EMBED"),s=[],u=0;u<l.length;u++)s.push(l[u]);for(e=0;e<s.length;e++)s[e].parentNode.removeChild(s[e])}delete c;delete v;t&&Sys.Extended.UI.HtmlEditor.isIE&&(c=r.body.createTextRange())}t&&Sys.Extended.UI.HtmlEditor.isIE&&(n!=""&&(Sys.Extended.UI.HtmlEditor.operateAnchors(this,r,!0),Sys.Extended.UI.HtmlEditor.operatePlaceHolders(this,r,!0)),c.select(),c.execCommand("copy"));var p=Sys.Extended.UI.HtmlEditor.Trim(r.body.innerHTML).replace(/<br\s*[\/]*>\s*<\/td>/ig,"<\/td>").replace(/(<td[^>]*?>)([\s ]*?)(<\/td[^>]*?>)/ig,"$1&nbsp;$3").replace(/(<p[^>]*?>)\s*(<br[^>]*?>)\s*(<\/p[^>]*?>)/ig,"$1&nbsp;$3").replace(/(<embed(?:.*?))(wmode=)(\"[^\"]*\")((?:.*?)>)/ig,"$1pseudomode=$3$4").replace(/(<embed)([^>]*?>)/ig,'$1 wmode="transparent"$2'),l=r.body.getElementsByTagName("EMBED"),s=[];for(u=0;u<l.length;u++)s.push(l[u]);for(e=0;e<s.length;e++)s[e].parentNode.removeChild(s[e]);return o.src="",y=this,y._doc.removeChild(o),delete o,p},insertHTML:function(n,t){var v,g,i,r,a,h,c,f,l,e,p;if(this.focusEditor(),v=this._getSelection(),typeof t=="undefined"&&(t=this._createRange(v)),Sys.Extended.UI.HtmlEditor.isIE){function w(n,t){return'<span class="'+Sys.Extended.UI.HtmlEditor.smartClassName+"_script\" style='display:none;visibility:hidden;'>"+t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")+"<\/span>"}function b(n,t){return t.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}var u='<span id="'+Sys.Extended.UI.HtmlEditor.smartClassName+'">111<span><\/span>'+n+"<\/span>",k=Sys.Extended.UI.HtmlEditor.getHrefsText(u),d=Sys.Extended.UI.HtmlEditor.getImagesText(u);u=this._editPanel.get_noScript()?u.replace(/(<script(?:[^>]*?)>.*?<\/script(?:[^>]*?)>)/gi,""):u.replace(/(<script(?:[^>]*?)>.*?<\/script(?:[^>]*?)>)/gi,w);g=this;try{if(t.pasteHTML)t.pasteHTML(u);else{for(r=this._doc.createElement("DIV"),r.innerHTML=u;r.firstChild;)t(0).parentNode.insertBefore(r.firstChild,t(0));t(0).parentNode.removeChild(t(0));t.remove(0);delete r}}catch(nt){return!1}for(i=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName),i.innerHTML="<span>qqq<\/span>"+Sys.Extended.UI.HtmlEditor.getHTML(i,!1,!0).replace(new RegExp("<span(?:[^>]*?)class="+Sys.Extended.UI.HtmlEditor.smartClassName+"_script(?:[^>]*?)>(.*?)<\/span(?:[^>]*?)>","gi"),b)+"<span>qqq<\/span>",i.removeChild(i.firstChild),i.removeChild(i.lastChild),Sys.Extended.UI.HtmlEditor.setHrefsText(i,k),Sys.Extended.UI.HtmlEditor.setImagesText(i,d),i.firstChild&&i.removeChild(i.firstChild),i.firstChild&&i.removeChild(i.firstChild);i.firstChild;)i.parentNode.insertBefore(i.firstChild,i);return i.parentNode.removeChild(i),delete i,!0}for(r=this._doc.createElement("div"),r.innerHTML=n,a=r.getElementsByTagName("EMBED"),h=[],f=0;f<a.length;f++)h.push(a[f]);for(c=0;c<h.length;c++){var s=h[c],o=document.createElement("IMG"),y=s.attributes;for(o.src=this._images_list[1],o.setAttribute("dummytag","embed"),f=0;f<y.length;++f)(l=y.item(f),l.specified)&&(e=l.name.toLowerCase(),p=l.value,e=="src"?e="dummysrc":e=="bgcolor"?e="dummybgcolor":e=="wmode"&&(e="pseudomode"),o.setAttribute(e,p));o.getAttribute("type");o.style.cssText="border: 1px dotted #000000; background-image: url('"+(o.getAttribute("type").toLowerCase()=="application/x-mplayer2"?this._images_list[3]:this._images_list[2])+"'); background-position: center; background-repeat: no-repeat; background-color: #c0c0c0;";s.parentNode.insertBefore(o,s);s.parentNode.removeChild(s)}return this.insertNodeAtSelection(r,t)},insertNodeAtSelection:function(n,t){var r,i,f,u;if(Sys.Extended.UI.HtmlEditor.isIE)return!1;if(r=this._getSelection(),typeof t=="undefined")try{t=this._createRange(r)}catch(s){return this._removeAllRanges(r),!1}if((i=t.startContainer,f=t.startOffset,i.ownerDocument.id!="EditorDocument")||t.startContainer.nodeType==1&&t.startContainer.tagName.toUpperCase()=="TR"||t.endContainer.nodeType==1&&t.endContainer.tagName.toUpperCase()=="TR")return!1;this._removeAllRanges(r);t.deleteContents();try{t=this._createRange()}catch(s){return this._removeAllRanges(r),!1}switch(i.nodeType){case 3:for(f>0&&(i=i.splitText(f));n.firstChild;)i.parentNode.insertBefore(n.firstChild,i);t.setStart(i,0);t.setEnd(i,0);break;case 1:case 11:try{if(this._removeAllRanges(r),i.childNodes.length>=f+1){for(i=i.childNodes.item(f);n.firstChild;)i.parentNode.insertBefore(n.firstChild,i);u=this._doc.createTextNode("");i.parentNode.insertBefore(u,i);i=u}else{if(u=this._doc.createTextNode(""),Sys.Extended.UI.HtmlEditor.canHaveChildren(i)){while(n.firstChild)i.appendChild(n.firstChild);i.appendChild(u)}else{while(n.firstChild)i.parentNode.insertBefore(n.firstChild,i);i.parentNode.insertBefore(u,i)}i=u}if(i.nodeType==1){for(var e=i.parentNode,h=e,o=0;o<e.childNodes.length;o++)if(i==e.childNodes.item(o))break;t.setStart(e,o);t.setEnd(e,o)}else t.setStart(i,0),t.setEnd(i,0)}catch(s){return this._removeAllRanges(r),!1}}return this._selectRange(r,t),!0},trickWithStyles:function(n){var i=this,r=i._doc.getElementById(n),t,f,e,o,s,h,u;if(r!=null)if(r.nextSibling&&r.nextSibling.nodeType==3){if(t=r.nextSibling,r.parentNode.removeChild(r),f=(""+t.data+"").indexOf(" "),f>0?t.splitText(f):f==0&&t.splitText(1),i.n_arr!=null)for(e=0;e<i.n_arr.length;e++)i.MSIE_applyCssStyle(i.n_arr[e],[t],!1);if(i.n_arr=null,o=i._getSelection(),Sys.Extended.UI.HtmlEditor.isIE){h=i._createRange(o);u=i._doc.createElement("span");t.nextSibling?t.parentNode.insertBefore(u,t.nextSibling):t.parentNode.appendChild(u);try{h.moveToElementText(u);h.select()}catch(c){}u.parentNode.removeChild(u)}else s=i._doc.createRange(),s.setStart(t,t.length),s.setEnd(t,t.length),i._removeAllRanges(o),i._selectRange(o,s)}else r.parentNode.removeChild(r)},_getParent:function(n){return Sys.Extended.UI.HtmlEditor.isIE?n.parentElement():n.startContainer},_checkImages:function(n){var f,u,t,i,r;if(this._editPanel.get_relativeImages())for(f=n.getElementsByTagName("IMG"),u=0;u<f.length;u++)t=f[u],t.src.indexOf("http://")>=0&&(i=t.src,t.src="qwerty.gif",r=t.src.indexOf("qwerty.gif"),i.substr(0,r)==t.src.substr(0,r)&&(i=i.substr(r,i.length-r)),t.src=i)},_getSafePlace:function(n){var t=this._doc.createElement("SPAN"),e=this,i,r;if(t.id=Sys.Extended.UI.HtmlEditor.smartClassName,typeof n=="undefined"){if(!this.insertHTML(Sys.Extended.UI.HtmlEditor.getHTML(t,!0)))return null}else n.nextSibling==null?n.parentNode.appendChild(t):n.parentNode.insertBefore(t,n.nextSibling),n.parentNode.removeChild(n);for(t=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName),t.id=null,t.removeAttribute("id"),t.setAttribute("para","no"),i=t.parentNode,r=i.tagName.toUpperCase();r!="BODY"&&r!="TD"&&r!="P"&&r!="DIV";)if(Sys.Extended.UI.HtmlEditor.isStyleTag(i.tagName))i=i.parentNode,r=i.tagName.toUpperCase();else break;if(r=="P"){t.setAttribute("para","");function f(n,t,r,u){var o=Sys.Extended.UI.HtmlEditor.myClone(r,e._doc,!1),s,h;for(n&&o.appendChild(n);t;)(t.nodeType==1||t.nodeType==3&&Sys.Extended.UI.HtmlEditor.Trim(""+t.data+"").length>0)&&(s=null,t.tagName&&t.tagName.toUpperCase()=="SCRIPT"&&(s=t.text),h=Sys.Extended.UI.HtmlEditor.myClone(t,e._doc,!0),o.childNodes.length!=0&&u?o.insertBefore(h,o.firstChild):o.appendChild(h),s!=null&&(h.text=s)),t=u?t.previousSibling:t.nextSibling;return o.childNodes.length==0&&(delete o,o=null),r==i?o:f(o,u?r.previousSibling:r.nextSibling,r.parentNode,u)}var o=f(null,t.previousSibling,t.parentNode,!0),s=f(null,t.nextSibling,t.parentNode,!1),u=i.parentNode;o&&(u.insertBefore(o,i),t.setAttribute("para",t.getAttribute("para")+" left"));u.insertBefore(t,i);s&&(u.insertBefore(s,i),t.setAttribute("para",t.getAttribute("para")+" right"));u.removeChild(i)}return t},noContextMenuAttributeName:function(){return Sys.Extended.UI.HtmlEditor.noContextMenuAttribute},_getTextNodeCollection:function(n){function k(n,t){for(var i,u;n;){if(n.id&&n.id==c){b=!0;return}if(n.nodeType==3){while(n.nextSibling&&(n.nextSibling.nodeType==3||!Sys.Extended.UI.HtmlEditor.isIE&&typeof h.__saveBM__!="undefined"&&h.__saveBM__!=null&&h.__saveBM__[0]==n.nextSibling))n.nextSibling.nodeType==3?n.data=""+n.data+""+n.nextSibling.data+"":(h.__saveBM__[0]=n,h.__saveBM__[1]=(""+n.data+"").length),n.parentNode.removeChild(n.nextSibling);Sys.Extended.UI.HtmlEditor.Trim(""+n.data+"").length>0&&r.push(n)}else i=n.tagName,n.tagName&&(i=i.toUpperCase(),i=="MAP"||i=="AREA"||i=="SCRIPT"||i=="NOSCRIPT"||n.style&&(Sys.Extended.UI.HtmlEditor.getStyle(n,"display")=="none"||Sys.Extended.UI.HtmlEditor.getStyle(n,"visibility")=="hidden")||k(n.firstChild,!1));if(b)return;if(u=n.parentNode,t)while(n.nextSibling==null)n=n.parentNode;n=n.nextSibling}}var r=[],a,v,s,t,i,b,h,f,y;if(this.isControl())return r;var l=this._getSelection(),o=this._createRange(l),c=Sys.Extended.UI.HtmlEditor.smartClassName+"_right",p=Sys.Extended.UI.HtmlEditor.smartClassName+"_left",u=null,e=null,w;if(typeof n=="undefined")if(Sys.Extended.UI.HtmlEditor.isIE?(u=o.duplicate(),e=o.duplicate(),u.setEndPoint("EndToStart",o),e.setEndPoint("StartToEnd",o)):(u=o.cloneRange(),e=o.cloneRange(),u.setEnd(u.startContainer,u.startOffset),e.setStart(e.endContainer,e.endOffset),w=u.endOffset),this.insertHTML("<span id='"+c+"'/>",e)){if(Sys.Extended.UI.HtmlEditor.isOpera&&(u.setEnd(u.startContainer,w),u.setStart(u.startContainer,w)),!this.insertHTML("<span id='"+p+"'/>",u))return a=this._doc.getElementById(c),a!=null&&(f=a.parentNode,f.removeChild(a)),v=this._doc.getElementById(rl),v!=null&&(f=v.parentNode,f.removeChild(v)),r}else return r;else s=this._doc.createElement("SPAN"),s.id=c,this._doc.body.appendChild(s),s=this._doc.createElement("SPAN"),s.id=p,this._doc.body.insertBefore(s,this._doc.body.firstChild);if(t=this._doc.getElementById(p),i=this._doc.getElementById(c),t==null||i==null)return t!=null&&(f=t.parentNode,f.removeChild(t)),i!=null&&(f=i.parentNode,f.removeChild(i)),[];while(t.firstChild)t.removeChild(t.firstChild);while(i.firstChild)i.removeChild(i.firstChild);while(t.previousSibling&&t.previousSibling.nodeType==3&&Sys.Extended.UI.HtmlEditor.Trim(""+t.previousSibling.data+"").length==0)t.parentNode.removeChild(t.previousSibling);while(t.nextSibling&&t.nextSibling.nodeType==3&&Sys.Extended.UI.HtmlEditor.Trim(""+t.nextSibling.data+"").length==0)t.parentNode.removeChild(t.nextSibling);while(i.previousSibling&&i.previousSibling.nodeType==3&&Sys.Extended.UI.HtmlEditor.Trim(""+i.previousSibling.data+"").length==0)i.parentNode.removeChild(i.previousSibling);while(i.nextSibling&&i.nextSibling.nodeType==3&&Sys.Extended.UI.HtmlEditor.Trim(""+i.nextSibling.data+"").length==0)i.parentNode.removeChild(i.nextSibling);return b=!1,h=this,k(t,!0),f=t.parentNode,f.removeChild(t),f=i.parentNode,f.removeChild(i),typeof n=="undefined"&&(Sys.Extended.UI.HtmlEditor.isIE?(l.empty(),e.select()):r.length>0&&(this._removeAllRanges(l),y=this._createRange(),y.setEnd(r[r.length-1],r[r.length-1].length),y.setStart(r[r.length-1],r[r.length-1].length),this._selectRange(l,y))),r},_getPlain:function(){var n=this._doc.createElement("textarea"),i,t;return n.width="0",n.height="0",this._doc.appendChild(n),i=n.createTextRange(),i.execCommand("paste"),t=n.value,t=t.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"").replace(/\n/g,"<br/>"),this._doc.removeChild(n),t},_execCommand:function(n,t,i){var f=this,r,u,e,i;if(!Sys.Extended.UI.HtmlEditor.isIE||this.isControl()||(r=this._getSelection(),u=this._createRange(r),e=u.parentElement(),e.tagName.toUpperCase()!="TEXTAREA")){n.toLowerCase()!="createlink"&&this._saveContent();switch(n.toLowerCase()){case"createlink":Sys.Extended.UI.HtmlEditor.isIE||!t?this._doc.execCommand(n,t,i):(i=prompt("Enter URL"))&&this._doc.execCommand(n,!1,i);break;case"backcolor":case"forecolor":case"fontname":case"fontsize":this.MSIE_applyCommand(n.toLowerCase(),i);break;case"indent":this.MSIE_indent(!0);break;case"outdent":this.MSIE_indent(!1);break;case"justifyleft":this.MSIE_justify("left");break;case"justifyfull":this.MSIE_justify("justify");break;case"justifycenter":this.MSIE_justify("center");break;case"justifyright":this.MSIE_justify("right");break;case"paragraph":this.MSIE_justify("remain",!1,"P");break;case"formatblock":if(i!=null&&typeof i=="string"&&i.length==2&&i.substr(0,1).toUpperCase()=="H"&&parseInt(i.substr(1,1))>0){this.MSIE_justify("remain",!1,i);break}this._doc.execCommand(n,t,i);break;case"insertunorderedlist":this.MSIE_list("UL");break;case"insertorderedlist":this.MSIE_list("OL");break;case"bold":case"italic":case"underline":case"strikethrough":case"superscript":case"subscript":this.MSIE_applyCommand(n.toLowerCase());break;default:this._doc.execCommand(n,t,i)}this.onContentChanged();Sys.Extended.UI.HtmlEditor.isIE||(r=this._getSelection(),u=this._createRange(r),this._removeAllRanges(r),this._selectRange(r,u),this.focusEditor());f=this;setTimeout(function(){f._editPanel.updateToolbar()},0)}},MSIE_indent:function(n){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.MSIE_indent)(n)},MSIE_justify:function(n,t,i){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.MSIE_justify)(n,t,i)},MSIE_list:function(n){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.MSIE_list)(n)},getSelectionAfterOperation:function(n){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.getSelectionAfterOperation)(n)},setSelectionAfterOperation:function(n,t){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.setSelectionAfterOperation)(n,t)},get_paragraphs:function(){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.get_paragraphs)()},getPseudoP:function(){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.getPseudoP)()},getPseudoP_Recur:function(n,t,i){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.getPseudoP_Recur)(n,t,i)},unWrap:function(n,t){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.unWrap)(n,t)},tryUnWrap:function(n,t,i){return Function.createDelegate(this,Sys.Extended.UI.HtmlEditor.tryUnWrap)(n,t,i)},MSIE_applyCommand:function(n,t){var e=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML()),f;if(!this.isControl()){var u=this._getSelection(),r=this._createRange(u),s=Sys.Extended.UI.HtmlEditor.isIE?[r.boundingLeft,r.boundingTop]:[r.startContainer,r.startOffset],o=Sys.Extended.UI.HtmlEditor.isIE&&r.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&e.length>0,i={name:"none",value:"none"};switch(n.toLowerCase()){case"bold":i={name:"font-weight",value:"bold",repl:!1};break;case"italic":i={name:"font-style",value:"italic",repl:!1};break;case"underline":i={name:"text-decoration",value:"underline",repl:!1};break;case"strikethrough":i={name:"text-decoration",value:"line-through",repl:!1};break;case"superscript":i={name:"vertical-align",value:"super",repl:!1};break;case"subscript":i={name:"vertical-align",value:"sub",repl:!1};break;case"forecolor":i={name:"color",value:t,repl:!1};break;case"backcolor":i={name:"background-color",value:t,repl:!1};break;case"fontname":i={name:"font-family",value:t,repl:!1};break;case"fontsize":i={name:"font-size",value:t,repl:!1}}if(o)f=this._getTextNodeCollection(),this.MSIE_applyCssStyle(i,f,!0);else{if(this.isControl())return;f=this._tryExpand();f.length>0?(this.MSIE_applyCssStyle(i,f,!1),Sys.Extended.UI.HtmlEditor.isIE&&this.__saveBM__!=null?(u=this._getSelection(),r=this._createRange(u),r.moveToBookmark(this.__saveBM__),r.select(),this.__saveBM__=null):this.__saveBM__!=null&&(this.__saveBM__[0].nodeType==3?(u=this._getSelection(),r=this._doc.createRange(),r.setStart(this.__saveBM__[0],this.__saveBM__[1]),r.setEnd(this.__saveBM__[0],this.__saveBM__[1]),this._removeAllRanges(u),this._selectRange(u,r)):(this._trySelect(this.__saveBM__[0],this.__saveBM__[0]),this.__saveBM__[0].parentNode.removeChild(this.__saveBM__[0])),this.__saveBM__=null)):this._setStyleForTyping(i)}}},MSIE_applyCssStyle:function(n,t,i){var u=n.name.replace(/\-(\w)/g,function(n,t){return t.toUpperCase()}),f=n.value,lt=n.repl,ft=!1,et=!1,h,a,c,r,b,p,e,s,d,l,tt,it,ht,st,w,rt,ut;this._saveContent();var at=Sys.Extended.UI.HtmlEditor.smartClassName+"_right",vt=Sys.Extended.UI.HtmlEditor.smartClassName+"_left",y=this._doc.createElement("SPAN");for(y.id=vt,h=this._doc.createElement("SPAN"),h.id=at,t[0].parentNode.insertBefore(y,t[0]),t[t.length-1].nextSibling!=null?t[t.length-1].parentNode.insertBefore(h,t[t.length-1].nextSibling):t[t.length-1].parentNode.appendChild(h),Sys.Extended.UI.HtmlEditor.unStyle(y),Sys.Extended.UI.HtmlEditor.unStyle(h),a=[],e=0;e<t.length;e++){for(c=t[e],r=c.parentNode,b=0;b<a.length;b++)if(p=a[b],p.parent==r){p.textNodes.push(c);break}b==a.length&&a.push({parent:r,textNodes:[c]})}for(e=0;e<a.length;e++)if(p=a[e],p.textNodes.length>1){var o=p.textNodes,nt=this._doc.createElement("SPAN"),k=this._doc.createElement("SPAN");o[0].parentNode.insertBefore(nt,o[0]);o[o.length-1].nextSibling!=null?o[o.length-1].parentNode.insertBefore(k,o[o.length-1].nextSibling):o[o.length-1].parentNode.appendChild(k);Sys.Extended.UI.HtmlEditor._moveTagsUp(nt,k);nt.parentNode.removeChild(nt);k.parentNode.removeChild(k)}for(e=0;e<t.length;e++){for(var c=t[e],r=c.parentNode,ot=!1;r&&r.tagName&&r.childNodes.length==1&&Sys.Extended.UI.HtmlEditor.isStyleTag(r.tagName);){if(s=r.tagName.toUpperCase(),(s=="I"||s=="EM")&&n.name=="font-style"||(s=="B"||s=="STRONG")&&n.name=="font-weight"||(s=="S"||s=="STRIKE")&&n.name=="text-decoration"||s=="U"&&n.name=="text-decoration"||(s=="SUB"||s=="SUP")&&n.name=="vertical-align"){for(d=r,r=r.parentNode;d.firstChild;)r.insertBefore(d.firstChild,d);r.removeChild(d);ot=!0;continue}else if(r.style&&r.style[u]&&r.style[u].length>0){if(l=r.style[u],u.toLowerCase().indexOf("color")>=0||u=="fontFamily"||u=="fontSize")r.style[u]=f;else if(lt)try{r.style[u]=r.style[u]+" "+f;l==r.style[u]&&(r.style[u]=f)}catch(yt){r.style[u]=f}else if(ft)if(et)r.style[u]=l.replace(f,"").replace(/,/,"");else try{r.style[u]=r.style[u]+" "+f;l==r.style[u]&&(r.style[u]=f)}catch(yt){r.style[u]=f}else{if(tt=l.replace(f,""),u=="fontWeight"&&l.toString()=="700"&&(tt=""),tt==l)try{r.style[u]=r.style[u]+" "+f;l==r.style[u]&&(r.style[u]=f)}catch(yt){r.style[u]=f}else r.style[u]=tt.replace(/,/,""),et=!0;ft=!0}ot=!0}r=r.parentNode}ot||et||(it=this._doc.createElement("SPAN"),it.style[u]=f,ht=c.parentNode,ht.insertBefore(it,c),it.appendChild(c),ft=!0)}var v=Sys.Extended.UI.HtmlEditor._commonTotalParent(y,h),ct=v.parent.childNodes.item(v.indexFirst).previousSibling,g=v.parent.childNodes.item(v.indexLast).nextSibling;y.parentNode.removeChild(y);h.parentNode.removeChild(h);st=0;w=v.parent.childNodes.length;ct!=null&&(st=Sys.Extended.UI.HtmlEditor.__getIndex(ct));g!=null&&(w=Sys.Extended.UI.HtmlEditor.__getIndex(g)+1,w<v.parent.childNodes.length&&(g.nodeType==3?w++:g.nodeType==1&&(rt=g.tagName.toUpperCase(),rt!="TR"&&rt!="TD"&&rt!="LI"&&w++)));Sys.Extended.UI.HtmlEditor.spanJoiner(v.parent,this._doc,st,w);ut=this;i&&ut._selectRng(t);setTimeout(function(){Sys.Extended.UI.HtmlEditor.isIE||ut.focusEditor();ut._editPanel.updateToolbar()},0)},_tryExpand:function(n){function w(n){var t=/[\d\w]/;return t.test(n)?!1:(t=/[\u0080-\u024F]/,t.test(n))?!1:(t=/[\u0370-\u2000]/,t.test(n))?!1:!0}var b=[],o,s,l=this._getSelection(),t=this._createRange(l),h,c,k=Sys.Extended.UI.HtmlEditor.smartClassName+"_right_add",d=Sys.Extended.UI.HtmlEditor.smartClassName+"_left_add",a=Sys.Extended.UI.HtmlEditor.smartClassName+"_middle_add",y,f;if(Sys.Extended.UI.HtmlEditor.isIE&&typeof n=="undefined"&&(t.execCommand("bold"),this.__saveBM__=t.getBookmark(),t.execCommand("bold")),Sys.Extended.UI.HtmlEditor.isIE){var r=null,p="<span id="+a+"><\/span>",v=t.duplicate();try{t.pasteHTML(p)}catch(g){}if(r=this._doc.getElementById(a),r==null)return[];if(typeof n!="undefined"&&(this.__saveBM__=r),r.nextSibling!=null&&!Sys.Extended.UI.HtmlEditor.isInlineElement(r.nextSibling))return r.parentNode.removeChild(r),[];if(t.expand("word"),t.select(),t.text.length==0)return r.parentNode.removeChild(r),v.select(),[];if(y=new RegExp(p,"ig"),!y.test(t.htmlText.replace(/[\n\r]/g,"")))return r.parentNode.removeChild(r),v.select(),[];if(y=new RegExp(p+"(<\/span>|&nbsp;|[\\s])*$","ig"),y.test(t.htmlText.replace(/[\n\r]/g,"")))return r.parentNode.removeChild(r),v.select(),[];while(t.text.length>0&&t.text.substr(t.text.length-1,1)==" ")if(t.moveEnd("character",-1),t.select(),t.text.length==0)return r.parentNode.removeChild(r),v.select(),[];return typeof n=="undefined"&&r.parentNode.removeChild(r),this._getTextNodeCollection()}if(!this.insertHTML("<span id='"+d+"'><\/span><span id='"+a+"'><\/span><span id='"+k+"'><\/span>"))return[];var i=this._doc.getElementById(d),u=this._doc.getElementById(k),e=this._doc.getElementById(a);Sys.Extended.UI.HtmlEditor.positionInParagraph(i,i.previousSibling,!0,i.parentNode,w);try{this._trySelect(i,u)}catch(g){}return(h=this._getSelection(),c=this._createRange(h),o=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML()),s=Sys.Extended.UI.HtmlEditor.isIE&&c.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&o.length>0,!s||this._getTextNodeCollection().length==0)?(f=this._doc.createTextNode(""),i.parentNode.insertBefore(f,i),i.parentNode.removeChild(i),u.parentNode.removeChild(u),e.parentNode.removeChild(e),t=this._doc.createRange(),t.setStart(f,0),t.setEnd(f,0),t.setStart(f,0),t.setEnd(f,0),this._removeAllRanges(l),this._selectRange(l,t),[]):(u.parentNode.insertBefore(i,e),Sys.Extended.UI.HtmlEditor.positionInParagraph(u,u.nextSibling,!1,u.parentNode,w),this._trySelect(i,u),h=this._getSelection(),c=this._createRange(h),o=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML()),s=Sys.Extended.UI.HtmlEditor.isIE&&c.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&o.length>0,!s||this._getTextNodeCollection().length==0)?(f=this._doc.createTextNode(""),i.parentNode.insertBefore(f,i),i.parentNode.removeChild(i),u.parentNode.removeChild(u),e.parentNode.removeChild(e),t=this._doc.createRange(),t.setStart(f,0),t.setEnd(f,0),t.setStart(f,0),t.setEnd(f,0),this._removeAllRanges(l),this._selectRange(l,t),[]):(Sys.Extended.UI.HtmlEditor.positionInParagraph(i,i.previousSibling,!0,i.parentNode,w),this._trySelect(i,u),h=this._getSelection(),c=this._createRange(h),o=Sys.Extended.UI.HtmlEditor.isIE?"":Sys.Extended.UI.HtmlEditor.Trim(this.getSelectedHTML()),s=Sys.Extended.UI.HtmlEditor.isIE&&c.text.length>0||!Sys.Extended.UI.HtmlEditor.isIE&&o.length>0,Sys.Extended.UI.HtmlEditor.isIE?typeof n!="undefined"?this.__saveBM__=e:e.parentNode.removeChild(e):this.__saveBM__=[e,0],s&&(b=this._getTextNodeCollection()),i.parentNode.removeChild(i),u.parentNode.removeChild(u),b)},_setStyleForTyping:function(n){var e=n.name.replace(/\-(\w)/g,function(n,t){return t.toUpperCase()}),o=n.value,s=n.repl,i,r,t,u,f;for(this._StyleForTyping==null&&(this._StyleForTyping=[]),i=[],r=!0,t=0;t<this._StyleForTyping.length;t++)u=this._StyleForTyping[t].name.replace(/\-(\w)/g,function(n,t){return t.toUpperCase()}),f=this._StyleForTyping[t].value,u==e&&(f==o||s)?r=!1:i.push(this._StyleForTyping[t]);this._StyleForTyping=i;r&&this._StyleForTyping.push(n)},_trySelect:function(n,t){var i=this._getSelection(),e=null,o=null,r,u,f;if(Sys.Extended.UI.HtmlEditor.isIE){i.empty();i=this._getSelection();r=this._createRange(i);u=this._createRange(i);try{n!=null&&r.moveToElementText(n);t!=null&&u.moveToElementText(t);n!=null&&t!=null?(r.setEndPoint("EndToEnd",u),r.select()):n!=null?r.select():t!=null&&u.select()}catch(s){}}else try{e=this._doc.createTextNode("");o=this._doc.createTextNode("");n.parentNode.insertBefore(e,n);t.parentNode.insertBefore(o,t);f=this._doc.createRange();f.setStart(e,0);f.setEnd(o,0);this._removeAllRanges(i);this._selectRange(i,f)}catch(s){}},getSelectedHTML:function(){var t=this._getSelection(),i=this._createRange(t),n=null;if(Sys.Extended.UI.HtmlEditor.isIE)n=i.htmlText;else if(Sys.Extended.UI.HtmlEditor.isSafari&&(t.type=="Caret"||t.type=="None"))n="";else{if(Sys.Extended.UI.HtmlEditor.isSafari&&i.cloneContents()==null)return"";n=Sys.Extended.UI.HtmlEditor.getHTML(i.cloneContents(),!1)}return n},_queryCommandState:function(n){var h=this._rangeStartEnd(),t,e,o,s,c;if(h==null)return!1;try{t={name:"none",value:"none"};switch(n.toLowerCase()){case"bold":t={name:"font-weight",value:"bold"};break;case"italic":t={name:"font-style",value:"italic"};break;case"underline":t={name:"text-decoration",value:"underline"};break;case"strikethrough":t={name:"text-decoration",value:"line-through"};break;case"superscript":t={name:"vertical-align",value:"super"};break;case"subscript":t={name:"vertical-align",value:"sub"}}var i=h.start,r=h.end,u=Sys.Extended.UI.HtmlEditor.getStyle(i,t.name).toString().toLowerCase(),f=Sys.Extended.UI.HtmlEditor.getStyle(r,t.name).toString().toLowerCase();if(t.name=="font-weight"&&u=="700"&&(u="bold"),t.name=="font-weight"&&f=="700"&&(f="bold"),/MSIE (5|6)/.test(navigator.userAgent)&&n.toLowerCase()=="strikethrough"&&(u=="underline"||f=="underline")){while(i&&Sys.Extended.UI.HtmlEditor.isStyleTag(i.tagName)){if(i.style.textDecoration.indexOf("line-through")>=0){u=i.style.textDecoration;break}i=i.parentNode}while(r&&Sys.Extended.UI.HtmlEditor.isStyleTag(r.tagName)){if(r.style.textDecoration.indexOf("line-through")>=0){f=r.style.textDecoration;break}r=r.parentNode}}if(Sys.Extended.UI.HtmlEditor.isSafari&&(n.toLowerCase()=="strikethrough"||n.toLowerCase()=="underline")){for(e=n.toLowerCase(),e=="strikethrough"&&(e="line-through");i&&Sys.Extended.UI.HtmlEditor.isStyleTag(i.tagName);){if(i.style.textDecoration.indexOf(e)>=0){u=i.style.textDecoration;break}i=i.parentNode}while(r&&Sys.Extended.UI.HtmlEditor.isStyleTag(r.tagName)){if(r.style.textDecoration.indexOf(e)>=0){f=r.style.textDecoration;break}r=r.parentNode}}if(o=u.indexOf(t.value)>=0&&f.indexOf(t.value)>=0,this._StyleForTyping!=null&&this._StyleForTyping.length>0)for(s=0;s<this._StyleForTyping.length;s++)if(c=this._StyleForTyping[s],c.name==t.name&&c.value==t.value){o=!o;break}return o}catch(l){return!1}},_textAlignState:function(n){var t=this._rangeStartEnd(),i,r;if(t==null)return!1;try{return i=this._textAlignStateSingle(t.start),r=this._textAlignStateSingle(t.end),i==n&&r==n}catch(u){return!1}},_textAlignStateSingle:function(n){while(n&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.tagName))n=n.parentNode;if(n!=null){var t=n.tagName.toUpperCase();if(t=="P"||t=="DIV")return n.style.textAlign.toLowerCase()}return null},_rangeStartEnd:function(){var e,u,f;if(this.isControl())return null;try{var l=this._getSelection(),n=this._createRange(l),t=null,i=null;if(Sys.Extended.UI.HtmlEditor.isIE)if(n.text.length==0)t=i=this._getParent(n);else{var o=Sys.Extended.UI.HtmlEditor.smartClassName+"_right_marker",s=Sys.Extended.UI.HtmlEditor.smartClassName+"_left_marker",h=n.duplicate(),c=n.duplicate();h.setEndPoint("EndToStart",n);c.setEndPoint("StartToEnd",n);c.pasteHTML("<span id='"+o+"'/>");h.pasteHTML("<span id='"+s+"'/>");u=this._doc.getElementById(s);f=this._doc.getElementById(o);t=u.parentNode;i=f.parentNode;u.parentNode.removeChild(u);f.parentNode.removeChild(f)}else{function r(t,i){for(var u=null;u==null;)if(u=t.nodeType==3?i&&n.startContainer!=n.endContainer&&n.startOffset==t.length&&t.nextSibling?r(t.nextSibling,i):!i&&n.startContainer!=n.endContainer&&n.endOffset==0&&t.previousSibling?r(t.previousSibling,i):t:(i?t.firstChild:t.lastChild)==null?null:r(i?t.firstChild:t.lastChild,i),u==null){if(t=i?t.nextSibling:t.previousSibling,t==null)return null}else return u}if(e=this._getParent(n),e.nodeType!=3&&n.startContainer==n.endContainer&&n.startOffset==n.endOffset&&n.startContainer.childNodes.item(n.startOffset).tagName&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.startContainer.childNodes.item(n.startOffset).tagName))return{start:n.startContainer.childNodes.item(n.startOffset),end:n.startContainer.childNodes.item(n.startOffset)};t=r(n.startContainer,!0);t!=null&&t.parentNode!=null&&(t=t.parentNode);t==null&&(t=n.startContainer);i=r(n.endContainer,!1);i!=null&&i.parentNode!=null&&(i=i.parentNode);i==null&&(i=n.endContainer)}return{start:t,end:i}}catch(a){return null}},rtlState:function(){return this._doc.body.style.direction&&this._doc.body.style.direction=="rtl"?!0:!1},openWait:function(){this._editPanel.openWait()},closeWait:function(){this._editPanel.closeWait()}};Sys.Extended.UI.HtmlEditor.DesignPanel.ScriptRecover=function(){this.scriptsArray=[];this.scriptsArray_index=-1;this.regReplScript1=function(n,t){return this.scriptsArray.push(t),""};this.regReplFromScript=function(n,t){return t.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")};this.regReplFromScript1=function(n,t,i,r){this.scriptsArray_index++;var u;return u=Sys.Extended.UI.HtmlEditor.isIE?this.scriptsArray[this.scriptsArray_index]:this.scriptsArray[this.scriptsArray_index].replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"'),t+u+r}};Sys.Extended.UI.HtmlEditor.DesignPanel.registerClass("Sys.Extended.UI.HtmlEditor.DesignPanel",Sys.Extended.UI.HtmlEditor.ModePanel);