Files
SIG/Scripts/AjaxControlToolkit/Release/HtmlEditor.ExecCommandEmulation.js
rrene 927295c7ba Revert "-- corr"
This reverts commit 5315c47fcd.
2024-11-05 10:55:34 -07:00

1 line
29 KiB
JavaScript

Sys.Extended.UI.HtmlEditor.MSIE_list=function(n){function e(){var v,h,i,l,s,r,e,n;if(t!=null){for(i=t.cloneNode(!1),t.parentNode.insertBefore(i,t);t.firstChild!=u[0];)i.appendChild(t.firstChild);if(i.firstChild==null&&i.parentNode.removeChild(i),t.tagName.toUpperCase()==c)for(e=0;e<u.length;e++)if(n=u[e],n.nodeType==1&&n.tagName&&n.tagName.toUpperCase()=="LI"){if(v=!1,t.parentNode.insertBefore(n,t),n.style.textAlign==""&&(n.style.textAlign=t.style.textAlign),t.childNodes.length==0&&e==u.length-1&&(t.parentNode.removeChild(t),t=null),(n.style.textAlign==""||n.style.textAlign.toLowerCase()=="left"&&!f.rtlState()||n.style.textAlign.toLowerCase()=="right"&&f.rtlState())&&(v=f.tryUnWrap(n,o),v&&(a=!0)),!v){for(h=f._doc.createElement(f.dfltBlockElement),l=n.attributes,s=0;s<l.length;++s)(r=l.item(s),r.specified)&&r.name.toLowerCase()!="style"&&h.setAttribute(r.name,r.value);for(h.style.cssText=n.style.cssText,h.tagName.toUpperCase()=="P"&&(h.style.margin="0px");n.firstChild;)h.appendChild(n.firstChild);n.parentNode.insertBefore(h,n);n.parentNode.removeChild(n)}}else t.parentNode.insertBefore(n,t);else{for(i=f._doc.createElement(c),l=t.attributes,s=0;s<l.length;++s)(r=l.item(s),r.specified)&&r.name.toLowerCase()!="style"&&i.setAttribute(r.name,r.value);for(i.style.cssText=t.style.cssText,t.parentNode.insertBefore(i,t),e=0;e<u.length;e++)n=u[e],i.appendChild(n)}if(t!=null){for(i=t.cloneNode(!1),t.parentNode.insertBefore(i,t);t.firstChild;)i.appendChild(t.firstChild);i.firstChild==null&&i.parentNode.removeChild(i);t.parentNode.removeChild(t)}}t=null;u=[]}function v(){var ot=r.firstChild,st=r.lastChild,p=r.tagName.toUpperCase(),n,l,g,ft,v,y,a,nt,rt,ut,w,b,et,s,k,tt,it;if(!Sys.Extended.UI.HtmlEditor.isInlineElement(r)&&i[0][0]==ot&&i[i.length-1][i[i.length-1].length-1]==st&&(p=="OL"||p=="UL"||p=="DL"||p=="LI"||(p=="P"||p=="DIV"||Sys.Extended.UI.HtmlEditor.isHeader(r))&&p=="LI")){if(e(),u=[],p=="LI")t=r.parentNode,u.push(r);else if(p=="P"||p=="DIV"||Sys.Extended.UI.HtmlEditor.isHeader(r))t=r.parentNode.parentNode,u.push(r.parentNode);else for(t=r,v=0;v<i.length;v++)for(y=i[v],s=0;s<y.length;s++)u.push(y[s]);e()}else if(p=="LI"&&i.length<h.length)t!=r.parentNode&&(e(),t=r.parentNode,u=[]),u.push(r);else if(p=="OL"||p=="UL"||p=="DL"){for(e(),t=r,u=[],v=0;v<i.length;v++)for(y=i[v],s=0;s<y.length;s++)u.push(y[s]);e()}else{n=null;l=null;function d(){n!=null&&n.childNodes==1&&(n.firstChild==o[0]||n.firstChild==o[1])&&(n.parentNode.insertBefore(n.firstChild,n),n.parentNode.removeChild(n));n=null}if(t!=null&&e(),g="",i.length==1&&i[0].length==1&&i[0][0].nodeType==1&&i[0][0].tagName&&(g=i[0][0].tagName.toUpperCase()),g=="OL"||g=="UL"||g=="DL"){for(a=i[0][0],t=a,u=[],v=0;v<a.childNodes.length;v++)ft=a.childNodes.item(v),u.push(ft);e()}else for(v=0;v<i.length;v++){for(y=i[v],s=0;s<y.length;s++)a=y[s],nt=a.tagName?a.tagName.toUpperCase():"",l==null&&(l=f._doc.createElement(c),a.parentNode.insertBefore(l,a)),Sys.Extended.UI.HtmlEditor.isInlineElement(a)||nt=="BR"?(n==null&&(n=f._doc.createElement("LI"),l.appendChild(n)),rt=y[y.length-1]==o[1]?y.length-1:y.length,ut=y[0]==o[0]?1:0,nt=="BR"&&s==rt-1&&s==ut?Sys.Extended.UI.HtmlEditor.isIE?(n.appendChild(f._doc.createTextNode(String.fromCharCode(160))),a.parentNode.removeChild(a)):n.appendChild(a):nt=="BR"&&s==rt-1&&s>ut?a.parentNode.removeChild(a):n.appendChild(a),nt=="BR"&&s==y.length-1&&(d(),n=null),a==o[1]&&s==y.length-1&&(d(),n=null)):(n&&n.firstChild&&d(),n==null&&(n=f._doc.createElement("LI"),l.appendChild(n)),n.appendChild(a),d());n&&n.firstChild&&d()}if(l!=null){for(w=[],s=0;s<l.childNodes.length;s++)w.push(l.childNodes.item(s).style.textAlign);for(b=1;b<w.length;b++)if(w[b-1]!=w[b])break;if(b==w.length){for(et=w[0]=="left"&&!f.rtlState()||w[0]=="right"&&f.rtlState()?"":w[0],s=0;s<l.childNodes.length;s++)l.childNodes.item(s).style.textAlign="";l.style.textAlign=et}}if(l!=null&&l.parentNode.tagName.toUpperCase()=="P"&&l.parentNode.childNodes.length==1)if(k=l.parentNode,tt=k.cloneNode(!1),k.parentNode.insertBefore(l,k),k.parentNode.removeChild(k),l.childNodes.length==1){for(it=l.firstChild;it.firstChild;)tt.appendChild(it.firstChild);it.appendChild(tt)}else delete tt}}for(var s,h=this.get_paragraphs(),o=this.getSelectionAfterOperation(h),r=null,i=[],f=this,t=null,u=[],c=n.toUpperCase(),a=!1,l=0;l<h.length;l++)s=h[l],s.length>0&&(s[0].parentNode!=r&&(i.length>0&&v(),i=[],r=s[0].parentNode),i.push(s));i.length>0&&v();t!=null&&e();this.setSelectionAfterOperation(o,a)};Sys.Extended.UI.HtmlEditor.MSIE_justify=function(n,t,i){function v(n){n!=null&&n.childNodes==1&&(n.firstChild==e[0]||n.firstChild==e[1])&&(n.parentNode.insertBefore(n.firstChild,n),n.parentNode.removeChild(n))}function p(){var vt=r.firstChild,yt=r.lastChild,at=!1,w,p,et,nt,t,i,ot,rt,st,ut,ht,a,y,k,b,tt,c,d,ft,it,g,ct,lt;if(r.tagName&&!Sys.Extended.UI.HtmlEditor.isInlineElement(r)&&f[0][0]==vt&&f[f.length-1][f[f.length-1].length-1]==yt&&(w=r.tagName.toUpperCase(),w!="TD"&&w!="TH"&&w!="FIELDSET"&&w!="LEGEND"&&(at=!0)),at)if(tt="",r.getAttribute("align")&&r.getAttribute("align").length>0&&(tt=r.getAttribute("align")),r.align&&r.align.length>0&&(tt=r.align),r.style.textAlign&&r.style.textAlign.length>0&&(tt=r.style.textAlign),r.align="",r.setAttribute("align",""),r.removeAttribute("align"),(w=="DIV"||w=="P"||Sys.Extended.UI.HtmlEditor.isHeader(r))&&n=="left"&&u)o.tryUnWrap(r,e,u)&&(l=!0);else{if(n!="remain"&&(r.style.textAlign=!(n=="left"&&u)||w=="LI"&&r.parentNode.style.textAlign.length>0?n:""),u&&(r.style.margin=w=="P"?"0px":""),w=="LI"){for(a=r.parentNode,y=[],k=0;k<a.childNodes.length;k++)a.childNodes.item(k).nodeType==1&&y.push(a.childNodes.item(k).style.textAlign);for(b=1;b<y.length;b++)if(y[b-1]!=y[b])break;if(b==y.length){for(tt=y[0]=="left"&&u?"":y[0],c=0;c<a.childNodes.length;c++)a.childNodes.item(c).nodeType==1&&(a.childNodes.item(c).style.textAlign="",u&&(a.childNodes.item(c).style.margin=a.childNodes.item(c).tagName.toUpperCase()=="P"?"0px":""));a.style.textAlign=tt}}if((w=="DIV"||w=="P"||Sys.Extended.UI.HtmlEditor.isHeader(r))&&s&&h.toUpperCase()!=w){for(d=o._doc.createElement(h),ft=r.attributes,it=0;it<ft.length;++it)(g=ft.item(it),g.specified)&&g.name.toLowerCase()!="style"&&d.setAttribute(g.name,g.value);for(d.style.cssText=r.style.cssText;r.firstChild;)d.appendChild(r.firstChild);r.parentNode.insertBefore(d,r);r.parentNode.removeChild(r)}}else for(p=null,et=0;et<f.length;et++)for(s||(p=null),nt=f[et],c=0;c<nt.length;c++)if(t=nt[c],i=t.nodeType==1&&t.tagName?t.tagName.toUpperCase():null,i!=null&&(i=="UL"||i=="OL"||i=="DL"||i=="DIV"||Sys.Extended.UI.HtmlEditor.isHeader(t)||i=="P"||i=="LI"||i=="TABLE")){if(v(p),p=null,n!="remain"&&(i=="TABLE"||u||(t.style.textAlign=n)),u&&(t.style.margin=i=="P"?"0px":""),i=="UL"||i=="OL"||i=="DL"){for(ot=0;ot<t.childNodes.length;ot++)if(rt=t.childNodes.item(ot),rt.nodeType==1)for(rt.style.textAlign="",u&&(rt.style.margin=rt.tagName.toUpperCase()=="P"?"0px":""),st=0;st<rt.childNodes.length;st++)ut=rt.childNodes.item(st),ut.nodeType==1&&ut.tagName&&(ht=ut.tagName.toUpperCase(),u&&(ut.style.margin=ht=="P"?"0px":""),(ht=="DIV"||ht=="P"||Sys.Extended.UI.HtmlEditor.isHeader(ut))&&o.tryUnWrap(ut,e,u)&&(l=!0));n=="left"&&u&&(t.style.textAlign="");continue}else if(i=="LI"){for(n!="remain"&&(t.style.textAlign=!(n=="left"&&u)||t.parentNode.style.textAlign.length>0?n:""),u&&(t.style.margin=i=="P"?"0px":""),a=t.parentNode,y=[],k=0;k<a.childNodes.length;k++)a.childNodes.item(k).nodeType==1&&y.push(a.childNodes.item(k).style.textAlign);for(b=1;b<y.length;b++)if(y[b-1]!=y[b])break;if(b==y.length){for(tt=y[0]=="left"&&u?"":y[0],c=0;c<a.childNodes.length;c++)a.childNodes.item(c).nodeType==1&&(a.childNodes.item(c).style.textAlign="",u&&(a.childNodes.item(c).style.margin=a.childNodes.item(c).tagName.toUpperCase()=="P"?"0px":""));a.style.textAlign=tt}continue}else i=="TABLE"&&n!="remain"&&(n=="left"&&u?(t.align="",t.removeAttribute("align")):t.align=n);if((i=="DIV"||i=="P"||Sys.Extended.UI.HtmlEditor.isHeader(t))&&n=="left"&&u&&o.tryUnWrap(t,e,u)&&(l=!0),(i=="DIV"||i=="P"||Sys.Extended.UI.HtmlEditor.isHeader(t))&&s&&h.toUpperCase()!=i){for(d=o._doc.createElement(h),ft=t.attributes,it=0;it<ft.length;++it)(g=ft.item(it),g.specified)&&g.name.toLowerCase()!="style"&&d.setAttribute(g.name,g.value);for(d.style.cssText=t.style.cssText;t.firstChild;)d.appendChild(t.firstChild);t.parentNode.insertBefore(d,t);t.parentNode.removeChild(t)}}else n=="left"&&u&&!s||(p==null&&(p=o._doc.createElement(s?h:o.dfltBlockElement),o.dfltBlockElement.toUpperCase()!="P"||s||(p.style.margin="0px"),s||(p.style.textAlign=n),t.parentNode.insertBefore(p,t)),ct=nt[nt.length-1]==e[1]?nt.length-1:nt.length,lt=nt[0]==e[0]?1:0,i=="BR"&&c==ct-1&&c==lt?Sys.Extended.UI.HtmlEditor.isIE?(p.appendChild(o._doc.createTextNode(String.fromCharCode(160))),t.parentNode.removeChild(t)):p.appendChild(t):i=="BR"&&c==ct-1&&c>lt&&(!s||t.nextSibling!=null&&t.nextSibling==e[1])?t.parentNode.removeChild(t):p.appendChild(t),i!="BR"||c!=nt.length-1||s||(v(p),p=null),t==e[1]&&c==nt.length-1&&(v(p),p=null))}for(var c,a=this.get_paragraphs(),e=this.getSelectionAfterOperation(a),r=null,f=[],o=this,u=typeof t!="undefined"&&t?!0:!1,s=typeof i=="string"?!0:!1,h=typeof i=="string"?i:"",l=!1,y=0;y<a.length;y++)c=a[y],c.length>0&&(c[0].parentNode!=r&&(f.length>0&&p(),f=[],r=c[0].parentNode),f.push(c));f.length>0&&p();this.setSelectionAfterOperation(e,l)};Sys.Extended.UI.HtmlEditor.MSIE_indent=function(n){function e(n){if(n.nodeType==1){var t=i.rtlState()?n.style.marginRight:n.style.marginLeft;if(t.length>0)return parseInt(t)}return 0}function u(n,t){n.nodeType==1&&(n.tagName.toUpperCase()=="P"&&t==""&&(t="0px"),i.rtlState()?n.style.marginRight=t:n.style.marginLeft=t)}function c(t){n?u(t,e(t)+40+"px"):t.tagName.toUpperCase()=="P"?e(t)>=40?u(t,e(t)-40+"px"):u(t,"0px"):e(t)>40?u(t,e(t)-40+"px"):u(t,"")}function l(n){n!=null&&n.childNodes==1&&(n.firstChild==f[0]||n.firstChild==f[1])&&(n.parentNode.insertBefore(n.firstChild,n),n.parentNode.removeChild(n))}function v(){var ht=t.firstChild,ct=t.lastChild,nt,rt,p,k,o,v,ut,tt,ft,g,et,w,y,d,b,it,a,h,ot,st;if(t.tagName&&!Sys.Extended.UI.HtmlEditor.isInlineElement(t)&&r[0][0]==ht&&r[r.length-1][r[r.length-1].length-1]==ct){if(h="",t.getAttribute("align")&&t.getAttribute("align").length>0&&(h=t.getAttribute("align")),t.align&&t.align.length>0&&(h=t.align),t.style.textAlign&&t.style.textAlign.length>0&&(h=t.style.textAlign),(h.toLowerCase()=="left"&&!i.rtlState()||h.toLowerCase()=="right"&&i.rtlState())&&(h=""),t.align="",t.setAttribute("align",""),t.removeAttribute("align"),c(t),nt=t.tagName.toUpperCase(),(nt=="DIV"||nt=="P"||Sys.Extended.UI.HtmlEditor.isHeader(t))&&h=="")i.tryUnWrap(t,f)&&(s=!0);else if(t.style.textAlign=h!=""||nt=="LI"&&t.parentNode.style.textAlign.length>0?h:"",nt=="LI"){for(w=t.parentNode,y=[],d=0;d<w.childNodes.length;d++)y.push(e(w.childNodes.item(d)));for(b=1;b<y.length;b++)if(y[b-1]!=y[b])break;if(b==y.length){for(it=y[0]==0?"":y[0]+"px",a=0;a<w.childNodes.length;a++)u(w.childNodes.item(a),"");u(w,it)}}}else for(rt=0;rt<r.length;rt++)for(p=null,k=r[rt],a=0;a<k.length;a++)if(o=k[a],v=o.nodeType==1&&o.tagName?o.tagName.toUpperCase():null,v!=null&&(v=="UL"||v=="OL"||v=="DL"||v=="DIV"||Sys.Extended.UI.HtmlEditor.isHeader(o)||v=="P"||v=="LI")){if(l(p),p=null,c(o),v=="UL"||v=="OL"||v=="DL"){for(ut=0;ut<o.childNodes.length;ut++)if(tt=o.childNodes.item(ut),tt.nodeType==1)for(u(tt,""),ft=0;ft<tt.childNodes.length;ft++)g=tt.childNodes.item(ft),h=g.nodeType==1?o.style.textAlign:"",(h.toLowerCase()=="left"&&!i.rtlState()||h.toLowerCase()=="right"&&i.rtlState())&&(h=""),g.nodeType==1&&(u(g,""),h==""&&g.tagName&&(et=g.tagName.toUpperCase(),(et=="DIV"||et=="P")&&i.tryUnWrap(g,f)&&(s=!0)));continue}else if(v=="LI"){for(w=o.parentNode,y=[],d=0;d<w.childNodes.length;d++)y.push(e(w.childNodes.item(d)));for(b=1;b<y.length;b++)if(y[b-1]!=y[b])break;if(b==y.length){for(it=y[0]==0?"":y[0]+"px",a=0;a<w.childNodes.length;a++)u(w.childNodes.item(a),"");u(w,it)}continue}h=o.style.textAlign;(h.toLowerCase()=="left"&&!i.rtlState()||h.toLowerCase()=="right"&&i.rtlState())&&(h="");(v=="DIV"||v=="P"||Sys.Extended.UI.HtmlEditor.isHeader(o))&&h==""&&i.tryUnWrap(o,f)&&(s=!0)}else n&&(p==null&&(p=i._doc.createElement(i.dfltBlockElement),i.dfltBlockElement.toUpperCase()=="P"&&(p.style.margin="0px"),c(p),o.parentNode.insertBefore(p,o)),ot=k[k.length-1]==f[1]?k.length-1:k.length,st=k[0]==f[0]?1:0,v=="BR"&&a==ot-1&&a==st?Sys.Extended.UI.HtmlEditor.isIE?(p.appendChild(i._doc.createTextNode(String.fromCharCode(160))),o.parentNode.removeChild(o)):p.appendChild(o):v=="BR"&&a==ot-1&&a>st?o.parentNode.removeChild(o):p.appendChild(o),v=="BR"&&a==k.length-1&&(l(p),p=null),o==f[1]&&a==k.length-1&&(l(p),p=null))}for(var o,h=this.get_paragraphs(),f=this.getSelectionAfterOperation(h),t=null,r=[],i=this,s=!1,a=0;a<h.length;a++)o=h[a],o.length>0&&(o[0].parentNode!=t&&(r.length>0&&v(),r=[],t=o[0].parentNode),r.push(o));r.length>0&&v();this.setSelectionAfterOperation(f,s)};Sys.Extended.UI.HtmlEditor.getSelectionAfterOperation=function(n){var f,e,o,i;if(n.length==0)return[];var u=this._doc.createElement("SPAN"),r=this._doc.createElement("SPAN"),s=n[0][0],t=n[n.length-1][n[n.length-1].length-1];if(s==t&&t.nodeType==1&&t.childNodes.length==0&&Sys.Extended.UI.HtmlEditor.canHaveChildren(t))t.appendChild(u),t.appendChild(r);else{if(f=Sys.Extended.UI.HtmlEditor._getReallyFirst(s),f.parentNode.insertBefore(u,f),f==s){for(e=[],e.push(u),o=0;o<n[0].length;o++)e.push(n[0][o]);n[0]=e}i=Sys.Extended.UI.HtmlEditor._getReallyLast(t);i.nextSibling?i.parentNode.insertBefore(r,i.nextSibling):i.parentNode.appendChild(r);i==t&&n[n.length-1].push(r)}return[u,r]};Sys.Extended.UI.HtmlEditor.setSelectionAfterOperation=function(n,t){var o,c,s,y,a,v,l,u;if(n.length!=0){var r=n[0],i=n[1],e=this._getSelection(),f=null,h=null;if(Sys.Extended.UI.HtmlEditor.isIE){e.empty();e=this._getSelection();o=this._createRange(e);c=this._createRange(e);try{r!=null&&i!=null&&r.nextSibling==i&&(f=this._doc.createTextNode(" "),i.parentNode.insertBefore(f,i));this._TcurrentFormat=null;r!=null&&o.moveToElementText(r);i!=null&&c.moveToElementText(i);r!=null&&i!=null?(o.setEndPoint("EndToStart",c),o.select(),f!=null&&(o.collapse(!1),o.select(),f.parentNode.removeChild(f))):r!=null?o.select():i!=null&&c.select()}catch(p){}}else try{s=r.nextSibling;y=i.previousSibling;this._TcurrentFormat=null;s==y&&s.nodeType==1&&s.tagName.toUpperCase()=="BR"?(a=Sys.Extended.UI.HtmlEditor.__getIndex(s),u=this._doc.createRange(),u.setStart(s.parentNode,a),u.setEnd(s.parentNode,a)):(f=this._doc.createTextNode(""),h=this._doc.createTextNode(""),r.parentNode.insertBefore(f,r),i.parentNode.insertBefore(h,i),u=this._doc.createRange(),u.setStart(f,0),u.setEnd(h,0));this._removeAllRanges(e);this._selectRange(e,u)}catch(p){}v=Sys.Extended.UI.HtmlEditor._commonTotalParent(r==null?i:r,i==null?r:i);l=null;v!=null&&(l=v.parent);r!=null&&r.parentNode.removeChild(r);i!=null&&i.parentNode.removeChild(i);t&&l!=null&&(Sys.Extended.UI.HtmlEditor.spanJoiner(l,this._doc),Sys.Extended.UI.HtmlEditor.isIE||f==null||h==null||(u=this._doc.createRange(),u.setStart(f,0),u.setEnd(h,0),this._removeAllRanges(e),this._selectRange(e,u)))}};Sys.Extended.UI.HtmlEditor.get_paragraphs=function(){var n,t;if(this._TcurrentFormat=null,n=this.getPseudoP(),n.length==0)try{t="<span id='"+Sys.Extended.UI.HtmlEditor.smartClassName+"_ll'><\/span><span id='"+Sys.Extended.UI.HtmlEditor.smartClassName+"_rr'><\/span><br>";this.insertHTML(t);var i=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName+"_ll"),r=this._doc.getElementById(Sys.Extended.UI.HtmlEditor.smartClassName+"_rr"),u=this._TcurrentFormat;this._TcurrentFormat=null;this.setSelectionAfterOperation([i,r],!1);this._TcurrentFormat=u;n=this.getPseudoP()}catch(f){}return n};Sys.Extended.UI.HtmlEditor.getPseudoP=function(){var b=[],n,t,c,l,d,nt,y,f,a,tt,i,it,p,g,rt,w,r,ut,u;try{var e=this._getSelection(),o=this._createRange(e),v=Sys.Extended.UI.HtmlEditor.smartClassName+"_right",k=Sys.Extended.UI.HtmlEditor.smartClassName+"_left",s=null,h=null;if(Sys.Extended.UI.HtmlEditor.isIE?e.type.toLowerCase()!="control"&&(s=o.duplicate(),h=o.duplicate(),s.setEndPoint("EndToStart",o),h.setEndPoint("StartToEnd",o)):(s=o.cloneRange(),h=o.cloneRange(),s.setEnd(s.startContainer,s.startOffset),h.setStart(h.endContainer,h.endOffset)),n=null,t=null,Sys.Extended.UI.HtmlEditor.isIE&&e.type.toLowerCase()=="control")c=o.item(0),l=this._doc.createElement("SPAN"),l.id=k,c.parentNode.insertBefore(l,c),l=this._doc.createElement("SPAN"),l.id=v,c.nextSibling==null?c.parentNode.appendChild(l):c.parentNode.insertBefore(l,c.nextSibling);else{if(!this.insertHTML("<span id='"+v+"'/>",h))return[];if(!this.insertHTML("<span id='"+k+"'/>",s))return d=this._doc.getElementById(v),d!=null&&(a=d.parentNode,a.removeChild(d)),[]}if(n=this._doc.getElementById(k),t=this._doc.getElementById(v),n!=null&&t!=null)while(n.nextSibling==null)n.parentNode.nextSibling?n.parentNode.parentNode.insertBefore(n,n.parentNode.nextSibling):n.parentNode.parentNode.appendChild(n);if(n!=null&&t!=null){while(t.previousSibling==null)t.parentNode.parentNode.insertBefore(t,t.parentNode);t.previousSibling.nodeType==1&&(nt=t.previousSibling.tagName.toUpperCase(),nt!="BR"&&nt!="IMG"&&(y=Sys.Extended.UI.HtmlEditor._getReallyLast(t.previousSibling),y.nodeType==1&&Sys.Extended.UI.HtmlEditor.canHaveChildren(y)?y.appendChild(t):y.parentNode.appendChild(t)));t.previousSibling&&t.previousSibling.nodeType==1&&t.previousSibling.tagName.toUpperCase()=="BR"&&t.parentNode.insertBefore(t,t.previousSibling)}for(n==null&&(r=this._doc.createElement("SPAN"),r.id=k,t.parentNode.insertBefore(r,t),n=r),t==null&&(r=this._doc.createElement("SPAN"),r.id=v,n.nextSibling?n.parentNode.insertBefore(r,n.nextSibling):n.parentNode.appendChild(r),t=r),n!=null&&t!=null&&(n.parentNode==t?t.parentNode.insertBefore(n,t):t.parentNode==n&&(n.nextSibling!=null?n.parentNode.insertBefore(t,n.nextSibling):n.parentNode.appendChild(t)));n.nextSibling!=null&&n.nextSibling.nodeType==3&&(""+n.nextSibling.data+"").length==0;)n.parentNode.removeChild(n.nextSibling);if(this._TcurrentFormat==null&&n!=null&&t!=null&&n.nextSibling==t){for(f=t.parentNode,this._TcurrentFormat=null;f&&f.tagName.toUpperCase()!="BODY"&&Sys.Extended.UI.HtmlEditor.isStyleTag(f.tagName);)f.tagName.toUpperCase()!="A"&&(a=f.cloneNode(!1),this._TcurrentFormat==null?this._TcurrentFormat=a:(a.appendChild(this._TcurrentFormat),this._TcurrentFormat=a)),f=f.parentNode;this._TcurrentFormat&&(tt=this._doc.createElement("span"),tt.appendChild(this._TcurrentFormat),this._TcurrentFormat=tt.innerHTML)}for(i=n;i&&i.tagName&&Sys.Extended.UI.HtmlEditor.isStyleTag(i.tagName)&&i.tagName.toUpperCase()!="A";)i=i.parentNode;for(i!=null&&i.tagName.toUpperCase()=="P"?i.firstChild!=null?i.insertBefore(n,i.firstChild):i.appendChild(n):Sys.Extended.UI.HtmlEditor.positionInParagraph(n,n.previousSibling,!0,n.parentNode),i=t;i&&i.tagName&&Sys.Extended.UI.HtmlEditor.isStyleTag(i.tagName)&&i.tagName.toUpperCase()!="A";)i=i.parentNode;if(i!=null&&i.tagName.toUpperCase()=="P"?i.appendChild(t):Sys.Extended.UI.HtmlEditor.positionInParagraph(t,t.nextSibling,!1,t.parentNode),b=this.getPseudoP_Recur(n,t,0),it=n.parentNode.tagName.toUpperCase(),b.length==0&&n.previousSibling==null&&t.nextSibling==null&&n.nextSibling==t&&(it=="P"||llpTagName=="DIV"||it=="LI")&&(b=[[n.parentNode]]),Sys.Extended.UI.HtmlEditor.isIE){e.empty();e=this._getSelection();p=this._createRange(e);g=this._createRange(e);try{n!=null&&p.moveToElementText(n);t!=null&&g.moveToElementText(t);n!=null&&t!=null?(p.setEndPoint("EndToEnd",g),p.select()):n!=null?p.select():t!=null&&g.select()}catch(ft){}}n!=null&&n.parentNode.removeChild(n);t!=null&&t.parentNode.removeChild(t)}catch(ft){for(rt=this._doc.getElementsByTagName("SPAN"),w=[],u=0;u<rt.length;u++)r=rt[u],r.id&&r.id.length>0&&(ut=new RegExp(Sys.Extended.UI.HtmlEditor.smartClassName,"ig"),ut.test(r.id)&&w.push(r));for(u=0;u<w.length;u++)w[u].parentNode.removeChild(w[u])}return b};Sys.Extended.UI.HtmlEditor.getPseudoP_Recur=function(n,t,i){var y=[],u=n,c=t.nextSibling!=null&&t.nextSibling.tagName&&t.nextSibling.tagName.toUpperCase()=="BR"?t.nextSibling:t,a=null,tt,et,kt,lt,dt,ot,g,yt,nt,b,h,v,it,rt,ut,k,st,ht,d,ft;if(u==null||c==null?(u!=null&&(a=Sys.Extended.UI.HtmlEditor._commonTotalParent(u,u)),c!=null&&(a=Sys.Extended.UI.HtmlEditor._commonTotalParent(c,c))):a=Sys.Extended.UI.HtmlEditor._commonTotalParent(u,c),a!=null){for(u=Sys.Extended.UI.HtmlEditor.getContainer(a.parent.childNodes.item(a.indexFirst),u),c=Sys.Extended.UI.HtmlEditor.getContainer(a.parent.childNodes.item(a.indexLast),c),Sys.Extended.UI.HtmlEditor.unStyle(u),Sys.Extended.UI.HtmlEditor.unStyle(c);u.parentNode!=a.parent;)u=u.parentNode;while(c.parentNode!=a.parent)c=c.parentNode;Sys.Extended.UI.HtmlEditor._moveTagsUp(u.nextSibling,c);a=null;n==null||t==null?(n!=null&&(a=Sys.Extended.UI.HtmlEditor._commonTotalParent(n,n)),t!=null&&(a=Sys.Extended.UI.HtmlEditor._commonTotalParent(t,t))):a=Sys.Extended.UI.HtmlEditor._commonTotalParent(n,t);a!=null&&Sys.Extended.UI.HtmlEditor.spanJoiner(a.parent,this._doc,a.indexFirst,a.indexLast+1,!0);function bt(n){var t,i;if(Sys.Extended.UI.HtmlEditor.isInlineElement(n)){if(n.tagName&&Sys.Extended.UI.HtmlEditor.isStyleTag(n.tagName)&&n.tagName.toUpperCase()!="A"&&!Sys.Extended.UI.HtmlEditor.isTempElement(n))for(t=n.firstChild;t!=null;){if(nnnNext=t.nextSibling,i=bt(t),i)return!0;t=nnnNext}}else return!0;return!1}var e=0,f=[],o=0;if(u.tagName&&c.tagName)if(tt=u.tagName.toUpperCase(),et=c.tagName.toUpperCase(),(tt=="TD"||tt=="TR")&&(et=="TD"||et=="TR")){while(u.tagName.toUpperCase()!="TABLE")u=u.parentNode;c=u}else if((tt=="DD"||tt=="DT")&&(et=="DD"||et=="DT")){while(u.tagName&&u.tagName.toUpperCase()!="DL")u=u.parentNode;c=u}else if(tt=="LI"&&et=="LI"){while(tt!="UL"&&tt!="OL")u=u.parentNode,tt=u.tagName?u.tagName.toUpperCase():null;c=u}for(var p=n?n:t,w=t?t:n,r=u;;){if(!Sys.Extended.UI.HtmlEditor.isTempElement(r))if(kt=bt(r),kt)if(r.tagName&&r.tagName.toUpperCase()=="BR")f[o]=r,y[e]=f,e++,f=[],o=0;else if(r!=c&&r!=u||(r==c&&r==u?Sys.Extended.UI.HtmlEditor._reallyFirst(r,p)&&Sys.Extended.UI.HtmlEditor._reallyLast(r,w):Sys.Extended.UI.HtmlEditor._reallyFirst(r,p)||Sys.Extended.UI.HtmlEditor._reallyLast(r,w)))o>0&&(y[e]=f,e++,f=[],o=0),f[o]=r,y[e]=f,e++,f=[],o=0;else if(ot=r.tagName?r.tagName.toUpperCase():null,ot=="TABLE"||ot=="TBODY"){for(g=r;g.tagName.toUpperCase()!="TABLE";)g=g.parentNode;var gt=0,at=0,ni=g.rows.item(g.rows.length-1).cells.length-1,vt=g.rows.length-1;for(h=0;h<g.rows.length;h++)for(yt=g.rows.item(h),nt=0;nt<yt.cells.length;nt++)b=yt.cells.item(nt),Sys.Extended.UI.HtmlEditor._lookChild(b,p)>=0&&(gt=nt,at=h),Sys.Extended.UI.HtmlEditor._lookChild(b,w)>=0&&(ni=nt,vt=h);for(h=at;h<=vt;h++)for(nt=h==at?gt:0;nt<=(h==vt?ni:g.rows.item(h).cells.length-1);nt++)if(b=g.rows.item(h).cells.item(nt),o>0&&(y[e]=f,e++,f=[],o=0),it=Sys.Extended.UI.HtmlEditor._lookChild(b,p)>=0,rt=Sys.Extended.UI.HtmlEditor._lookChild(b,w)>=0,it||rt){var s=p,l=w,pt=Sys.Extended.UI.HtmlEditor.smartClassName+"_right_"+i,wt=Sys.Extended.UI.HtmlEditor.smartClassName+"_left_"+i;for(it&&(l=this._doc.createElement("span"),l.id=pt,b.appendChild(l)),rt&&(s=this._doc.createElement("span"),s.id=wt,b.firstChild?b.insertBefore(s,b.firstChild):b.appendChild(s)),ut=this.getPseudoP_Recur(s,l,i+1),k=0;k<ut.length;k++)y[e]=ut[k],e++;s!=p&&s.parentNode.removeChild(s);l!=w&&l.parentNode.removeChild(l)}else{for(st=0,ht=b.childNodes.length,d=st;d<ht;d++)ft=b.childNodes.item(d),Sys.Extended.UI.HtmlEditor.isTempElement(ft)||(f[o]=ft,o++);f.length>0&&(y[e]=f,e++,f=[],o=0)}}else if(ot=="UL"||ot=="OL"||ot=="DL"){var ct=r,ti=0,ii=ct.childNodes.length-1;for(h=0;h<ct.childNodes.length;h++)v=ct.childNodes.item(h),v.nodeType==1&&((v==p||Sys.Extended.UI.HtmlEditor._lookChild(v,p)>=0)&&(ti=h),(v==w||Sys.Extended.UI.HtmlEditor._lookChild(v,w)>=0)&&(ii=h));for(h=ti;h<=ii;h++)if(v=ct.childNodes.item(h),o>0&&(y[e]=f,e++,f=[],o=0),it=Sys.Extended.UI.HtmlEditor._lookChild(v,p)>=0,rt=Sys.Extended.UI.HtmlEditor._lookChild(v,w)>=0,it||rt){var s=p,l=w,pt=Sys.Extended.UI.HtmlEditor.smartClassName+"_right_"+i,wt=Sys.Extended.UI.HtmlEditor.smartClassName+"_left_"+i;for(it&&(l=this._doc.createElement("span"),l.id=pt,v.appendChild(l)),rt&&(s=this._doc.createElement("span"),s.id=wt,v.firstChild?v.insertBefore(s,v.firstChild):v.appendChild(s)),ut=this.getPseudoP_Recur(s,l,i+1),k=0;k<ut.length;k++)y[e]=ut[k],e++;s!=p&&s.parentNode.removeChild(s);l!=w&&l.parentNode.removeChild(l)}else{for(st=0,ht=v.childNodes.length,d=st;d<ht;d++)ft=v.childNodes.item(d),Sys.Extended.UI.HtmlEditor.isTempElement(ft)||(f[o]=ft,o++);f.length>0&&(y[e]=f,e++,f=[],o=0)}}else if(it=Sys.Extended.UI.HtmlEditor._lookChild(r,p)>=0,rt=Sys.Extended.UI.HtmlEditor._lookChild(r,w)>=0,o>0&&(y[e]=f,e++,f=[],o=0),it||rt){var s=p,l=w,pt=Sys.Extended.UI.HtmlEditor.smartClassName+"_right_"+i,wt=Sys.Extended.UI.HtmlEditor.smartClassName+"_left_"+i;for(it&&(l=this._doc.createElement("span"),l.id=pt,r.appendChild(l)),rt&&(s=this._doc.createElement("span"),s.id=wt,r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s)),ut=this.getPseudoP_Recur(s,l,i+1),k=0;k<ut.length;k++)y[e]=ut[k],e++;s!=p&&s.parentNode.removeChild(s);l!=w&&l.parentNode.removeChild(l)}else{for(st=0,ht=r.childNodes.length,d=st;d<ht;d++)ft=r.childNodes.item(d),Sys.Extended.UI.HtmlEditor.isTempElement(ft)||(f[o]=ft,o++);f.length>0&&(y[e]=f,e++,f=[],o=0)}else{if(r.nodeType&&r.nodeType==3&&(lt=""+r.data+"",lt.length==0||/^[\n\r]+$/.test(lt))){if(dt=r.nextSibling,r.parentNode.removeChild(r),r==c)break;r=dt;continue}f[o]=r;o++}if(r==c)break;r=r.nextSibling}o>0&&(y[e]=f)}return y};Sys.Extended.UI.HtmlEditor.unWrap=function(n,t){var f=this,i,e,u,r;if(n.firstChild){while(n.firstChild&&n.firstChild.nodeType==3&&""+n.firstChild.data+""=="")n.removeChild(n.firstChild);for(i=[];n.firstChild;)n.firstChild!=t[0]&&n.firstChild!=t[1]&&i.push(n.firstChild),n.parentNode.insertBefore(n.firstChild,n);for(i.length==0&&(r=f._doc.createElement("BR"),n.parentNode.insertBefore(r,n)),Sys.Extended.UI.HtmlEditor.isIE&&i.length==1&&i[0].nodeType==3&&(e=""+i[0].data+"",e.length==1&&e.charCodeAt(0)==160&&(r=f._doc.createElement("BR"),i[0].parentNode.insertBefore(r,i[0]),i[0].parentNode.removeChild(i[0])));n.nextSibling&&n.nextSibling.nodeType==3&&""+n.nextSibling.data+""=="";)n.parentNode.removeChild(n.nextSibling);u=n.previousSibling&&t[1]==n.previousSibling?t[1].previousSibling:n.previousSibling;u&&Sys.Extended.UI.HtmlEditor.isInlineElement(u)&&u.nodeType==1&&u.childNodes.length>0&&(u=Sys.Extended.UI.HtmlEditor._getReallyLast(u));Sys.Extended.UI.HtmlEditor.isInlineElement(u)&&n.nextSibling!=null&&(r=f._doc.createElement("BR"),n.parentNode.insertBefore(r,n))}else r=f._doc.createElement("BR"),n.parentNode.insertBefore(r,n);n.parentNode.removeChild(n)};Sys.Extended.UI.HtmlEditor.tryUnWrap=function(n,t,i){var c=this,o,s,e,h;for(n.style.textAlign="",o=0,s=n.attributes,e=0;e<s.length;++e)(h=s.item(e),h.specified)&&h.name.toLowerCase()!="style"&&o++;var l=n.style.cssText,u=0,r,f=n.tagName.toUpperCase();if(!(typeof i!="undefined"&&i)&&f!="LI")try{r=parseInt(Sys.Extended.UI.HtmlEditor.getStyle(n,"margin-top"));isNaN(r)&&(r=f=="P"?1:0);u+=r;r=parseInt(Sys.Extended.UI.HtmlEditor.getStyle(n,"margin-bottom"));isNaN(r)&&(r=f=="P"?1:0);u+=r;r=parseInt(Sys.Extended.UI.HtmlEditor.getStyle(n,"margin-right"));isNaN(r)&&(r=f=="P"?1:0);u+=r;r=parseInt(Sys.Extended.UI.HtmlEditor.getStyle(n,"margin-left"));isNaN(r)&&(r=f=="P"?1:0);u+=r}catch(a){u=1}return n.style.margin="",o==0&&n.style.cssText.length==0&&u==0||typeof i!="undefined"&&i&&f!="LI"?(c.unWrap(n,t),!0):(n.style.cssText=l,!1)};Sys.Extended.UI.HtmlEditor._queryCommandValue=function(n,t){var e=this._rangeStartEnd(),o,s,u,r,i,f,h,c;if(e==null)return"";try{if(n.toLowerCase()=="backcolor"){for(o=e.start;o;){if(s=Sys.Extended.UI.HtmlEditor.getStyle(o,"background-color").toLowerCase(),s.length>0&&s!="transparent")return s;o=o.parentNode}return"#FFFFFF"}u="none";switch(n.toLowerCase()){case"forecolor":u="color";break;case"fontname":u="font-family";break;case"fontsize":u="font-size"}if((u=="font-size"||u=="font-family")&&this._FontNotSet)for(r="",i=e.start;i!=null;){if(u=="font-size"){if(i.style&&i.style.fontSize&&i.style.fontSize.length>0){r=i.style.fontSize;break}else if(i.tagName&&i.tagName.toUpperCase()=="FONT"&&i.size&&i.size.length>0){r=Sys.Extended.UI.HtmlEditor.fontSizeSeek(i.size);break}}else if(i.style&&i.style.fontFamily&&i.style.fontFamily.length>0){r=i.style.fontFamily;break}else if(i.tagName&&i.tagName.toUpperCase()=="FONT"&&i.face&&i.face.length>0){r=i.face;break}if(i.className&&i.className.length>0){r=Sys.Extended.UI.HtmlEditor.getStyle(i,u).toLowerCase();u=="font-size"&&(Sys.Extended.UI.HtmlEditor.isIE||(r=Sys.Extended.UI.HtmlEditor._TryTransformFromPxToPt(r,this,t)));break}if(f=i.tagName.toUpperCase(),f=="BODY"||f=="TD")break;i=i.parentNode}else if(r=Sys.Extended.UI.HtmlEditor.getStyle(e.start,u).toLowerCase(),u=="font-size"&&!Sys.Extended.UI.HtmlEditor.isIE)for(r=Sys.Extended.UI.HtmlEditor._TryTransformFromPxToPt(r,this,t),i=e.start;i!=null;){if(i.style&&i.style.fontSize&&i.style.fontSize.length>0){r=i.style.fontSize;break}if(i.className&&i.className.length>0)break;if(f=i.tagName.toUpperCase(),f=="BODY"||f=="TD")break;i=i.parentNode}if(this._StyleForTyping!=null&&this._StyleForTyping.length>0)for(h=0;h<this._StyleForTyping.length;h++)if(c=this._StyleForTyping[h],c.name==u){r=c.value;break}return r}catch(l){return""}};