/** Copyright (c) The New York Times, CMS Group, Matthew DeLambo This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program as the file license.txt. If not, see **/ window.rangy=(function(){var k="object",h="function",A="undefined";var l=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer","START_TO_START","START_TO_END","END_TO_START","END_TO_END"];var d=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"];var s=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"];var p=["collapse","compareEndPoints","duplicate","getBookmark","moveToBookmark","moveToElementText","parentElement","pasteHTML","select","setEndPoint","getBoundingClientRect"];function j(D,C){var B=typeof D[C];return B==h||(!!(B==k&&D[C]))||B=="unknown"}function e(C,B){return !!(typeof C[B]==k&&C[B])}function q(C,B){return typeof C[B]!=A}function m(B){return function(E,D){var C=D.length;while(C--){if(!B(E,D[C])){return false}}return true}}var o=m(j);var r=m(e);var z=m(q);function v(B){return B&&o(B,p)&&z(B,s)}var n={version:"1.2",initialized:false,supported:true,util:{isHostMethod:j,isHostObject:e,isHostProperty:q,areHostMethods:o,areHostObjects:r,areHostProperties:z,isTextRange:v},features:{},modules:{},config:{alertOnWarn:false,preferTextRange:false}};function g(B){window.alert("Rangy not supported in your browser. Reason: "+B);n.initialized=true;n.supported=false}n.fail=g;function u(C){var B="Rangy warning: "+C;if(n.config.alertOnWarn){window.alert(B)}else{if(typeof window.console!=A&&typeof window.console.log!=A){window.console.log(B)}}}n.warn=u;if({}.hasOwnProperty){n.util.extend=function(D,C){for(var B in C){if(C.hasOwnProperty(B)){D[B]=C[B]}}}}else{g("hasOwnProperty not supported")}var w=[];var a=[];function t(){if(n.initialized){return}var D;var H=false,I=false;if(j(document,"createRange")){D=document.createRange();if(o(D,d)&&z(D,l)){H=true}D.detach()}var C=e(document,"body")?document.body:document.getElementsByTagName("body")[0];if(C&&j(C,"createTextRange")){D=C.createTextRange();if(v(D)){I=true}}if(!H&&!I){g("Neither Range nor TextRange are implemented")}n.initialized=true;n.features={implementsDomRange:H,implementsTextRange:I};var G=a.concat(w);for(var F=0,B=G.length;F["+C.childNodes.length+"]"}else{return C.nodeName}}}function m(C){this.root=C;this._next=C}m.prototype={_current:null,hasNext:function(){return !!this._next},next:function(){var E=this._current=this._next;var D,C;if(this._current){D=E.firstChild;if(D){this._next=D}else{C=null;while((E!==this.root)&&!(C=E.nextSibling)){E=E.parentNode}this._next=C}}return this._current},detach:function(){this._current=this._next=this.root=null}};function i(C){return new m(C)}function j(C,D){this.node=C;this.offset=D}j.prototype={equals:function(C){return this.node===C.node&this.offset==C.offset},inspect:function(){return"[DomPosition("+n(this.node)+":"+this.offset+")]"}};function t(C){this.code=this[C];this.codeName=C;this.message="DOMException: "+this.codeName}t.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};t.prototype.toString=function(){return this.message};o.dom={arrayContains:x,getNodeIndex:a,getNodeLength:h,getCommonAncestor:w,isAncestorOf:A,getClosestAncestorIn:y,isCharacterDataNode:k,insertAfter:u,splitDataNode:v,getDocument:p,getWindow:l,getIframeWindow:g,getIframeDocument:z,getBody:B,getRootContainer:d,comparePoints:q,inspectNode:n,createIterator:i,DomPosition:j};o.DOMException=t});rangy.createModule("DomRange",function(h,e){h.requireModules(["DomUtil"]);var a=h.dom;var D=a.DomPosition;var Q=h.DOMException;function w(ai,ah){return(ai.nodeType!=3)&&(a.isAncestorOf(ai,ah.startContainer,true)||a.isAncestorOf(ai,ah.endContainer,true))}function l(ah){return a.getDocument(ah.startContainer)}function t(ai,am,aj){var al=ai._listeners[am];if(al){for(var ak=0,ah=al.length;ak=ak.childNodes.length){ak.appendChild(ai)}else{ak.insertBefore(ai,ak.childNodes[aj])}}return ah}function G(aj){var ai;for(var ak,al=l(aj.range).createDocumentFragment(),ah;ak=aj.next();){ai=aj.isPartiallySelectedSubtree();ak=ak.cloneNode(!ai);if(ai){ah=aj.getSubtreeIterator();ak.appendChild(G(ah));ah.detach(true)}if(ak.nodeType==10){throw new Q("HIERARCHY_REQUEST_ERR")}al.appendChild(ak)}return al}function S(ai,al,ah){var aj,an;ah=ah||{stop:false};for(var ak,am;ak=ai.next();){if(ai.isPartiallySelectedSubtree()){if(al(ak)===false){ah.stop=true;return}else{am=ai.getSubtreeIterator();S(am,al,ah);am.detach(true);if(ah.stop){return}}}else{aj=a.createIterator(ak);while((an=aj.next())){if(al(an)===false){ah.stop=true;return}}}}}function m(ai){var ah;while(ai.next()){if(ai.isPartiallySelectedSubtree()){ah=ai.getSubtreeIterator();m(ah);ah.detach(true)}else{ai.remove()}}}function O(ai){for(var aj,ak=l(ai.range).createDocumentFragment(),ah;aj=ai.next();){if(ai.isPartiallySelectedSubtree()){aj=aj.cloneNode(false);ah=ai.getSubtreeIterator();aj.appendChild(O(ah));ah.detach(true)}else{ai.remove()}if(aj.nodeType==10){throw new Q("HIERARCHY_REQUEST_ERR")}ak.appendChild(aj)}return ak}function o(aj,ah,ak){var am=!!(ah&&ah.length),al;var an=!!ak;if(am){al=new RegExp("^("+ah.join("|")+")$")}var ai=[];S(new f(aj,false),function(ao){if((!am||al.test(ao.nodeType))&&(!an||ak(ao))){ai.push(ao)}});return ai}function y(ah){var ai=(typeof ah.getName=="undefined")?"Range":ah.getName();return"["+ai+"("+a.inspectNode(ah.startContainer)+":"+ah.startOffset+", "+a.inspectNode(ah.endContainer)+":"+ah.endOffset+")]"}function f(aj,ai){this.range=aj;this.clonePartiallySelectedTextNodes=ai;if(!aj.collapsed){this.sc=aj.startContainer;this.so=aj.startOffset;this.ec=aj.endContainer;this.eo=aj.endOffset;var ah=aj.commonAncestorContainer;if(this.sc===this.ec&&a.isCharacterDataNode(this.sc)){this.isSingleCharacterDataNode=true;this._first=this._last=this._next=this.sc}else{this._first=this._next=(this.sc===ah&&!a.isCharacterDataNode(this.sc))?this.sc.childNodes[this.so]:a.getClosestAncestorIn(this.sc,ah,true);this._last=(this.ec===ah&&!a.isCharacterDataNode(this.ec))?this.ec.childNodes[this.eo-1]:a.getClosestAncestorIn(this.ec,ah,true)}}}f.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:false,reset:function(){this._current=null;this._next=this._first},hasNext:function(){return !!this._next},next:function(){var ah=this._current=this._next;if(ah){this._next=(ah!==this._last)?ah.nextSibling:null;if(a.isCharacterDataNode(ah)&&this.clonePartiallySelectedTextNodes){if(ah===this.ec){(ah=ah.cloneNode(true)).deleteData(this.eo,ah.length-this.eo)}if(this._current===this.sc){(ah=ah.cloneNode(true)).deleteData(0,this.so)}}}return ah},remove:function(){var ai=this._current,aj,ah;if(a.isCharacterDataNode(ai)&&(ai===this.sc||ai===this.ec)){aj=(ai===this.sc)?this.so:0;ah=(ai===this.ec)?this.eo:ai.length;if(aj!=ah){ai.deleteData(aj,ah-aj)}}else{if(ai.parentNode){ai.parentNode.removeChild(ai)}else{}}},isPartiallySelectedSubtree:function(){var ah=this._current;return w(ah,this.range)},getSubtreeIterator:function(){var ai;if(this.isSingleCharacterDataNode){ai=this.range.cloneRange();ai.collapse()}else{ai=new af(l(this.range));var am=this._current;var ak=am,ah=0,al=am,aj=a.getNodeLength(am);if(a.isAncestorOf(am,this.sc,true)){ak=this.sc;ah=this.so}if(a.isAncestorOf(am,this.ec,true)){al=this.ec;aj=this.eo}C(ai,ak,ah,al,aj)}return new f(ai,this.clonePartiallySelectedTextNodes)},detach:function(ah){if(ah){this.range.detach()}this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};function N(ah){this.code=this[ah];this.codeName=ah;this.message="RangeException: "+this.codeName}N.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2};N.prototype.toString=function(){return this.message};function v(ai,ah,aj){this.nodes=o(ai,ah,aj);this._next=this.nodes[0];this._position=0}v.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 ab=[1,3,4,5,7,8,10];var Z=[2,9,11];var A=[5,6,10,12];var L=[1,3,4,5,7,8,10,11];var E=[1,3,4,5,7,8];function V(ah){return function(aj,al){var ai,ak=al?aj:aj.parentNode;while(ak){ai=ak.nodeType;if(a.arrayContains(ah,ai)){return ak}ak=ak.parentNode}return null}}var s=a.getRootContainer;var H=V([9,11]);var J=V(A);var b=V([6,10,12]);function q(ai,ah){if(b(ai,ah)){throw new N("INVALID_NODE_TYPE_ERR")}}function B(ah){if(!ah.startContainer){throw new Q("INVALID_STATE_ERR")}}function R(ah,ai){if(!a.arrayContains(ai,ah.nodeType)){throw new N("INVALID_NODE_TYPE_ERR")}}function aa(ah,ai){if(ai<0||ai>(a.isCharacterDataNode(ah)?ah.length:ah.childNodes.length)){throw new Q("INDEX_SIZE_ERR")}}function d(ai,ah){if(H(ai,true)!==H(ah,true)){throw new Q("WRONG_DOCUMENT_ERR")}}function X(ah){if(J(ah,true)){throw new Q("NO_MODIFICATION_ALLOWED_ERR")}}function ad(ai,ah){if(!ai){throw new Q(ah)}}function n(ah){return !a.arrayContains(Z,ah.nodeType)&&!H(ah,true)}function ag(ah,ai){return ai<=(a.isCharacterDataNode(ah)?ah.length:ah.childNodes.length)}function g(ah){B(ah);if(n(ah.startContainer)||n(ah.endContainer)||!ag(ah.startContainer,ah.startOffset)||!ag(ah.endContainer,ah.endOffset)){throw new Error("Range error: Range is no longer valid after DOM mutation ("+ah.inspect()+")")}}var K=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"];var k=0,x=1,ac=2,W=3;var r=0,u=1,I=2,j=3;function Y(){}Y.prototype={attachListener:function(ah,ai){this._listeners[ah].push(ai)},compareBoundaryPoints:function(am,aj){g(this);d(this.startContainer,aj.startContainer);var ao,ai,an,ah;var al=(am==W||am==k)?"start":"end";var ak=(am==x||am==k)?"start":"end";ao=this[al+"Container"];ai=this[al+"Offset"];an=aj[ak+"Container"];ah=aj[ak+"Offset"];return a.comparePoints(ao,ai,an,ah)},insertNode:function(ai){g(this);R(ai,L);X(this.startContainer);if(a.isAncestorOf(ai,this.startContainer,true)){throw new Q("HIERARCHY_REQUEST_ERR")}var ah=i(ai,this.startContainer,this.startOffset);this.setStartBefore(ah)},cloneContents:function(){g(this);var aj,ai;if(this.collapsed){return l(this).createDocumentFragment()}else{if(this.startContainer===this.endContainer&&a.isCharacterDataNode(this.startContainer)){aj=this.startContainer.cloneNode(true);aj.data=aj.data.slice(this.startOffset,this.endOffset);ai=l(this).createDocumentFragment();ai.appendChild(aj);return ai}else{var ah=new f(this,true);aj=G(ah);ah.detach()}return aj}},canSurroundContents:function(){g(this);X(this.startContainer);X(this.endContainer);var ah=new f(this,true);var ai=(ah._first&&(w(ah._first,this))||(ah._last&&w(ah._last,this)));ah.detach();return !ai},surroundContents:function(ai){R(ai,E);if(!this.canSurroundContents()){throw new N("BAD_BOUNDARYPOINTS_ERR")}var ah=this.extractContents();if(ai.hasChildNodes()){while(ai.lastChild){ai.removeChild(ai.lastChild)}}i(ai,this.startContainer,this.startOffset);ai.appendChild(ah);this.selectNode(ai)},cloneRange:function(){g(this);var ah=new af(l(this));var ai=K.length,aj;while(ai--){aj=K[ai];ah[aj]=this[aj]}return ah},toString:function(){g(this);var ai=this.startContainer;if(ai===this.endContainer&&a.isCharacterDataNode(ai)){return(ai.nodeType==3||ai.nodeType==4)?ai.data.slice(this.startOffset,this.endOffset):""}else{var aj=[],ah=new f(this,true);S(ah,function(ak){if(ak.nodeType==3||ak.nodeType==4){aj.push(ak.data)}});ah.detach();return aj.join("")}},compareNode:function(aj){g(this);var ai=aj.parentNode;var al=a.getNodeIndex(aj);if(!ai){throw new Q("NOT_FOUND_ERR")}var ak=this.comparePoint(ai,al),ah=this.comparePoint(ai,al+1);if(ak<0){return(ah>0)?I:r}else{return(ah>0)?u:j}},comparePoint:function(ah,ai){g(this);ad(ah,"HIERARCHY_REQUEST_ERR");d(ah,this.startContainer);if(a.comparePoints(ah,ai,this.startContainer,this.startOffset)<0){return -1}else{if(a.comparePoints(ah,ai,this.endContainer,this.endOffset)>0){return 1}}return 0},createContextualFragment:function(ai){B(this);var aj=l(this);var ah=aj.createElement("div");ah.innerHTML=ai;var al=aj.createDocumentFragment(),ak;while((ak=ah.firstChild)){al.appendChild(ak)}return al},toHtml:function(){g(this);var ah=l(this).createElement("div");ah.appendChild(this.cloneContents());return ah.innerHTML},intersectsNode:function(ak,ah){g(this);ad(ak,"NOT_FOUND_ERR");if(a.getDocument(ak)!==l(this)){return false}var aj=ak.parentNode,am=a.getNodeIndex(ak);ad(aj,"NOT_FOUND_ERR");var al=a.comparePoints(aj,am,this.endContainer,this.endOffset),ai=a.comparePoints(aj,am+1,this.startContainer,this.startOffset);return ah?al<=0&&ai>=0:al<0&&ai>0},isPointInRange:function(ah,ai){g(this);ad(ah,"HIERARCHY_REQUEST_ERR");d(ah,this.startContainer);return(a.comparePoints(ah,ai,this.startContainer,this.startOffset)>=0)&&(a.comparePoints(ah,ai,this.endContainer,this.endOffset)<=0)},intersectsRange:function(ai,ah){g(this);if(l(ai)!=l(this)){throw new Q("WRONG_DOCUMENT_ERR")}var ak=a.comparePoints(this.startContainer,this.startOffset,ai.endContainer,ai.endOffset),aj=a.comparePoints(this.endContainer,this.endOffset,ai.startContainer,ai.startOffset);return ah?ak<=0&&aj>=0:ak<0&&aj>0},intersection:function(ah){if(this.intersectsRange(ah)){var ak=a.comparePoints(this.startContainer,this.startOffset,ah.startContainer,ah.startOffset),ai=a.comparePoints(this.endContainer,this.endOffset,ah.endContainer,ah.endOffset);var aj=this.cloneRange();if(ak==-1){aj.setStart(ah.startContainer,ah.startOffset)}if(ai==1){aj.setEnd(ah.endContainer,ah.endOffset)}return aj}return null},union:function(ah){if(this.intersectsRange(ah,true)){var ai=this.cloneRange();if(a.comparePoints(ah.startContainer,ah.startOffset,this.startContainer,this.startOffset)==-1){ai.setStart(ah.startContainer,ah.startOffset)}if(a.comparePoints(ah.endContainer,ah.endOffset,this.endContainer,this.endOffset)==1){ai.setEnd(ah.endContainer,ah.endOffset)}return ai}else{throw new N("Ranges do not intersect")}},containsNode:function(ai,ah){if(ah){return this.intersectsNode(ai,false)}else{return this.compareNode(ai)==j}},containsNodeContents:function(ah){return this.comparePoint(ah,0)>=0&&this.comparePoint(ah,a.getNodeLength(ah))<=0},containsRange:function(ah){return this.intersection(ah).equals(ah)},containsNodeText:function(ak){var al=this.cloneRange();al.selectNode(ak);var aj=al.getNodes([3]);if(aj.length>0){al.setStart(aj[0],0);var ah=aj.pop();al.setEnd(ah,ah.length);var ai=this.containsRange(al);al.detach();return ai}else{return this.containsNodeContents(ak)}},createNodeIterator:function(ah,ai){g(this);return new v(this,ah,ai)},getNodes:function(ah,ai){g(this);return o(this,ah,ai)},getDocument:function(){return l(this)},collapseBefore:function(ah){B(this);this.setEndBefore(ah);this.collapse(false)},collapseAfter:function(ah){B(this);this.setStartAfter(ah);this.collapse(true)},getName:function(){return"DomRange"},equals:function(ah){return af.rangesEqual(this,ah)},inspect:function(){return y(this)}};function P(ah){ah.START_TO_START=k;ah.START_TO_END=x;ah.END_TO_END=ac;ah.END_TO_START=W;ah.NODE_BEFORE=r;ah.NODE_AFTER=u;ah.NODE_BEFORE_AND_AFTER=I;ah.NODE_INSIDE=j}function F(ah){P(ah);P(ah.prototype)}function p(ah,ai){return function(){g(this);var ao=this.startContainer,an=this.startOffset,aj=this.commonAncestorContainer;var al=new f(this,true);var am,ap;if(ao!==aj){am=a.getClosestAncestorIn(ao,aj,true);ap=T(am);ao=ap.node;an=ap.offset}S(al,X);al.reset();var ak=ah(al);al.detach();ai(this,ao,an,ao,an);return ak}}function U(ak,an,ah){function am(ap,ao){return function(aq){B(this);R(aq,ab);R(s(aq),Z);var ar=(ap?z:T)(aq);(ao?aj:al)(this,ar.node,ar.offset)}}function aj(ap,ar,at){var aq=ap.endContainer,ao=ap.endOffset;if(ar!==ap.startContainer||at!==this.startOffset){if(s(ar)!=s(aq)||a.comparePoints(ar,at,aq,ao)==1){aq=ar;ao=at}an(ap,ar,at,aq,ao)}}function al(ao,ap,at){var ar=ao.startContainer,aq=ao.startOffset;if(ap!==ao.endContainer||at!==this.endOffset){if(s(ap)!=s(ar)||a.comparePoints(ap,at,ar,aq)==-1){ar=ap;aq=at}an(ao,ar,aq,ap,at)}}function ai(ao,ap,aq){if(ap!==ao.startContainer||aq!==this.startOffset||ap!==ao.endContainer||aq!==this.endOffset){an(ao,ap,aq,ap,aq)}}ak.prototype=new Y();h.util.extend(ak.prototype,{setStart:function(ao,ap){B(this);q(ao,true);aa(ao,ap);aj(this,ao,ap)},setEnd:function(ao,ap){B(this);q(ao,true);aa(ao,ap);al(this,ao,ap)},setStartBefore:am(true,true),setStartAfter:am(false,true),setEndBefore:am(true,false),setEndAfter:am(false,false),collapse:function(ao){g(this);if(ao){an(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset)}else{an(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)}},selectNodeContents:function(ao){B(this);q(ao,true);an(this,ao,0,ao,a.getNodeLength(ao))},selectNode:function(ap){B(this);q(ap,false);R(ap,ab);var aq=z(ap),ao=T(ap);an(this,aq.node,aq.offset,ao.node,ao.offset)},extractContents:p(O,an),deleteContents:p(m,an),canSurroundContents:function(){g(this);X(this.startContainer);X(this.endContainer);var ao=new f(this,true);var ap=(ao._first&&(w(ao._first,this))||(ao._last&&w(ao._last,this)));ao.detach();return !ap},detach:function(){ah(this)},splitBoundaries:function(){g(this);var at=this.startContainer,ar=this.startOffset,ap=this.endContainer,ao=this.endOffset;var aq=(at===ap);if(a.isCharacterDataNode(ap)&&ao>0&&ao0&&ar=a.getNodeIndex(at)){ao++}}ar=0}an(this,at,ar,ap,ao)},normalizeBoundaries:function(){g(this);var aw=this.startContainer,aq=this.startOffset,av=this.endContainer,ao=this.endOffset;var ar=function(az){var ay=az.nextSibling;if(ay&&ay.nodeType==az.nodeType){av=az;ao=az.length;az.appendData(ay.data);ay.parentNode.removeChild(ay)}};var ax=function(aA){var az=aA.previousSibling;if(az&&az.nodeType==aA.nodeType){aw=aA;var ay=aA.length;aq=az.length;aA.insertData(0,az.data);az.parentNode.removeChild(az);if(aw==av){ao+=aq;av=aw}else{if(av==aA.parentNode){var aB=a.getNodeIndex(aA);if(ao==aB){av=aA;ao=ay}else{if(ao>aB){ao--}}}}}};var au=true;if(a.isCharacterDataNode(av)){if(av.length==ao){ar(av)}}else{if(ao>0){var at=av.childNodes[ao-1];if(at&&a.isCharacterDataNode(at)){ar(at)}}au=!this.collapsed}if(au){if(a.isCharacterDataNode(aw)){if(aq==0){ax(aw)}}else{if(aq0&&n.previousSibling);p=n.nextSibling;if(y==-1&&p&&i.isCharacterDataNode(p)){B.setEndPoint(o?"EndToStart":"EndToEnd",A);var s;if(/[\r\n]/.test(p.data)){var u=B.duplicate();var q=u.text.replace(/\r\n/g,"\r").length;s=u.moveStart("character",q);while((y=u.compareEndPoints("StartToEnd",u))==-1){s++;u.moveStart("character",1)}}else{s=B.text.length}m=new b(p,s)}else{w=(t||!o)&&n.previousSibling;r=(t||o)&&n.nextSibling;if(r&&i.isCharacterDataNode(r)){m=new b(r,0)}else{if(w&&i.isCharacterDataNode(w)){m=new b(w,w.length)}else{m=new b(z,i.getNodeIndex(n))}}}n.parentNode.removeChild(n);return m}function l(m,o){var p,s,q=m.offset;var t=i.getDocument(m.node);var n,u,v=t.body.createTextRange();var r=i.isCharacterDataNode(m.node);if(r){p=m.node;s=p.parentNode}else{u=m.node.childNodes;p=(q12");ad.close();var ab=d.getIframeWindow(Z).getSelection();var ae=ad.documentElement;var aa=ae.lastChild,ac=aa.firstChild;var Y=ad.createRange();Y.setStart(ac,1);Y.collapse(true);ab.addRange(Y);P=(ab.rangeCount==1);ab.removeAllRanges();var X=Y.cloneRange();Y.setStart(ac,0);X.setEnd(ac,2);ab.addRange(Y);ab.addRange(X);Q=(ab.rangeCount==2);Y.detach();X.detach();D.removeChild(Z)})()}h.features.selectionSupportsMultipleRanges=Q;h.features.collapsedNonEditableSelectionsSupported=P;var g=false,k;if(D&&m.isHostMethod(D,"createControlRange")){k=D.createControlRange();if(m.areHostProperties(k,["item","add"])){g=true}}h.features.implementsControlRange=g;if(K){o=function(X){return X.anchorNode===X.focusNode&&X.anchorOffset===X.focusOffset}}else{o=function(X){return X.rangeCount?X.getRangeAt(X.rangeCount-1).collapsed:false}}function b(aa,Y,X){var Z=X?"end":"start",ab=X?"start":"end";aa.anchorNode=Y[Z+"Container"];aa.anchorOffset=Y[Z+"Offset"];aa.focusNode=Y[ab+"Container"];aa.focusOffset=Y[ab+"Offset"]}function w(Y){var X=Y.nativeSelection;Y.anchorNode=X.anchorNode;Y.anchorOffset=X.anchorOffset;Y.focusNode=X.focusNode;Y.focusOffset=X.focusOffset}function H(X){X.anchorNode=X.focusNode=null;X.anchorOffset=X.focusOffset=0;X.rangeCount=0;X.isCollapsed=true;X._ranges.length=0}function J(X){var Y;if(X instanceof R){Y=X._selectionNativeRange;if(!Y){Y=h.createNativeRange(d.getDocument(X.startContainer));Y.setEnd(X.endContainer,X.endOffset);Y.setStart(X.startContainer,X.startOffset);X._selectionNativeRange=Y;X.attachListener("detach",function(){this._selectionNativeRange=null})}}else{if(X instanceof f){Y=X.nativeRange}else{if(h.features.implementsDomRange&&(X instanceof d.getWindow(X.startContainer).Range)){Y=X}}}return Y}function l(Z){if(!Z.length||Z[0].nodeType!=1){return false}for(var Y=1,X=Z.length;Y1){j(this,Y)}else{this.removeAllRanges();for(var Z=0,X=Y.length;Z1){j(this,X)}else{if(Y){this.addRange(X[0])}}}}else{e.fail("No means of selecting a Range or TextRange was found");return false}}a.getRangeAt=function(X){if(X<0||X>=this.rangeCount){throw new O("INDEX_SIZE_ERR")}else{return this._ranges[X]}};var F;if(v){F=function(Y){var X;if(h.isSelectionValid(Y.win)){X=Y.docSelection.createRange()}else{X=d.getBody(Y.win.document).createTextRange();X.collapse(true)}if(Y.docSelection.type==V){u(Y)}else{if(G(X)){I(Y,X)}else{H(Y)}}}}else{if(m.isHostMethod(M,"getRangeAt")&&typeof M.rangeCount=="number"){F=function(Z){if(g&&N&&Z.docSelection.type==V){u(Z)}else{Z._ranges.length=Z.rangeCount=Z.nativeSelection.rangeCount;if(Z.rangeCount){for(var Y=0,X=Z.rangeCount;Y0&&M=0;--p){r=n[p];if(r.collapsed){r.collapseBefore(m(s[p].markerId,w))}else{r.setEndBefore(m(s[p].endMarkerId,w));r.setStartAfter(m(s[p].startMarkerId,w))}}o.setRanges(n);return{win:u,doc:w,rangeInfos:s,restored:false}}function a(x,p){if(!x.restored){var s=x.rangeInfos;var o=i.getSelection(x.win);var n=[];for(var u=s.length,q=u-1,w,r;q>=0;--q){w=s[q];r=i.createRange(x.doc);if(w.collapsed){var t=m(w.markerId,x.doc);if(t){t.style.display="inline";var v=t.previousSibling;if(v&&v.nodeType==3){t.parentNode.removeChild(t);r.collapseToPoint(v,v.length)}else{r.collapseBefore(t);t.parentNode.removeChild(t)}}else{f.warn("Marker element has been removed. Cannot restore selection.")}}else{l(x.doc,r,w.startMarkerId,true);l(x.doc,r,w.endMarkerId,false)}if(u==1){r.normalizeBoundaries()}n[q]=r}if(u==1&&p&&i.features.selectionHasExtend&&s[0].backwards){o.removeAllRanges();o.addRange(n[0],true)}else{o.setRanges(n)}x.restored=true}}function j(p,o){var n=m(o,p);if(n){n.parentNode.removeChild(n)}}function k(o){var r=o.rangeInfos;for(var q=0,n=r.length,p;q>6)|192,(D&63)|128)}else{B.push((D>>12)|224,((D>>6)&63)|128,(D&63)|128)}}}return B}var w=null;function v(){var B=[];for(var A=0,z,C;A<256;++A){C=A;z=8;while(z--){if((C&1)==1){C=(C>>>1)^3988292384}else{C>>>=1}}B[A]=C>>>0}return B}function x(){if(!w){w=v()}return w}return function(E){var D=y(E),C=-1,A=x();for(var B=0,z=D.length,F;B>>8)^A[F]}return(C^-1)>>>0}})();var s=q.dom;function e(v){return v.replace(//g,">")}function p(y,x){x=x||[];var B=y.nodeType,w=y.childNodes,A=w.length;var D=[B,y.nodeName,A].join(":");var v="",z="";switch(B){case 3:v=e(y.nodeValue);break;case 8:v="";break;default:v="<"+D+">";z="";break}if(v){x.push(v)}for(var C=0;C
"))}}else{f.appendChild(ice.dom.create("<"+this.blockEl+" >
"))}this.element.innerHTML=f.innerHTML;var h=new Array();for(var e in this.changeTypes){h.push(this._getIceNodeClass(e))}ice.dom.each(ice.dom.find(this.element,"."+h.join(", .")),function(l,k){var n=0;var p="";var j=k.className.split(" ");for(var l=0;l')});return true},revertDeletePlaceholders:function(){var e=this;if(!this.isPlaceholdingDeletes){return false}ice.dom.each(this._deletes,function(f,g){ice.dom.find(e.element,e._delBookmark+"[data-allocation="+f+"]").replaceWith(g)});this.isPlaceholdingDeletes=false;return true},deleteContents:function(g,f){var e=true;if(f){this.selection.addRange(f)}else{f=this.getCurrentRange()}var h=this.startBatchChange(this.changeTypes.deleteType.alias);if(f.collapsed===false){this._deleteFromSelection(f)}else{if(g){e=this._deleteFromRight(f)}else{e=this._deleteFromLeft(f)}}this.selection.addRange(f);this.endBatchChange(h);return e},getChanges:function(){return this._changes},getElementContent:function(){return this.element.innerHTML},getCleanContent:function(e,j){var i="";var f=this;ice.dom.each(this.changeTypes,function(l,k){if(l!="deleteType"){if(k>0){i+=","}i+="."+f._getIceNodeClass(l)}});if(e){if(typeof e==="string"){e=ice.dom.create("
"+e+"
")}else{e=ice.dom.cloneNode(e,false)[0]}}else{e=ice.dom.cloneNode(this.element,false)[0]}var g=ice.dom.find(e,i);ice.dom.each(g,function(l,k){ice.dom.replaceWith(this,ice.dom.contents(this))});var h=ice.dom.find(e,"."+this._getIceNodeClass("deleteType"));ice.dom.remove(h);e=j?j.call(this,e):e;return e.innerHTML},acceptAll:function(){this.element.innerHTML=this.getCleanContent()},rejectAll:function(){var f="."+this._getIceNodeClass("insertType");var e="."+this._getIceNodeClass("deleteType");ice.dom.remove(ice.dom.find(this.element,f));ice.dom.each(ice.dom.find(this.element,e),function(g,h){ice.dom.replaceWith(h,ice.dom.contents(h))})},acceptChange:function(e){this.acceptRejectChange(e,true)},rejectChange:function(e){this.acceptRejectChange(e,false)},acceptRejectChange:function(g,m){var o,l,h,n,f,e,k,i=ice.dom;if(!g){var j=this.getCurrentRange();if(!j.collapsed){return}else{g=j.startContainer}}o=n="."+this._getIceNodeClass("deleteType");l=f="."+this._getIceNodeClass("insertType");h=o+","+l;e=i.getNode(g,h);k=i.find(this.element,"["+this.changeIdAttribute+"="+i.attr(e,this.changeIdAttribute)+"]");if(!m){n=l;f=o}if(ice.dom.is(e,f)){i.each(k,function(p,q){i.replaceWith(q,ice.dom.contents(q))})}else{if(i.is(e,n)){i.remove(k)}}},isInsideChange:function(f){var e="."+this._getIceNodeClass("insertType")+", ."+this._getIceNodeClass("deleteType");if(!f){range=this.getCurrentRange();if(!range.collapsed){return false}else{f=range.startContainer}}return !!ice.dom.getNode(f,e)},addChangeType:function(g,f,h,i){var e={tag:f,alias:h};if(i){e.action=i}this.changeTypes[g]=e},getIceNode:function(g,f){var e="."+this._getIceNodeClass(f);return ice.dom.getNode(g,e)},_moveRangeToValidTrackingPos:function(f){var g=false;var h=this._getVoidElement(f.endContainer);while(h){try{f.moveEnd(ice.dom.CHARACTER_UNIT,1);f.moveEnd(ice.dom.CHARACTER_UNIT,-1)}catch(i){g=true}if(g||ice.dom.onBlockBoundary(f.endContainer,f.startContainer,this.blockEl)){f.setStartAfter(h);f.collapse(true);break}h=this._getVoidElement(f.endContainer);if(h){f.setEnd(f.endContainer,0);f.moveEnd(ice.dom.CHARACTER_UNIT,ice.dom.getNodeTextContent(f.endContainer).length);f.collapse()}else{f.setStart(f.endContainer,0);f.collapse(true)}}},_getNoTrackElement:function(g){var f=this._getNoTrackSelector();var e=ice.dom.is(g,f)?g:(ice.dom.parents(g,f)[0]||null);return e},_getNoTrackSelector:function(){return'.ins[userid="'+this.currentUser.id+'"],'+this.noTrack},_getVoidElement:function(f){var e=this._getVoidElSelector();return ice.dom.is(f,e)?f:(ice.dom.parents(f,e)[0]||null)},_getVoidElSelector:function(){return"."+this._getIceNodeClass("deleteType")+","+this.avoid},_currentUserIceNode:function(e){return ice.dom.attr(e,this.userIdAttribute)==this.currentUser.id},_getChangeTypeFromAlias:function(f){var g,e=null;for(g in this.changeTypes){if(this.changeTypes.hasOwnProperty(g)){if(this.changeTypes[g].alias==f){e=g}}}return e},_getIceNodeClass:function(e){return this.attrValuePrefix+this.changeTypes[e].alias},getUserStyle:function(e){var f=null;if(this._userStyles[e]){f=this._userStyles[e]}else{f=this.setUserStyle(e,this.getNewStyleId())}return f},setUserStyle:function(e,g){var f=this.stylePrefix+"-"+g;if(!this._styles[g]){this._styles[g]=true}return this._userStyles[e]=f},getNewStyleId:function(){var e=++this._uniqueStyleIndex;if(this._styles[e]){return this.getNewStyleId()}else{this._styles[e]=true;return e}},addChange:function(f,h){var g=this._batchChangeid||this.getNewChangeId();if(!this._changes[g]){this._changes[g]={type:this._getChangeTypeFromAlias(f),time:(new Date()).getTime(),userid:this.currentUser.id,username:this.currentUser.name}}var e=this;ice.dom.foreach(h,function(j){e.addNodeToChange(g,h[j])});return g},addNodeToChange:function(g,f){if(this._batchChangeid!==null){g=this._batchChangeid}var h=this.getChange(g);if(!f.getAttribute(this.changeIdAttribute)){f.setAttribute(this.changeIdAttribute,g)}if(!f.getAttribute(this.userIdAttribute)){f.setAttribute(this.userIdAttribute,h.userid)}if(!f.getAttribute(this.userNameAttribute)){f.setAttribute(this.userNameAttribute,h.username)}if(!f.getAttribute(this.timeAttribute)){f.setAttribute(this.timeAttribute,h.time)}if(!ice.dom.hasClass(f,this._getIceNodeClass(h.type))){ice.dom.addClass(f,this._getIceNodeClass(h.type))}var e=this.getUserStyle(h.userid);if(!ice.dom.hasClass(f,e)){ice.dom.addClass(f,e)}},getChange:function(e){var f=null;if(this._changes[e]){f=this._changes[e]}return f},getNewChangeId:function(){var e=++this._uniqueIDIndex;if(this._changes[e]){e=this.getNewChangeId()}return e},startBatchChange:function(){this._batchChangeid=this.getNewChangeId();return this._batchChangeid},endBatchChange:function(e){if(e!==this._batchChangeid){return}this._batchChangeid=null},getCurrentRange:function(){return this.selection.getRangeAt(0)},_insertNode:function(g,e,f){var h=this.getIceNode(e.startContainer,"insertType");var i=this._currentUserIceNode(h);if(f&&i){return}else{if(!i){g=this.createIceNode("insertType",g)}}e.insertNode(g);if(f){e.setStart(g,0);e.setEnd(g,1)}this.selection.addRange(e)},_deleteFromSelection:function(l){var n=new ice.Bookmark(this.env,l),e=ice.dom.getElementsBetween(n.start,n.end),q=ice.dom.parents(l.startContainer,this.blockEl)[0],o=ice.dom.parents(l.endContainer,this.blockEl)[0],r=new Array(),m=e.length;var m=e.length;for(var k=0;k0){i=String.fromCharCode(h.which)}}var f=this.getCurrentRange();var g=ice.dom.parents(f.startContainer,"br")[0]||null;if(g){f.moveToNextEl(g);g.parentNode.removeChild(g)}if(i!==null&&h.ctrlKey!==true&&h.metaKey!==true){switch(h.keyCode){case ice.dom.DOM_VK_DELETE:return this._handleAncillaryKey(h);case ice.dom.DOM_VK_ENTER:return this._handleEnter();default:this._moveRangeToValidTrackingPos(f,f.startContainer);return this.insert();break}}return this._handleAncillaryKey(h)},_handleEnter:function(){var e=this.getCurrentRange();if(!e.collapsed){this.deleteContents()}return true},_handleSpecialKey:function(k){var j=k.which;if(j===null){j=k.keyCode}var h=false;switch(j){case 65:if(k.ctrlKey===true||k.metaKey===true){h=true;var g=this.getCurrentRange();if(ice.dom.isBrowser("msie")===true){var l=this.env.document.createTextNode("");var f=this.env.document.createTextNode("");if(this.element.firstChild){ice.dom.insertBefore(this.element.firstChild,l)}else{this.element.appendChild(l)}this.element.appendChild(f);g.setStart(l,0);g.setEnd(f,0)}else{g.setStart(g.getFirstSelectableChild(this.element),0);var i=g.getLastSelectableChild(this.element);g.setEnd(i,i.length)}this.selection.addRange(g)}break;default:break}if(h===true){ice.dom.preventDefault(k);return false}return true},mouseUp:function(g,f){if(!this.pluginsManager.fireClicked(g)){return false}this.pluginsManager.fireSelectionChanged(this.getCurrentRange())},mouseDown:function(g,f){if(!this.pluginsManager.fireMouseDown(g)){return false}this.pluginsManager.fireCaretUpdated()}};a.ice=this.ice||{};a.ice.InlineChangeEditor=b}).call(this);(function(){var a=this,b={};b.DOM_VK_DELETE=8;b.DOM_VK_LEFT=37;b.DOM_VK_UP=38;b.DOM_VK_RIGHT=39;b.DOM_VK_DOWN=40;b.DOM_VK_ENTER=13;b.ELEMENT_NODE=1;b.ATTRIBUTE_NODE=2;b.TEXT_NODE=3;b.CDATA_SECTION_NODE=4;b.ENTITY_REFERENCE_NODE=5;b.ENTITY_NODE=6;b.PROCESSING_INSTRUCTION_NODE=7;b.COMMENT_NODE=8;b.DOCUMENT_NODE=9;b.DOCUMENT_TYPE_NODE=10;b.DOCUMENT_FRAGMENT_NODE=11;b.NOTATION_NODE=12;b.CHARACTER_UNIT="character";b.WORD_UNIT="word";b.getKeyChar=function(d){return String.fromCharCode(d.which)};b.getClass=function(f,e,d){if(!e){e=document.body}f="."+f.split(" ").join(".");if(d){f=d+f}return jQuery.makeArray(jQuery(e).find(f))};b.getId=function(e,d){if(!d){d=document}element=d.getElementById(e);return element};b.getTag=function(d,e){if(!e){e=document}return jQuery.makeArray(jQuery(e).find(d))};b.getElementWidth=function(d){return d.offsetWidth};b.getElementHeight=function(d){return d.offsetHeight};b.getElementDimensions=function(e){var d={width:b.getElementWidth(e),height:b.getElementHeight(e)};return d};b.trim=function(d){return jQuery.trim(d)};b.empty=function(d){if(d){return jQuery(d).empty()}};b.remove=function(d){if(d){return jQuery(d).remove()}};b.prepend=function(d,e){jQuery(d).prepend(e)};b.append=function(d,e){jQuery(d).append(e)};b.insertBefore=function(e,d){jQuery(e).before(d)};b.insertAfter=function(e,d){jQuery(e).after(d)};b.getHtml=function(d){return jQuery(d).html()};b.setHtml=function(d,e){if(d){jQuery(d).html(e)}};b.contents=function(d){return jQuery(d).contents()};b.extractContent=function(d){var f=document.createDocumentFragment(),e;while((e=d.firstChild)){f.appendChild(e)}return f},b.getNode=function(e,d){return b.is(e,d)?e:b.parents(e,d)[0]||null},b.getParents=function(k,g,j){var f=jQuery(k).parents(g);var h=f.length;var d=[];for(var e=0;e0){e--;if(b.isStubElement(d[e])===false){if(!g||g.call(this,d[e])!==false){b.remove(d[e])}}}};b.create=function(d){return jQuery(d)[0]};b.find=function(d,e){return jQuery(d).find(e)};b.children=function(d,e){return jQuery(d).children(e)};b.parent=function(e,d){return jQuery(e).parent(d)[0]};b.parents=function(e,d){return jQuery(e).parents(d)};b.is=function(d,e){return jQuery(d).is(e)};b.extend=function(d,g,f,e){return jQuery.extend.apply(this,arguments)};b.walk=function(e,g,d){if(!e){return}if(!d){d=0}var f=g.call(this,e,d);if(f===false){return}if(e.childNodes&&e.childNodes.length>0){b.walk(e.firstChild,g,(d+1))}else{if(e.nextSibling){b.walk(e.nextSibling,g,d)}else{if(e.parentNode&&e.parentNode.nextSibling){b.walk(e.parentNode.nextSibling,g,(d-1))}}}};b.revWalk=function(d,f){if(!d){return}var e=f.call(this,d);if(e===false){return}if(d.childNodes&&d.childNodes.length>0){b.walk(d.lastChild,f)}else{if(d.previousSibling){b.walk(d.previousSibling,f)}else{if(d.parentNode&&d.parentNode.previousSibling){b.walk(d.parentNode.previousSibling,f)}}}};b.setStyle=function(d,f,e){if(d){jQuery(d).css(f,e)}};b.getStyle=function(d,e){return jQuery(d).css(e)};b.hasClass=function(d,e){return jQuery(d).hasClass(e)};b.addClass=function(d,e){jQuery(d).addClass(e)};b.removeClass=function(d,e){jQuery(d).removeClass(e)};b.preventDefault=function(d){d.preventDefault();b.stopPropagation(d)};b.stopPropagation=function(d){d.stopPropagation()};b.noInclusionInherits=function(f,e){if(e instanceof String||typeof e==="string"){e=window[e]}if(f instanceof String||typeof f==="string"){f=window[f]}var d=function(){};if(b.isset(e)===true){for(value in e.prototype){if(f.prototype[value]){d.prototype[value]=e.prototype[value];continue}f.prototype[value]=e.prototype[value]}}if(f.prototype){d.prototype.constructor=e;f.prototype["super"]=new d()}};b.each=function(d,e){jQuery.each(d,function(f,g){e.call(this,f,g)})};b.foreach=function(h,e){if(h instanceof Array||h instanceof NodeList||typeof h.length!="undefined"&&typeof h.item!="undefined"){var d=h.length;for(var g=0;g"+f+"");h.find("*").not(i).remove();return h.html()}else{var d;var e=new RegExp(/<\/?(\w+)((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)\/?>/gim);var g=f;while((d=e.exec(f))!=null){if(b.isset(i)===false||b.inArray(d[1],i)!==true){g=g.replace(d[0],"")}}return g}};b.browser=function(){var d={};d.version=jQuery.browser.version;if(jQuery.browser.mozilla===true){d.type="mozilla"}else{if(jQuery.browser.msie===true){d.type="msie"}else{if(jQuery.browser.opera===true){d.type="opera"}else{if(jQuery.browser.safari===true){d.type="safari"}}}}return d};b.getBrowserType=function(){if(this._browserType===null){var f=["msie","firefox","chrome","safari"];var e=f.length;for(var d=0;d12){d-=12}}break;case"i":d=b.addNumberPadding(h.getMinutes());break;case"a":d="am";if(h.getHours()>=12){d="pm"}break;default:d=l;break}j+=d}return j};b.getOrdinalSuffix=function(e){var f="";var d=(e%100);if(d>=4&&d<=20){f="th"}else{switch(e%10){case 1:f="st";break;case 2:f="nd";break;case 3:f="rd";break;default:f="th";break}}return f};b.addNumberPadding=function(d){if(d<10){d="0"+d}return d};b.tsIso8601ToTimestamp=function(e){var h=/(\d\d\d\d)(?:-?(\d\d)(?:-?(\d\d)(?:[T ](\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(?:Z|(?:([-+])(\d\d)(?::?(\d\d))?)?)?)?)?)?/;var j=e.match(new RegExp(h));if(j){var f=new Date();f.setDate(j[3]);f.setFullYear(j[1]);f.setMonth(j[2]-1);f.setHours(j[4]);f.setMinutes(j[5]);f.setSeconds(j[6]);var i=(j[9]*60);if(j[8]==="+"){i*=-1}i-=f.getTimezoneOffset();var g=(f.getTime()+(i*60*1000));return g}return null};a.dom=b}).call(this.ice);(function(){var a=this,b;b=function(j,g,p){this.env=j;this.element=j.element;this.selection=this.env.selection;if(!p){this.removeBookmarks(this.element)}var n=g||this.selection.getRangeAt(0);var g=n.cloneRange();var d=g.startContainer;var o=g.endContainer;var l=g.startOffset;var m=g.endOffset;g.collapse(false);var i=this.env.document.createElement("span");i.style.display="none";ice.dom.setHtml(i," ");ice.dom.addClass(i,"iceBookmark iceBookmark_end");i.setAttribute("iceBookmark","end");g.insertNode(i);if(!ice.dom.isChildOf(i,this.element)){this.element.appendChild(i)}g.setStart(d,l);g.collapse(true);var h=this.env.document.createElement("span");h.style.display="none";ice.dom.addClass(h,"iceBookmark iceBookmark_start");ice.dom.setHtml(h," ");h.setAttribute("iceBookmark","start");try{g.insertNode(h);if(h.previousSibling===i){var f=h;h=i;i=f}}catch(k){ice.dom.insertBefore(i,h)}if(ice.dom.isChildOf(h,this.element)===false){if(this.element.firstChild){ice.dom.insertBefore(this.element.firstChild,h)}else{this.element.appendChild(h)}}if(!i.previousSibling){var f=this.env.document.createTextNode("");ice.dom.insertBefore(i,f)}if(!h.nextSibling){var f=this.env.document.createTextNode("");ice.dom.insertAfter(h,f)}n.setStart(h.nextSibling,0);n.setEnd(i.previousSibling,(i.previousSibling.length||0));this.start=h;this.end=i};b.prototype={selectBookmark:function(){var f=this.selection.getRangeAt(0);var i=null;var h=null;var d=0;var g=null;if(this.start.nextSibling===this.end||ice.dom.getElementsBetween(this.start,this.end).length===0){if(this.end.nextSibling){i=ice.dom.getFirstChild(this.end.nextSibling)}else{if(this.start.previousSibling){i=ice.dom.getFirstChild(this.start.previousSibling);if(i.nodeType===ice.dom.TEXT_NODE){d=i.length}}else{this.end.parentNode.appendChild(this.env.document.createTextNode(""));i=ice.dom.getFirstChild(this.end.nextSibling)}}}else{if(this.start.nextSibling){i=ice.dom.getFirstChild(this.start.nextSibling)}else{if(!this.start.previousSibling){var j=this.env.document.createTextNode("");ice.dom.insertBefore(this.start,j)}i=ice.dom.getLastChild(this.start.previousSibling);d=i.length}if(this.end.previousSibling){h=ice.dom.getLastChild(this.end.previousSibling)}else{h=ice.dom.getFirstChild(this.end.nextSibling);g=0}}ice.dom.remove([this.start,this.end]);if(h===null){f.setEnd(i,d);f.collapse(false)}else{f.setStart(i,d);if(g===null){g=(h.length||0)}f.setEnd(h,g)}try{this.selection.addRange(f)}catch(k){}},getBookmark:function(e,d){var f=ice.dom.getClass("iceBookmark_"+d,e)[0];return f},removeBookmarks:function(d){ice.dom.remove(ice.dom.getClass("iceBookmark",d,"span"))}};a.Bookmark=b}).call(this.ice);(function(){var a=this,b;b=function(d){this._selection=null;this.env=d;this._initializeRangeLibrary();if(this.env.frame){this._selection=rangy.getIframeSelection(this.env.frame)}else{this._selection=rangy.getSelection()}};b.prototype={_getSelection:function(){if(this._selection){this._selection.refresh()}else{if(this.env.frame){this._selection=rangy.getIframeSelection(this.env.frame)}else{this._selection=rangy.getSelection()}}return this._selection},createRange:function(){return rangy.createRange(this.env.document)},getRangeAt:function(f){this._selection.refresh();try{return this._selection.getRangeAt(f)}catch(d){return this.createRange()}},addRange:function(d){this._selection||(this._selection=this._getSelection());this._selection.setSingleRange(d);this._selection.ranges=[d];return},_initializeRangeLibrary:function(){var d=this;rangy.init();rangy.config.checkSelectionRanges=false;rangy.rangePrototype.moveStart=function(f,e){if(e===0){throw Error("InvalidArgumentException: units cannot be 0")}switch(f){case ice.dom.CHARACTER_UNIT:if(e>0){this.moveCharRight(true,e)}else{this.moveCharLeft(true,e)}break;case ice.dom.WORD_UNIT:default:break}};rangy.rangePrototype.moveEnd=function(f,e){if(e===0){throw Error("InvalidArgumentException: units cannot be 0")}switch(f){case ice.dom.CHARACTER_UNIT:if(e>0){this.moveCharRight(false,e)}else{this.moveCharLeft(false,e)}break;case ice.dom.WORD_UNIT:default:break}};rangy.rangePrototype.setRange=function(g,e,f){if(g){this.setStart(e,f)}else{this.setEnd(e,f)}};rangy.rangePrototype.moveCharLeft=function(h,g){var f,i;if(h){f=this.startContainer;i=this.startOffset}else{f=this.endContainer;i=this.endOffset}i+=g;if(i<0){while(i<0){var e=[];if(!this.getPreviousContainer(f,e)){if(g===-1){return}i=0;break}f=this.getPreviousContainer(f,e);if(f.nodeType===ice.dom.ELEMENT_NODE){continue}i=f.data.length;i--}}this.setRange(h,f,i)};rangy.rangePrototype.moveCharRight=function(h,g){var f,j;if(h){f=this.startContainer;j=this.startOffset}else{f=this.endContainer;j=this.endOffset}if(f.nodeType===ice.dom.ELEMENT_NODE){f=f.childNodes[j];if(f.nodeType!==ice.dom.TEXT_NODE){f=this.getNextTextNode(f)}j=g}else{j+=g}var i=(j-f.data.length);if(i>0){var e=[];while(i>0){f=this.getNextContainer(f,e);if(f.nodeType===ice.dom.ELEMENT_NODE){continue}if(f.data.length>=i){break}else{if(f.data.length>0){i-=f.data.length}}}j=i}this.setRange(h,f,j)};rangy.rangePrototype.getNextContainer=function(f,e){if(!f){return null}while(f.nextSibling){f=f.nextSibling;if(f.nodeType!==ice.dom.TEXT_NODE){var h=this.getFirstSelectableChild(f);if(h!==null){return h}}else{if(this.isSelectable(f)===true){return f}}}while(f&&!f.nextSibling){f=f.parentNode}if(!f){return null}f=f.nextSibling;if(this.isSelectable(f)===true){return f}else{if(e&&ice.dom.isBlockElement(f)===true){e.push(f)}}var g=this.getFirstSelectableChild(f);if(g!==null){return g}return this.getNextContainer(f,e)};rangy.rangePrototype.getPreviousContainer=function(f,e){if(!f){return null}while(f.previousSibling){f=f.previousSibling;if(f.nodeType!==ice.dom.TEXT_NODE){if(ice.dom.isStubElement(f)===true){return f}else{var h=this.getLastSelectableChild(f);if(h!==null){return h}}}else{if(this.isSelectable(f)===true){return f}}}while(f&&!f.previousSibling){f=f.parentNode}if(!f){return null}f=f.previousSibling;if(this.isSelectable(f)===true){return f}else{if(e&&ice.dom.isBlockElement(f)===true){e.push(f)}}var g=this.getLastSelectableChild(f);if(g!==null){return g}return this.getPreviousContainer(f,e)};rangy.rangePrototype.getStartOffset=function(f){if(f===true){return this.startOffset}var g=0;var e=this.startContainer;var i=e.data.charCodeAt(0);while(i===10||i===32){g++;i=e.data.charCodeAt(g)}var h=(this.startOffset-g);return h};rangy.rangePrototype.getNextTextNode=function(e){if(e.nodeType===ice.dom.ELEMENT_NODE){if(e.childNodes.length!==0){return this.getFirstSelectableChild(e)}}e=this.getNextContainer(e);if(e.nodeType===ice.dom.TEXT_NODE){return e}return this.getNextTextNode(e)};rangy.rangePrototype.getFirstSelectableChild=function(f){if(f){if(f.nodeType!==ice.dom.TEXT_NODE){var g=f.firstChild;while(g){if(this.isSelectable(g)===true){return g}else{if(g.firstChild){var e=this.getFirstSelectableChild(g);if(e!==null){return e}else{g=g.nextSibling}}else{g=g.nextSibling}}}}else{return f}}return null};rangy.rangePrototype.getLastSelectableChild=function(f){if(f){if(f.nodeType!==ice.dom.TEXT_NODE){var g=f.lastChild;while(g){if(this.isSelectable(g)===true){return g}else{if(g.lastChild){var e=this.getLastSelectableChild(g);if(e!==null){return e}else{g=g.previousSibling}}else{g=g.previousSibling}}}}else{return f}}return null};rangy.rangePrototype.isSelectable=function(e){if(e&&e.nodeType===ice.dom.TEXT_NODE&&e.data.length!==0){return true}return false};rangy.rangePrototype.getHTMLContents=function(e){if(!e){e=this.cloneContents()}var f=d.env.document.createElement("div");f.appendChild(e.cloneNode(true));return f.innerHTML};rangy.rangePrototype.getHTMLContentsObj=function(){return this.cloneContents()}}};a.Selection=b}).call(this.ice);(function(){var a=this;var b=function(d){this._ice=d};b.prototype={start:function(){},clicked:function(d){return true},mouseDown:function(d){return true},keyDown:function(d){return true},keyPress:function(d){return true},selectionChanged:function(d){},setEnabled:function(d){},setDisabled:function(d){},caretUpdated:function(){},nodeInserted:function(e,d){},nodeCreated:function(e,d){},caretPositioned:function(){},remove:function(){this._ice.removeKeyPressListener(this)},setSettings:function(d){}};a.IcePlugin=b}).call(this.ice);(function(){var a=this;var b=function(d){this.plugins={},this.pluginConstructors={},this.keyPressListeners={},this.activePlugin=null,this.pluginSets={},this.activePluginSet=null,this._ice=d};b.prototype={getPluginNames:function(){var d=[];for(var e in this.plugins){d.push(e)}return d},addPluginObject:function(d,e){this.plugins[d]=e},addPlugin:function(d,e){if(typeof e!=="function"){throw Error("IcePluginException: plugin must be a constructor function")}if(ice.dom.isset(this.pluginConstructors[d])===false){this.pluginConstructors[d]=e}},loadPlugins:function(d,f){if(d.length===0){f.call(this)}else{var e=d.shift();if(typeof e==="object"){e=e.name}if(ice.dom.isset(ice._plugin[e])===true){this.addPlugin(e,ice._plugin[e]);this.loadPlugins(d,f)}else{throw new Error("plugin was not included in the page: "+e)}}},_enableSet:function(d){this.activePluginSet=d;var g=this.pluginSets[d].length;for(var f=0;f
");this._ice.element.appendChild(f)}d.setStart(f,0);d.collapse(true);this._ice.env.selection.addRange(d)}this._tmpNode=this._ice.env.document.createElement(this._tmpNodeTagName);d.insertNode(this._tmpNode);switch(this.pasteType){case"formatted":this.setupPaste();break;case"formattedClean":this.setupPaste(true);break}return true},setupPaste:function(e){var f=this.createDiv(this._pasteId),d=this;f.focus();f.onpaste=function(){setTimeout(function(){d.handlePasteValue(e)},1)};return true},handlePasteValue:function(k){var l=ice.dom.getHtml(document.getElementById(this._pasteId));var i=ice.dom.children("
"+l+"
",this._ice.blockEl);if(i.length===1&&ice.dom.getNodeTextContent("
"+l+"
")===ice.dom.getNodeTextContent(i)){l=ice.dom.getHtml(l)}if(k){l=this._ice.getCleanContent(l);l=this.stripPaste(l)}l=this.afterPasteClean.call(this,l);l=ice.dom.trim(l);var m=this._ice.getCurrentRange();m.setStartAfter(this._tmpNode);m.collapse(true);var h=null;var n=m.createContextualFragment(l);var r=this._ice.startBatchChange();if(ice.dom.hasBlockChildren(n)){var j=ice.dom.isChildOfTagName(this._tmpNode,this._ice.blockEl);m.setEndAfter(j.lastChild);this._ice.selection.addRange(m);var g=m.extractContents();var o=this._ice.env.document.createElement(this._ice.blockEl);o.appendChild(g);ice.dom.insertAfter(j,o);m.setStart(o,0);m.collapse(true);this._ice.selection.addRange(m);var d=m.startContainer;var q=null,h=null,f=null;while(n.firstChild){if(n.firstChild.nodeType===3&&!jQuery.trim(n.firstChild.nodeValue)){n.removeChild(n.firstChild);continue}if(ice.dom.isBlockElement(n.firstChild)){if(n.firstChild.textContent!==""){q=null;var p=null;if(this._ice.isTracking){p=this._ice.createIceNode("insertType");this._ice.addChange("insertType",[p]);h=document.createElement(n.firstChild.tagName);p.innerHTML=n.firstChild.innerHTML;h.appendChild(p)}else{p=h=document.createElement(n.firstChild.tagName);h.innerHTML=n.firstChild.innerHTML}f=p;ice.dom.insertBefore(d,h)}n.removeChild(n.firstChild)}else{if(!q){h=document.createElement(this._ice.blockEl);ice.dom.insertBefore(d,h);if(this._ice.isTracking){q=this._ice.createIceNode("insertType");this._ice.addChange("insertType",[q]);h.appendChild(q)}else{q=h}}f=q;q.appendChild(n.removeChild(n.firstChild))}}if(!o.textContent){o.parentNode.removeChild(o)}}else{if(this._ice.isTracking){h=this._ice.createIceNode("insertType",n);this._ice.addChange("insertType",[h]);m.insertNode(h);f=h}else{var e;while((e=n.firstChild)){m.insertNode(e);m.setStartAfter(e);m.collapse(true);f=e}}}this._ice.endBatchChange(r);this._cleanup(f)},createDiv:function(f){var d=ice.dom.getId(f);if(d){ice.dom.empty(d);return d}var e=this._ice.env.document.createElement("div");e.id=f;e.setAttribute("contentEditable",true);ice.dom.setStyle(e,"width","1px");ice.dom.setStyle(e,"height","1px");ice.dom.setStyle(e,"overflow","hidden");ice.dom.setStyle(e,"position","fixed");ice.dom.setStyle(e,"top","10px");ice.dom.setStyle(e,"left","10px");document.body.appendChild(e);return e},handleCut:function(){this.cutElementId="icecut";this.cutElement=this.createDiv(this.cutElementId);var e=this._ice.getCurrentRange();if(e.collapsed){return}var g=e.getHTMLContents();if(this._ice.isTracking){this._ice.deleteContents()}else{e.deleteContents()}var f=e.cloneRange();f.collapse(true);this.cutElement.innerHTML=g;e.setStart(this.cutElement.firstChild,0);e.setEndAfter(this.cutElement.lastChild,this.cutElement.lastChild.length);var d=this;setTimeout(function(){e.setStart(f.startContainer,f.startOffset);e.collapse(true);d._ice.env.selection.addRange(e);ice.dom.remove(this.cutElement)},10)},stripPaste:function(d){d=this._cleanWordPaste(d);d=this.cleanPreserved(d);return d},setupPreserved:function(){var d=this;this._tags="";this._attributesMap=[];ice.dom.each(this.preserve.split(","),function(h,g){g.match(/(\w+)(\[(.+)\])?/);var f=RegExp.$1;var e=RegExp.$3;if(d._tags){d._tags+=","}d._tags+=f.toLowerCase();d._attributesMap[f]=e.split("|")})},cleanPreserved:function(e){var f=this;var d=this._ice.env.document.createElement("div");d.innerHTML=e;d=ice.dom.stripEnclosingTags(d,this._tags);ice.dom.each(ice.dom.find(d,this._tags),function(k,l){if(ice.dom.hasClass(l,"skip-clean")){return true}var g=l.tagName.toLowerCase();var j=f._attributesMap[g];if(j[0]&&j[0]==="*"){return true}if(l.hasAttributes()){var h=l.attributes;for(var k=h.length-1;k>=0;k--){if(!ice.dom.inArray(h[k].name,j)){l.removeAttribute(h[k].name)}}}});return d.innerHTML},_cleanWordPaste:function(d){d=d.replace(/<(meta|link)[^>]+>/g,"");d=d.replace(//g,"");d=d.replace(/