/* Rangy, a cross-browser JavaScript range and selection library http://code.google.com/p/rangy/ Copyright 2011, Tim Down Licensed under the MIT license. Version: 1.2.2 Build date: 13 November 2011 */ window.rangy=function(){function k(p,u){var w=typeof p[u];return w=="function"||!!(w=="object"&&p[u])||w=="unknown"}function L(p,u){return!!(typeof p[u]=="object"&&p[u])}function J(p,u){return typeof p[u]!="undefined"}function K(p){return function(u,w){for(var B=w.length;B--;)if(!p(u,w[B]))return false;return true}}function z(p){return p&&A(p,x)&&v(p,t)}function C(p){window.alert("Rangy not supported in your browser. Reason: "+p);c.initialized=true;c.supported=false}function N(){if(!c.initialized){var p, u=false,w=false;if(k(document,"createRange")){p=document.createRange();if(A(p,n)&&v(p,g))u=true;p.detach()}if((p=L(document,"body")?document.body:document.getElementsByTagName("body")[0])&&k(p,"createTextRange")){p=p.createTextRange();if(z(p))w=true}!u&&!w&&C("Neither Range nor TextRange are implemented");c.initialized=true;c.features={implementsDomRange:u,implementsTextRange:w};u=j.concat(f);w=0;for(p=u.length;w["+c.childNodes.length+"]":c.nodeName}function n(c){this._next=this.root=c}function t(c,f){this.node=c;this.offset=f}function x(c){this.code=this[c]; this.codeName=c;this.message="DOMException: "+this.codeName}var A=k.util;A.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||L.fail("document missing a Node creation method");A.isHostMethod(document,"getElementsByTagName")||L.fail("document missing getElementsByTagName method");var q=document.createElement("div");A.areHostMethods(q,["insertBefore","appendChild","cloneNode"])||L.fail("Incomplete Element implementation");A.isHostProperty(q,"innerHTML")||L.fail("Element is missing innerHTML property"); q=document.createTextNode("test");A.areHostMethods(q,["splitText","deleteData","insertData","appendData","cloneNode"])||L.fail("Incomplete Text Node implementation");var v=function(c,f){for(var j=c.length;j--;)if(c[j]===f)return true;return false};n.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var c=this._current=this._next,f;if(this._current)if(f=c.firstChild)this._next=f;else{for(f=null;c!==this.root&&!(f=c.nextSibling);)c=c.parentNode;this._next=f}return this._current}, detach:function(){this._current=this._next=this.root=null}};t.prototype={equals:function(c){return this.node===c.node&this.offset==c.offset},inspect:function(){return"[DomPosition("+g(this.node)+":"+this.offset+")]"}};x.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};x.prototype.toString=function(){return this.message};k.dom={arrayContains:v,isHtmlNamespace:function(c){var f;return typeof c.namespaceURI== "undefined"||(f=c.namespaceURI)===null||f=="http://www.w3.org/1999/xhtml"},parentElement:function(c){c=c.parentNode;return c.nodeType==1?c:null},getNodeIndex:J,getNodeLength:function(c){var f;return C(c)?c.length:(f=c.childNodes)?f.length:0},getCommonAncestor:K,isAncestorOf:function(c,f,j){for(f=j?f:f.parentNode;f;)if(f===c)return true;else f=f.parentNode;return false},getClosestAncestorIn:z,isCharacterDataNode:C,insertAfter:N,splitDataNode:function(c,f){var j=c.cloneNode(false);j.deleteData(0,f); c.deleteData(f,c.length-f);N(j,c);return j},getDocument:O,getWindow:function(c){c=O(c);if(typeof c.defaultView!="undefined")return c.defaultView;else if(typeof c.parentWindow!="undefined")return c.parentWindow;else throw Error("Cannot get a window object for node");},getIframeWindow:function(c){if(typeof c.contentWindow!="undefined")return c.contentWindow;else if(typeof c.contentDocument!="undefined")return c.contentDocument.defaultView;else throw Error("getIframeWindow: No Window object found for iframe element"); },getIframeDocument:function(c){if(typeof c.contentDocument!="undefined")return c.contentDocument;else if(typeof c.contentWindow!="undefined")return c.contentWindow.document;else throw Error("getIframeWindow: No Document object found for iframe element");},getBody:function(c){return A.isHostObject(c,"body")?c.body:c.getElementsByTagName("body")[0]},getRootContainer:function(c){for(var f;f=c.parentNode;)c=f;return c},comparePoints:function(c,f,j,r){var M;if(c==j)return f===r?0:f=d.childNodes.length?d.appendChild(a):d.insertBefore(a,d.childNodes[h]);return o}function O(a){for(var d,h,o=J(a.range).createDocumentFragment();h=a.next();){d=a.isPartiallySelectedSubtree();h=h.cloneNode(!d);if(d){d=a.getSubtreeIterator();h.appendChild(O(d));d.detach(true)}if(h.nodeType==10)throw new Q("HIERARCHY_REQUEST_ERR");o.appendChild(h)}return o}function g(a,d,h){var o,G;for(h=h||{stop:false};o=a.next();)if(a.isPartiallySelectedSubtree())if(d(o)=== false){h.stop=true;return}else{o=a.getSubtreeIterator();g(o,d,h);o.detach(true);if(h.stop)return}else for(o=l.createIterator(o);G=o.next();)if(d(G)===false){h.stop=true;return}}function n(a){for(var d;a.next();)if(a.isPartiallySelectedSubtree()){d=a.getSubtreeIterator();n(d);d.detach(true)}else a.remove()}function t(a){for(var d,h=J(a.range).createDocumentFragment(),o;d=a.next();){if(a.isPartiallySelectedSubtree()){d=d.cloneNode(false);o=a.getSubtreeIterator();d.appendChild(t(o));o.detach(true)}else a.remove(); if(d.nodeType==10)throw new Q("HIERARCHY_REQUEST_ERR");h.appendChild(d)}return h}function x(a,d,h){var o=!!(d&&d.length),G,U=!!h;if(o)G=RegExp("^("+d.join("|")+")$");var m=[];g(new q(a,false),function(s){if((!o||G.test(s.nodeType))&&(!U||h(s)))m.push(s)});return m}function A(a){return"["+(typeof a.getName=="undefined"?"Range":a.getName())+"("+l.inspectNode(a.startContainer)+":"+a.startOffset+", "+l.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function q(a,d){this.range=a;this.clonePartiallySelectedTextNodes= d;if(!a.collapsed){this.sc=a.startContainer;this.so=a.startOffset;this.ec=a.endContainer;this.eo=a.endOffset;var h=a.commonAncestorContainer;if(this.sc===this.ec&&l.isCharacterDataNode(this.sc)){this.isSingleCharacterDataNode=true;this._first=this._last=this._next=this.sc}else{this._first=this._next=this.sc===h&&!l.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:l.getClosestAncestorIn(this.sc,h,true);this._last=this.ec===h&&!l.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:l.getClosestAncestorIn(this.ec, h,true)}}}function v(a){this.code=this[a];this.codeName=a;this.message="RangeException: "+this.codeName}function c(a,d,h){this.nodes=x(a,d,h);this._next=this.nodes[0];this._position=0}function f(a){return function(d,h){for(var o,G=h?d:d.parentNode;G;){o=G.nodeType;if(l.arrayContains(a,o))return G;G=G.parentNode}return null}}function j(a,d){if(E(a,d))throw new v("INVALID_NODE_TYPE_ERR");}function r(a){if(!a.startContainer)throw new Q("INVALID_STATE_ERR");}function M(a,d){if(!l.arrayContains(d,a.nodeType))throw new v("INVALID_NODE_TYPE_ERR"); }function p(a,d){if(d<0||d>(l.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new Q("INDEX_SIZE_ERR");}function u(a,d){if(e(a,true)!==e(d,true))throw new Q("WRONG_DOCUMENT_ERR");}function w(a){if(i(a,true))throw new Q("NO_MODIFICATION_ALLOWED_ERR");}function B(a,d){if(!a)throw new Q(d);}function F(a){r(a);if(!l.arrayContains(Y,a.startContainer.nodeType)&&!e(a.startContainer,true)||!l.arrayContains(Y,a.endContainer.nodeType)&&!e(a.endContainer,true)||!(a.startOffset<=(l.isCharacterDataNode(a.startContainer)? a.startContainer.length:a.startContainer.childNodes.length))||!(a.endOffset<=(l.isCharacterDataNode(a.endContainer)?a.endContainer.length:a.endContainer.childNodes.length)))throw Error("Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")");}function W(){}function da(a){a.START_TO_START=ja;a.START_TO_END=la;a.END_TO_END=ra;a.END_TO_START=ma;a.NODE_BEFORE=na;a.NODE_AFTER=oa;a.NODE_BEFORE_AND_AFTER=pa;a.NODE_INSIDE=ka}function Z(a){da(a);da(a.prototype)}function X(a,d){return function(){F(this); var h=this.startContainer,o=this.startOffset,G=this.commonAncestorContainer,U=new q(this,true);if(h!==G){h=l.getClosestAncestorIn(h,G,true);o=C(h);h=o.node;o=o.offset}g(U,w);U.reset();G=a(U);U.detach();d(this,h,o,h,o);return G}}function aa(a,d,h){function o(m,s){return function(y){r(this);M(y,ea);M(b(y),Y);y=(m?z:C)(y);(s?G:U)(this,y.node,y.offset)}}function G(m,s,y){var H=m.endContainer,R=m.endOffset;if(s!==m.startContainer||y!==m.startOffset){if(b(s)!=b(H)||l.comparePoints(s,y,H,R)==1){H=s;R=y}d(m, s,y,H,R)}}function U(m,s,y){var H=m.startContainer,R=m.startOffset;if(s!==m.endContainer||y!==m.endOffset){if(b(s)!=b(H)||l.comparePoints(s,y,H,R)==-1){H=s;R=y}d(m,H,R,s,y)}}a.prototype=new W;k.util.extend(a.prototype,{setStart:function(m,s){r(this);j(m,true);p(m,s);G(this,m,s)},setEnd:function(m,s){r(this);j(m,true);p(m,s);U(this,m,s)},setStartBefore:o(true,true),setStartAfter:o(false,true),setEndBefore:o(true,false),setEndAfter:o(false,false),collapse:function(m){F(this);m?d(this,this.startContainer, this.startOffset,this.startContainer,this.startOffset):d(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(m){r(this);j(m,true);d(this,m,0,m,l.getNodeLength(m))},selectNode:function(m){r(this);j(m,false);M(m,ea);var s=z(m);m=C(m);d(this,s.node,s.offset,m.node,m.offset)},extractContents:X(t,d),deleteContents:X(n,d),canSurroundContents:function(){F(this);w(this.startContainer);w(this.endContainer);var m=new q(this,true),s=m._first&&L(m._first,this)|| m._last&&L(m._last,this);m.detach();return!s},detach:function(){h(this)},splitBoundaries:function(){F(this);var m=this.startContainer,s=this.startOffset,y=this.endContainer,H=this.endOffset,R=m===y;l.isCharacterDataNode(y)&&H>0&&H0&&s=l.getNodeIndex(m)&&H++;s=0}d(this,m,s,y,H)},normalizeBoundaries:function(){F(this);var m=this.startContainer,s=this.startOffset,y= this.endContainer,H=this.endOffset,R=function(V){var S=V.nextSibling;if(S&&S.nodeType==V.nodeType){y=V;H=V.length;V.appendData(S.data);S.parentNode.removeChild(S)}},qa=function(V){var S=V.previousSibling;if(S&&S.nodeType==V.nodeType){m=V;var sa=V.length;s=S.length;V.insertData(0,S.data);S.parentNode.removeChild(S);if(m==y){H+=s;y=m}else if(y==V.parentNode){S=l.getNodeIndex(V);if(H==S){y=V;H=sa}else H>S&&H--}}},fa=true;if(l.isCharacterDataNode(y))y.length==H&&R(y);else{if(H>0)(fa=y.childNodes[H-1])&& l.isCharacterDataNode(fa)&&R(fa);fa=!this.collapsed}if(fa)if(l.isCharacterDataNode(m))s==0&&qa(m);else{if(sx";P=I.firstChild.nodeType==3}catch(ca){}k.features.htmlParsingConforms=P;var ia=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"], ja=0,la=1,ra=2,ma=3,na=0,oa=1,pa=2,ka=3;W.prototype={attachListener:function(a,d){this._listeners[a].push(d)},compareBoundaryPoints:function(a,d){F(this);u(this.startContainer,d.startContainer);var h=a==ma||a==ja?"start":"end",o=a==la||a==ja?"start":"end";return l.comparePoints(this[h+"Container"],this[h+"Offset"],d[o+"Container"],d[o+"Offset"])},insertNode:function(a){F(this);M(a,ha);w(this.startContainer);if(l.isAncestorOf(a,this.startContainer,true))throw new Q("HIERARCHY_REQUEST_ERR");this.setStartBefore(N(a, this.startContainer,this.startOffset))},cloneContents:function(){F(this);var a,d;if(this.collapsed)return J(this).createDocumentFragment();else{if(this.startContainer===this.endContainer&&l.isCharacterDataNode(this.startContainer)){a=this.startContainer.cloneNode(true);a.data=a.data.slice(this.startOffset,this.endOffset);d=J(this).createDocumentFragment();d.appendChild(a);return d}else{d=new q(this,true);a=O(d);d.detach()}return a}},canSurroundContents:function(){F(this);w(this.startContainer);w(this.endContainer); var a=new q(this,true),d=a._first&&L(a._first,this)||a._last&&L(a._last,this);a.detach();return!d},surroundContents:function(a){M(a,$);if(!this.canSurroundContents())throw new v("BAD_BOUNDARYPOINTS_ERR");var d=this.extractContents();if(a.hasChildNodes())for(;a.lastChild;)a.removeChild(a.lastChild);N(a,this.startContainer,this.startOffset);a.appendChild(d);this.selectNode(a)},cloneRange:function(){F(this);for(var a=new T(J(this)),d=ia.length,h;d--;){h=ia[d];a[h]=this[h]}return a},toString:function(){F(this); var a=this.startContainer;if(a===this.endContainer&&l.isCharacterDataNode(a))return a.nodeType==3||a.nodeType==4?a.data.slice(this.startOffset,this.endOffset):"";else{var d=[];a=new q(this,true);g(a,function(h){if(h.nodeType==3||h.nodeType==4)d.push(h.data)});a.detach();return d.join("")}},compareNode:function(a){F(this);var d=a.parentNode,h=l.getNodeIndex(a);if(!d)throw new Q("NOT_FOUND_ERR");a=this.comparePoint(d,h);d=this.comparePoint(d,h+1);return a<0?d>0?pa:na:d>0?oa:ka},comparePoint:function(a, d){F(this);B(a,"HIERARCHY_REQUEST_ERR");u(a,this.startContainer);if(l.comparePoints(a,d,this.startContainer,this.startOffset)<0)return-1;else if(l.comparePoints(a,d,this.endContainer,this.endOffset)>0)return 1;return 0},createContextualFragment:P?function(a){var d=this.startContainer,h=l.getDocument(d);if(!d)throw new Q("INVALID_STATE_ERR");var o=null;if(d.nodeType==1)o=d;else if(l.isCharacterDataNode(d))o=l.parentElement(d);o=o===null||o.nodeName=="HTML"&&l.isHtmlNamespace(l.getDocument(o).documentElement)&& l.isHtmlNamespace(o)?h.createElement("body"):o.cloneNode(false);o.innerHTML=a;return l.fragmentFromNodeChildren(o)}:function(a){r(this);var d=J(this).createElement("body");d.innerHTML=a;return l.fragmentFromNodeChildren(d)},toHtml:function(){F(this);var a=J(this).createElement("div");a.appendChild(this.cloneContents());return a.innerHTML},intersectsNode:function(a,d){F(this);B(a,"NOT_FOUND_ERR");if(l.getDocument(a)!==J(this))return false;var h=a.parentNode,o=l.getNodeIndex(a);B(h,"NOT_FOUND_ERR"); var G=l.comparePoints(h,o,this.endContainer,this.endOffset);h=l.comparePoints(h,o+1,this.startContainer,this.startOffset);return d?G<=0&&h>=0:G<0&&h>0},isPointInRange:function(a,d){F(this);B(a,"HIERARCHY_REQUEST_ERR");u(a,this.startContainer);return l.comparePoints(a,d,this.startContainer,this.startOffset)>=0&&l.comparePoints(a,d,this.endContainer,this.endOffset)<=0},intersectsRange:function(a,d){F(this);if(J(a)!=J(this))throw new Q("WRONG_DOCUMENT_ERR");var h=l.comparePoints(this.startContainer, this.startOffset,a.endContainer,a.endOffset),o=l.comparePoints(this.endContainer,this.endOffset,a.startContainer,a.startOffset);return d?h<=0&&o>=0:h<0&&o>0},intersection:function(a){if(this.intersectsRange(a)){var d=l.comparePoints(this.startContainer,this.startOffset,a.startContainer,a.startOffset),h=l.comparePoints(this.endContainer,this.endOffset,a.endContainer,a.endOffset),o=this.cloneRange();d==-1&&o.setStart(a.startContainer,a.startOffset);h==1&&o.setEnd(a.endContainer,a.endOffset);return o}return null}, union:function(a){if(this.intersectsRange(a,true)){var d=this.cloneRange();l.comparePoints(a.startContainer,a.startOffset,this.startContainer,this.startOffset)==-1&&d.setStart(a.startContainer,a.startOffset);l.comparePoints(a.endContainer,a.endOffset,this.endContainer,this.endOffset)==1&&d.setEnd(a.endContainer,a.endOffset);return d}else throw new v("Ranges do not intersect");},containsNode:function(a,d){return d?this.intersectsNode(a,false):this.compareNode(a)==ka},containsNodeContents:function(a){return this.comparePoint(a, 0)>=0&&this.comparePoint(a,l.getNodeLength(a))<=0},containsRange:function(a){return this.intersection(a).equals(a)},containsNodeText:function(a){var d=this.cloneRange();d.selectNode(a);var h=d.getNodes([3]);if(h.length>0){d.setStart(h[0],0);a=h.pop();d.setEnd(a,a.length);a=this.containsRange(d);d.detach();return a}else return this.containsNodeContents(a)},createNodeIterator:function(a,d){F(this);return new c(this,a,d)},getNodes:function(a,d){F(this);return x(this,a,d)},getDocument:function(){return J(this)}, collapseBefore:function(a){r(this);this.setEndBefore(a);this.collapse(false)},collapseAfter:function(a){r(this);this.setStartAfter(a);this.collapse(true)},getName:function(){return"DomRange"},equals:function(a){return T.rangesEqual(this,a)},inspect:function(){return A(this)}};aa(T,ba,function(a){r(a);a.startContainer=a.startOffset=a.endContainer=a.endOffset=null;a.collapsed=a.commonAncestorContainer=null;K(a,"detach",null);a._listeners=null});k.rangePrototype=W.prototype;T.rangeProperties=ia;T.RangeIterator= q;T.copyComparisonConstants=Z;T.createPrototypeRange=aa;T.inspect=A;T.getRangeDocument=J;T.rangesEqual=function(a,d){return a.startContainer===d.startContainer&&a.startOffset===d.startOffset&&a.endContainer===d.endContainer&&a.endOffset===d.endOffset};k.DomRange=T;k.RangeException=v}); rangy.createModule("WrappedRange",function(k){function L(g,n,t,x){var A=g.duplicate();A.collapse(t);var q=A.parentElement();z.isAncestorOf(n,q,true)||(q=n);if(!q.canHaveHTML)return new C(q.parentNode,z.getNodeIndex(q));n=z.getDocument(q).createElement("span");var v,c=t?"StartToStart":"StartToEnd";do{q.insertBefore(n,n.previousSibling);A.moveToElementText(n)}while((v=A.compareEndPoints(c,g))>0&&n.previousSibling);c=n.nextSibling;if(v==-1&&c&&z.isCharacterDataNode(c)){A.setEndPoint(t?"EndToStart":"EndToEnd", g);if(/[\r\n]/.test(c.data)){q=A.duplicate();t=q.text.replace(/\r\n/g,"\r").length;for(t=q.moveStart("character",t);q.compareEndPoints("StartToEnd",q)==-1;){t++;q.moveStart("character",1)}}else t=A.text.length;q=new C(c,t)}else{c=(x||!t)&&n.previousSibling;q=(t=(x||t)&&n.nextSibling)&&z.isCharacterDataNode(t)?new C(t,0):c&&z.isCharacterDataNode(c)?new C(c,c.length):new C(q,z.getNodeIndex(n))}n.parentNode.removeChild(n);return q}function J(g,n){var t,x,A=g.offset,q=z.getDocument(g.node),v=q.body.createTextRange(), c=z.isCharacterDataNode(g.node);if(c){t=g.node;x=t.parentNode}else{t=g.node.childNodes;t=A12");e.close();var i=c.getIframeWindow(b).getSelection(),E=e.documentElement.lastChild.firstChild;e=e.createRange();e.setStart(E,1);e.collapse(true);i.addRange(e);T=i.rangeCount==1;i.removeAllRanges();var I=e.cloneRange();e.setStart(E,0);I.setEnd(E,2);i.addRange(e);i.addRange(I);ba=i.rangeCount==2;e.detach();I.detach();Z.removeChild(b)}();k.features.selectionSupportsMultipleRanges=ba;k.features.collapsedNonEditableSelectionsSupported=T;var l=false,D; if(Z&&f.isHostMethod(Z,"createControlRange")){D=Z.createControlRange();if(f.areHostProperties(D,["item","add"]))l=true}k.features.implementsControlRange=l;w=X?function(b){return b.anchorNode===b.focusNode&&b.anchorOffset===b.focusOffset}:function(b){return b.rangeCount?b.getRangeAt(b.rangeCount-1).collapsed:false};var Q;if(f.isHostMethod(B,"getRangeAt"))Q=function(b,e){try{return b.getRangeAt(e)}catch(i){return null}};else if(X)Q=function(b){var e=c.getDocument(b.anchorNode);e=k.createRange(e);e.setStart(b.anchorNode, b.anchorOffset);e.setEnd(b.focusNode,b.focusOffset);if(e.collapsed!==this.isCollapsed){e.setStart(b.focusNode,b.focusOffset);e.setEnd(b.anchorNode,b.anchorOffset)}return e};k.getSelection=function(b){b=b||window;var e=b._rangySelection,i=u(b),E=F?K(b):null;if(e){e.nativeSelection=i;e.docSelection=E;e.refresh(b)}else{e=new x(i,E,b);b._rangySelection=e}return e};k.getIframeSelection=function(b){return k.getSelection(c.getIframeWindow(b))};D=x.prototype;if(!W&&X&&f.areHostMethods(B,["removeAllRanges", "addRange"])){D.removeAllRanges=function(){this.nativeSelection.removeAllRanges();C(this)};var ea=function(b,e){var i=j.getRangeDocument(e);i=k.createRange(i);i.collapseToPoint(e.endContainer,e.endOffset);b.nativeSelection.addRange(N(i));b.nativeSelection.extend(e.startContainer,e.startOffset);b.refresh()};D.addRange=ga?function(b,e){if(l&&F&&this.docSelection.type=="Control")t(this,b);else if(e&&aa)ea(this,b);else{var i;if(ba)i=this.rangeCount;else{this.removeAllRanges();i=0}this.nativeSelection.addRange(N(b)); this.rangeCount=this.nativeSelection.rangeCount;if(this.rangeCount==i+1){if(k.config.checkSelectionRanges)if((i=Q(this.nativeSelection,this.rangeCount-1))&&!j.rangesEqual(i,b))b=new r(i);this._ranges[this.rangeCount-1]=b;z(this,b,$(this.nativeSelection));this.isCollapsed=w(this)}else this.refresh()}}:function(b,e){if(e&&aa)ea(this,b);else{this.nativeSelection.addRange(N(b));this.refresh()}};D.setRanges=function(b){if(l&&b.length>1)A(this,b);else{this.removeAllRanges();for(var e=0,i=b.length;e1)A(this,b);else e&&this.addRange(b[0])}}else{L.fail("No means of selecting a Range or TextRange was found");return false}D.getRangeAt=function(b){if(b<0||b>=this.rangeCount)throw new M("INDEX_SIZE_ERR");else return this._ranges[b]};var Y;if(W)Y=function(b){var e;if(k.isSelectionValid(b.win))e=b.docSelection.createRange();else{e=c.getBody(b.win.document).createTextRange(); e.collapse(true)}if(b.docSelection.type=="Control")n(b);else e&&typeof e.text!="undefined"?g(b,e):C(b)};else if(f.isHostMethod(B,"getRangeAt")&&typeof B.rangeCount=="number")Y=function(b){if(l&&F&&b.docSelection.type=="Control")n(b);else{b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount;if(b.rangeCount){for(var e=0,i=b.rangeCount;e