// ============================================================================
// Response to events
// ============================================================================
function fixedScroller(){var a=$(window).scrollTop();$fixable.length&&(a>=notes_top?$fixable.addClass("fixed"):$fixable.removeClass("fixed"))}function loadCommentary(a,b){if(b.commentary==null)return!1;var b=b.commentary.commentary,c=start_book+" "+start_chapter+":"+start_verse,d="Matthew Henry",e=d,f="<h2>Commentary: "+b.source+"</h2>";f+='<p id="commentary-info-links">',f+='<a href="#" id="book-summary" data-book="'+b.book+'">Book Summary</a>',f+='<a href="#" id="chapter-summary" data-book="'+b.book+'" data-chapter="'+b.chapter+'">Chapter Summary</a>',f+="</p>",f+="<p>"+b.text+"</p>";var g=!0;loadPanelContent(d,f,g,e)}function loadStrongs(a,b){var c=b.dictionary,d=start_book+" "+start_chapter+":"+start_verse,e=b.text,f="Strong's",g=f,a=decodeURIComponent(text_selection),h="<h2>Strong's</h2>";h+='<p id="strongs-list">'+e+"</p>",h+='<table id="dictionary-list">',$.each(c,function(a,b){h+="<tr>",h+='<td id="'+b.code+'">',h+="<p>",h+='<strong><a href="#" data-strong-code="'+b.code+'" class="get-concordance" data-book="'+start_book+'" data-chapter="'+start_chapter+'" data-verse="'+start_verse+'">'+b.kjvs_word+"</a></strong><br />",h+="<em>"+b.word+" ("+b.pronunciation+") - </em>",h+=b.meaning,h+="</p>",h+="</td>",h+="</tr>"}),h+="</table>";var i=!0;loadPanelContent(f,h,i,g),$("div#panel-content").scrollTo(0,0),$definition=$("div#panel-content tr td strong:contains('"+a.trim()+"')"),$definition.length&&$("div#panel-content").scrollTo($definition,200)}function showDefinition(a){a=a.entry.dictionary;var b="Definition: "+a.word,c=b,d=!0,e="<h2>Definition: "+a.word+" ("+a.pronunciation+") </h2>";e+="<p>"+a.meaning+"</p>",loadPanelContent(b,e,d,c)}function openEditJournal(a,b){openLightbox(b),$("div#lightbox-content").load("/journals/"+a+"/edit/",function(){$("div#tiptip_holder").hide()})}function loadMoreJournals(){if($ajax_indicator.css("display")=="block")return!1;$journals=$("div#journals > div.page-right"),$journals.append($ajax_indicator);var a=$("input#category").val(),b="/journals?scrolling=true&offset="+journal_offset;a!=undefined&&(b+="&category="+a),$.ajax({type:"GET",url:b,success:function(a){journal_offset+=10,$ajax_indicator.remove(),$("article.scroll-trigger").removeClass("scroll-trigger"),$journals.append(a),$ajax_indicator.remove()}})}function openLightbox(a){closeLightbox();var b='<div id="overlay"></div>';b+='<div id="lightbox-container">',b+='<a href="#" class="close-lightbox">X</a>',b+='<div id="lightbox-content">',b+='<p id="ajax-loader-container"><img src="/images/ajax-loader.gif" alt="Loading..." /></p>',b+="</div>",b+="</div>",$body.append(b),$("div#overlay").show(),top.location!=self.location&&a&&$("#lightbox-container").css("margin-top","0").css("top",a.pageY)}function closeLightbox(){$("div#overlay").remove(),$("div#lightbox-container").remove()}function loadingPanel(){localStorage.setItem("panel_open",!0);var a=localStorage.getItem("panel_left"),b=localStorage.getItem("panel_top"),c=localStorage.getItem("panel_container_width"),d=localStorage.getItem("panel_container_height"),e=localStorage.getItem("panel_content_height");a!=null&&b!=null&&$("#panel-container").css({left:a+"px",top:b+"px"}),d!=null&&c!=null&&$("#panel-container").css({width:c+"px",height:d+"px"}),e!=null&&$("#panel-content").css({height:e+"px"}),$("#panel-container").show();var f='<p id="panel-loader"><img src="/images/ajax-loader.gif" alt="Ajax Load" /></p>';$("#panel-loader").remove(),$("#panel-content").children().hide(),$("#panel-content").prepend(f)}function loadPanelContent(a,b,c,d){var e=localStorage.getItem("panel_tabs"),f=localStorage.getItem("panel_active");e!=null&&($("ul#panel-tabs-nav").html(e).show(),$("ul#panel-tabs-nav li.active-panel-tab").removeClass("active-panel-tab"),$("ul#panel-tabs-nav li#"+f).addClass("active-panel-tab"));var g=localStorage.getItem("open_tabs");g!=null&&c==1?(g=parseInt(g),g+=1):g==null&&(g=1);var h=localStorage.getItem("tab_counter");h!=null&&c==1?(h=parseInt(h),h+=1):h==null&&(h=1);var i="div#tab-"+h,j='<a href="#" class="close-panel">X</a>';if(c==1&&$("ul#panel-tabs-nav").css("display")=="none"){$("#panel-content").append('<div id="tab-'+h+'" class="panel-tab"></div>'),$(i).html(b),$("div.panel-tab").hide(),$(i).show();if(g>1){checkPanelHeight(),$("ul#panel-tabs-nav li.active-panel-tab").removeClass("active-panel-tab"),localStorage.setItem("panel_active",h);var k='<li id="1" class="open-panel-tab"><a href="#" class="tab-nav-title">'+$("#panel-header h1").text()+"</a>"+j+"</li>";$("ul#panel-tabs-nav").append(k);var l='<li id="'+h+'" class="open-panel-tab active-panel-tab"><a href="#" class="tab-nav-title">'+d+"</a>"+j+"</li>";$("ul#panel-tabs-nav").append(l),$("ul#panel-tabs-nav").show()}}else if(c==1)$("div.panel-tab").hide(),$("#panel-content").append('<div id="tab-'+h+'" class="panel-tab"></div>'),$(i).html(b),$("ul#panel-tabs-nav li.active-panel-tab").removeClass("active-panel-tab"),l='<li id="'+h+'" class="open-panel-tab active-panel-tab"><a href="#" class="tab-nav-title">'+d+"</a>"+j+"</li>",$("ul#panel-tabs-nav").append(l),$("ul#panel-tabs-nav").show(),localStorage.setItem("panel_active",h);else if(c==0){if(f!=null)var m="div#tab-"+f;else f=1,m="div#tab-1",$("#panel-content").append('<div id="tab-1" class="panel-tab"></div>');$("ul#panel-tabs-nav").css("display")=="block"&&$("ul#panel-tabs-nav li#"+f+" a.tab-nav-title").text(d),$(m).html(b),$(m).show(),localStorage.setItem("panel_active",f)}else $("#panel-content").html(b);$("#panel-header h1").html(a),$("#panel-loader").remove();var n=$("div#panel-content").html();localStorage.setItem("panel_title",a),localStorage.setItem("panel_content",n),localStorage.setItem("open_tabs",g),localStorage.setItem("tab_counter",h),$("ul#panel-tabs-nav").css("display")=="block"&&(e=$("ul#panel-tabs-nav").html(),localStorage.setItem("panel_tabs",e)),checkPanelTabsWidth(g)}function closePanel(){var a=$("div#panel-content").height();$("ul#panel-tabs-nav").css("display")=="block"&&(a+=27),$("#panel-container").hide(),$("div#panel-content").html(""),$("ul#panel-tabs-nav").html(""),$("ul#panel-tabs-nav").hide(),localStorage.setItem("panel_content_height",a),localStorage.setItem("panel_open",!1),localStorage.removeItem("panel_content"),localStorage.removeItem("open_tabs"),localStorage.removeItem("tab_counter"),localStorage.removeItem("panel_tabs"),localStorage.removeItem("panel_active")}function resetPanel(){$("ul#panel-tabs-nav").html(""),$("div#panel-content").html(""),localStorage.removeItem("panel_content"),localStorage.removeItem("open_tabs"),localStorage.removeItem("tab_counter"),localStorage.removeItem("panel_tabs"),localStorage.removeItem("panel_active")}function checkPanelHeight(){var a=$("div#panel-content").height();a-=27,$("div#panel-content").css("height",a+"px"),localStorage.setItem("panel_content_height",a)}function checkPanelTabsWidth(a){var b=100/a-8;$("ul#panel-tabs-nav li").css("width",b+"%")}function loadMorePlanItems(){if($ajax_indicator.css("display")=="block")return!1;$plans_container=$("div#plans-index > div.page-right"),$plans_container.append($ajax_indicator);var a=$("div#plans-index").data().planId,b="/plans/preview/"+a+"?scrolling=1&offset="+item_offset;$.ajax({type:"GET",url:b,success:function(a){item_offset+=10,$ajax_indicator.remove(),$("article.scroll-trigger").removeClass("scroll-trigger"),$plans_container.append(a),$ajax_indicator.remove()}})}function openShareDialog(a,b){$this=a,$.ajax({url:b,success:function(a){top.location!=self.location?($this.tipTip({content:a,activation:"open",keepAlive:!0}),$("#fb-vertical").css("top","13px")):($this.tipTip({content:a,activation:"open",keepAlive:!0,defaultPosition:"left"}),$("#tiptip_holder").addClass("hide-tiptip-on-scroll"),$("#tiptip_content").css("top","85px").css("position","relative"));try{FB.XFBML.parse()}catch(b){}}})}function getFirstRange(){var a=rangy.getSelection();return a.rangeCount?a.getRangeAt(0):null}function insertNodeAtRange(){range=getFirstRange(),range&&(savedSel&&rangy.removeMarkers(savedSel),savedSel=rangy.saveSelection(),savedSelActiveElement=document.activeElement,$range_start=$("span.selectionBoundary").first(),start_verse_id=$range_start.parents("span.verse").prevAll("sup").first().attr("id"),$range_end=$("span.selectionBoundary").last(),end_verse_id=$range_end.parents("span.verse").prevAll("sup").first().attr("id"),$range_start.parent().get(0).tagName=="P"?start_verse_id=$range_start.prevAll("sup").first().attr("id"):$range_start.parent().get(0).tagName=="SUP"?start_verse_id=$range_start.parent().attr("id"):start_verse_id=$range_start.parents("span.verse").prevAll("sup").first().attr("id"),$range_end.parent().get(0).tagName=="H2"&&($start_paragraph=$("sup#"+start_verse_id).parent(),end_verse_id=$("sup",$start_paragraph).last().attr("id")),end_verse_id==null&&$range_end.parent().get(0).tagName=="P"&&($start_paragraph=$("sup#"+start_verse_id).parent(),end_verse_id=$("sup",$start_paragraph).last().attr("id")),end_verse_id==null&&(end_verse_id=start_verse_id))}function uniq(a){return a.filter(function(a,b,c){return c.indexOf(a)==b})}function accountRequired(a){var b=window.location.pathname;if(USER_ID=="")return openLightbox(a),$("div#lightbox-content").load("/account_required?success="+b),!1}window.addEventListener?window.addEventListener("message",function(a){var b=$("body").height();a.source.postMessage(b,a.origin)},!1):window.attachEvent&&window.attachEvent("message",function(a){var b=$("body").height();a.source.postMessage(b,a.origin)}),jQuery.cookie=function(a,b,c){if(arguments.length>1&&String(b)!=="[object Object]"){c=jQuery.extend({},c);if(b===null||b===undefined)c.expires=-1;if(typeof c.expires=="number"){var d=c.expires,e=c.expires=new Date;e.setDate(e.getDate()+d)}return b=String(b),document.cookie=[encodeURIComponent(a),"=",c.raw?b:encodeURIComponent(b),c.expires?"; expires="+c.expires.toUTCString():"",c.path?"; path="+c.path:"",c.domain?"; domain="+c.domain:"",c.secure?"; secure":""].join("")}c=b||{};var f,g=c.raw?function(a){return a}:decodeURIComponent;return(f=(new RegExp("(?:^|; )"+encodeURIComponent(a)+"=([^;]*)")).exec(document.cookie))?g(f[1]):null},function(a){a.fn.jqDrag=function(a){return e(this,a,"d")},a.fn.jqResize=function(a){return e(this,a,"r")},a.jqDnR={dnr:{},e:0,drag:function(b){return c.k=="d"?(d.css({left:c.X+b.pageX-c.pX,top:c.Y+b.pageY-c.pY}),localStorage.setItem("panel_left",c.X+b.pageX-c.pX),localStorage.setItem("panel_top",c.Y+b.pageY-c.pY)):(d.css({width:Math.max(b.pageX-c.pX+c.W,0),height:Math.max(b.pageY-c.pY+c.H,0)}),a("ul#panel-tabs-nav").css("display")=="block"?(a("#panel-content").css({height:Math.max(b.pageY-c.pY+c.H-58,0)}),localStorage.setItem("panel_content_height",Math.max(b.pageY-c.pY+c.H-58,0))):(a("#panel-content").css({height:Math.max(b.pageY-c.pY+c.H-30,0)}),localStorage.setItem("panel_content_height",Math.max(b.pageY-c.pY+c.H-30,0))),localStorage.setItem("panel_container_width",Math.max(b.pageX-c.pX+c.W,0)),localStorage.setItem("panel_container_height",Math.max(b.pageY-c.pY+c.H,0))),!1},stop:function(){d.css("opacity",c.o),a(document).unbind("mousemove",b.drag).unbind("mouseup",b.stop)}};var b=a.jqDnR,c=b.dnr,d=b.e,e=function(b,e,g){return b.each(function(){e=e?a(e,b):b,e.bind("mousedown",{e:b,k:g},function(b){var e=b.data,g={};d=e.e;if(d.css("position")!="relative")try{d.position(g)}catch(h){}return c={X:g.left||f("left")||0,Y:g.top||f("top")||0,W:f("width")||d[0].scrollWidth||0,H:f("height")||d[0].scrollHeight||0,pX:b.pageX,pY:b.pageY,k:e.k,o:d.css("opacity")},d.css({opacity:.8}),a(document).mousemove(a.jqDnR.drag).mouseup(a.jqDnR.stop),!1})})},f=function(a){return parseInt(d.css(a))||!1}}(jQuery),function(a){function c(a){return typeof a=="object"?a:{top:a,left:a}}var b=a.scrollTo=function(b,c,e){a(window).scrollTo(b,c,e)};b.defaults={axis:"xy",duration:parseFloat(a.fn.jquery)>=1.3?0:1},b.window=function(b){return a(window)._scrollable()},a.fn._scrollable=function(){return this.map(function(){var b=this,c=!b.nodeName||a.inArray(b.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!c)return b;var e=(b.contentWindow||b).document||b.ownerDocument||b;return a.browser.safari||e.compatMode=="BackCompat"?e.body:e.documentElement})},a.fn.scrollTo=function(e,f,g){return typeof f=="object"&&(g=f,f=0),typeof g=="function"&&(g={onAfter:g}),e=="max"&&(e=9e9),g=a.extend({},b.defaults,g),f=f||g.speed||g.duration,g.queue=g.queue&&g.axis.length>1,g.queue&&(f/=2),g.offset=c(g.offset),g.over=c(g.over),this._scrollable().each(function(){function r(a){i.animate(o,f,g.easing,a&&function(){a.call(this,e,g)})}var h=this,i=a(h),l=e,m,o={},q=i.is("html,body");switch(typeof l){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(l)){l=c(l);break}l=a(l,this);case"object":if(l.is||l.style)m=(l=a(l)).offset()}a.each(g.axis.split(""),function(a,c){var d=c=="x"?"Left":"Top",e=d.toLowerCase(),f="scroll"+d,j=h[f],n=b.max(h,c);if(m)o[f]=m[e]+(q?0:j-i.offset()[e]),g.margin&&(o[f]-=parseInt(l.css("margin"+d))||0,o[f]-=parseInt(l.css("border"+d+"Width"))||0),o[f]+=g.offset[e]||0,g.over[e]&&(o[f]+=l[c=="x"?"width":"height"]()*g.over[e]);else{var p=l[e];o[f]=p.slice&&p.slice(-1)=="%"?parseFloat(p)/100*n:p}/^\d+$/.test(o[f])&&(o[f]=o[f]<=0?0:Math.min(o[f],n)),!a&&g.queue&&(j!=o[f]&&r(g.onAfterFirst),delete o[f])}),r(g.onAfter)}).end()},b.max=function(b,c){var e=c=="x"?"Width":"Height",f="scroll"+e;if(!a(b).is("html,body"))return b[f]-a(b)[e.toLowerCase()]();var g="client"+e,h=b.ownerDocument.documentElement,i=b.ownerDocument.body;return Math.max(h[f],i[f])-Math.min(h[g],i[g])}}(jQuery),function(a){a.belowthefold=function(b,c){var d=a(window).height()+a(window).scrollTop();return d<=a(b).offset().top-c.threshold},a.abovethetop=function(b,c){var d=a(window).scrollTop();return d>=a(b).offset().top+a(b).height()-c.threshold},a.rightofscreen=function(b,c){var d=a(window).width()+a(window).scrollLeft();return d<=a(b).offset().left-c.threshold},a.leftofscreen=function(b,c){var d=a(window).scrollLeft();return d>=a(b).offset().left+a(b).width()-c.threshold},a.inviewport=function(b,c){return!a.rightofscreen(b,c)&&!a.leftofscreen(b,c)&&!a.belowthefold(b,c)&&!a.abovethetop(b,c)},a.extend(a.expr[":"],{"below-the-fold":function(b,c,d){return a.belowthefold(b,{threshold:0})},"above-the-top":function(b,c,d){return a.abovethetop(b,{threshold:0})},"left-of-screen":function(b,c,d){return a.leftofscreen(b,{threshold:0})},"right-of-screen":function(b,c,d){return a.rightofscreen(b,{threshold:0})},"in-viewport":function(b,c,d){return a.inviewport(b,{threshold:0})}})}(jQuery),window.rangy=function(){function h(c,d){var e=typeof c[d];return e==b||e==a&&!!c[d]||e=="unknown"}function i(b,c){return typeof b[c]==a&&!!b[c]}function j(a,b){return typeof a[b]!=c}function k(a){return function(b,c){var d=c.length;while(d--)if(!a(b,c[d]))return!1;return!0}}function o(a){return a&&l(a,g)&&n(a,f)}function q(a){window.alert("Rangy not supported in your browser. Reason: "+a),p.initialized=!0,p.supported=!1}function r(a){var b="Rangy warning: "+a;p.config.alertOnWarn?window.alert(b):typeof window.console!=c&&typeof window.console.log!=c&&window.console.log(b)}function u(){if(p.initialized)return;var a,b=!1,c=!1;h(document,"createRange")&&(a=document.createRange(),l(a,e)&&n(a,d)&&(b=!0),a.detach());var f=i(document,"body")?document.body:document.getElementsByTagName("body")[0];f&&h(f,"createTextRange")&&(a=f.createTextRange(),o(a)&&(c=!0)),!b&&!c&&q("Neither Range nor TextRange are implemented"),p.initialized=!0,p.features={implementsDomRange:b,implementsTextRange:c};var g=t.concat(s);for(var j=0,k=g.length;j<k;++j)try{g[j](p)}catch(m){i(window,"console")&&h(window.console,"log")&&window.console.log("Init listener threw an exception. Continuing.",m)}}function w(a){a=a||window,u();for(var b=0,c=v.length;b<c;++b)v[b](a)}function x(a){this.name=a,this.initialized=!1,this.supported=!1}var a="object",b="function",c="undefined",d=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer","START_TO_START","START_TO_END","END_TO_START","END_TO_END"],e=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],f=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],g=["collapse","compareEndPoints","duplicate","getBookmark","moveToBookmark","moveToElementText","parentElement","pasteHTML","select","setEndPoint"],l=k(h),m=k(i),n=k(j),p={version:"1.2beta2",initialized:!1,supported:!0,util:{isHostMethod:h,isHostObject:i,isHostProperty:j,areHostMethods:l,areHostObjects:m,areHostProperties:n,isTextRange:o},features:{},modules:{},config:{alertOnWarn:!1,preferTextRange:!1}};p.fail=q,p.warn=r,{}.hasOwnProperty?p.util.extend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])}:q("hasOwnProperty not supported");var s=[],t=[];p.init=u,p.addInitListener=function(a){p.initialized?a(p):s.push(a)};var v=[];p.addCreateMissingNativeApiListener=function(a){v.push(a)},p.createMissingNativeApi=w,x.prototype.fail=function(a){throw this.initialized=!0,this.supported=!1,new Error("Module '"+this.name+"' failed to load: "+a)},x.prototype.warn=function(a){p.warn("Module "+this.name+": "+a)},x.prototype.createError=function(a){return new Error("Error in Rangy "+this.name+" module: "+a)},p.createModule=function(a,b){var c=new x(a);p.modules[a]=c,t.push(function(a){b(a,c),c.initialized=!0,c.supported=!0})},p.requireModules=function(a){for(var b=0,c=a.length,d,e;b<c;++b){e=a[b],d=p.modules[e];if(!d||!(d instanceof x))throw new Error("Module '"+e+"' not found");if(!d.supported)throw new Error("Module '"+e+"' not supported")}};var y=!1,z=function(a){y||(y=!0,p.initialized||u())};if(typeof window==c){q("No window found");return}if(typeof document==c){q("No document found");return}return h(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",z,!1),h(window,"addEventListener")?window.addEventListener("load",z,!1):h(window,"attachEvent")?window.attachEvent("onload",z):q("Window does not have required addEventListener or attachEvent method"),p}(),rangy.createModule("DomUtil",function(a,b){function h(a){var b=0;while(a=a.previousSibling)b++;return b}function i(a){var b;return m(a)?a.length:(b=a.childNodes)?b.length:0}function j(a,b){var c=[],d;for(d=a;d;d=d.parentNode)c.push(d);for(d=b;d;d=d.parentNode)if(g(c,d))return d;return null}function k(a,b,c){var d=c?b:b.parentNode;while(d){if(d===a)return!0;d=d.parentNode}return!1}function l(a,b,c){var d,e=c?a:a.parentNode;while(e){d=e.parentNode;if(d===b)return e;e=d}return null}function m(a){var b=a.nodeType;return b==3||b==4||b==8}function n(a,b){var c=b.nextSibling,d=b.parentNode;return c?d.insertBefore(a,c):d.appendChild(a),a}function o(a,b){var c=a.cloneNode(!1);return c.deleteData(0,b),a.deleteData(b,a.length-b),n(c,a),c}function p(a){if(a.nodeType==9)return a;if(typeof a.ownerDocument!=c)return a.ownerDocument;if(typeof a.document!=c)return a.document;if(a.parentNode)return p(a.parentNode);throw new Error("getDocument: no document found for node")}function q(a){var b=p(a);if(typeof b.defaultView!=c)return b.defaultView;if(typeof b.parentWindow!=c)return b.parentWindow;throw new Error("Cannot get a window object for node")}function r(a){if(typeof a.contentDocument!=c)return a.contentDocument;if(typeof a.contentWindow!=c)return a.contentWindow.document;throw new Error("getIframeWindow: No Document object found for iframe element")}function s(a){if(typeof a.contentWindow!=c)return a.contentWindow;if(typeof a.contentDocument!=c)return a.contentDocument.defaultView;throw new Error("getIframeWindow: No Window object found for iframe element")}function t(a){return d.isHostObject(a,"body")?a.body:a.getElementsByTagName("body")[0]}function u(a){var b;while(b=a.parentNode)a=b;return a}function v(a,b,c,d){var e,f,g,i,k;if(a==c)return b===d?0:b<d?-1:1;if(e=l(c,a,!0))return b<=h(e)?-1:1;if(e=l(a,c,!0))return h(e)<d?-1:1;f=j(a,c),g=a===f?f:l(a,f,!0),i=c===f?f:l(c,f,!0);if(g===i)throw new Error("comparePoints got to case 4 and childA and childB are the same!");k=f.firstChild;while(k){if(k===g)return-1;if(k===i)return 1;k=k.nextSibling}throw new Error("Should not be here!")}function w(a){if(!a)return"[No node]";if(m(a))return'"'+a.data+'"';if(a.nodeType==1){var b=a.id?' id="'+a.id+'"':"";return"<"+a.nodeName+b+">["+a.childNodes.length+"]"}return a.nodeName}function x(a){this.root=a,this._next=a}function y(a){return new x(a)}function z(a,b){this.node=a,this.offset=b}function A(a){this.code=this[a],this.codeName=a,this.message="DOMException: "+this.codeName}var c="undefined",d=a.util;d.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||b.fail("document missing a Node creation method"),d.isHostMethod(document,"getElementsByTagName")||b.fail("document missing getElementsByTagName method");var e=document.createElement("div");d.areHostMethods(e,["insertBefore","appendChild","cloneNode"]||!d.areHostObjects(e,["previousSibling","nextSibling","childNodes","parentNode"]))||b.fail("Incomplete Element implementation");var f=document.createTextNode("test");d.areHostMethods(f,["splitText","deleteData","insertData","appendData","cloneNode"]||!d.areHostObjects(e,["previousSibling","nextSibling","childNodes","parentNode"])||!d.areHostProperties(f,["data"]))||b.fail("Incomplete Text Node implementation");var g=function(a,b){var c=a.length;while(c--)if(a[c]===b)return!0;return!1};x.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next,b,c;if(this._current){b=a.firstChild;if(b)this._next=b;else{c=null;while(a!==this.root&&!(c=a.nextSibling))a=a.parentNode;this._next=c}}return this._current},detach:function(){this._current=this._next=this.root=null}},z.prototype={equals:function(a){return this.node===a.node&this.offset==a.offset},inspect:function(){return"[DomPosition("+w(this.node)+":"+this.offset+")]"}},A.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},A.prototype.toString=function(){return this.message},a.dom={arrayContains:g,getNodeIndex:h,getNodeLength:i,getCommonAncestor:j,isAncestorOf:k,getClosestAncestorIn:l,isCharacterDataNode:m,insertAfter:n,splitDataNode:o,getDocument:p,getWindow:q,getIframeWindow:s,getIframeDocument:r,getBody:t,getRootContainer:u,comparePoints:v,inspectNode:w,createIterator:y,DomPosition:z},a.DOMException=A}),rangy.createModule("DomRange",function(a,b){function f(a,b){return a.nodeType!=3&&(c.isAncestorOf(a,b.startContainer,!0)||c.isAncestorOf(a,b.endContainer,!0))}function g(a){return c.getDocument(a.startContainer)}function h(a,b,c){var d=a._listeners[b];if(d)for(var e=0,f=d.length;e<f;++e)d[e].call(a,{target:a,args:c})}function i(a){return new d(a.parentNode,c.getNodeIndex(a))}function j(a){return new d(a.parentNode,c.getNodeIndex(a)+1)}function k(a,b,d){var e=a.nodeType==11?a.firstChild:a;return c.isCharacterDataNode(b)?d==b.length?c.insertAfter(a,b):b.parentNode.insertBefore(a,d==0?b:c.splitDataNode(b,d)):d>=b.childNodes.length?b.appendChild(a):b.insertBefore(a,b.childNodes[d]),e}function l(a){var b;for(var c,d=g(a.range).createDocumentFragment(),f;c=a.next();){b=a.isPartiallySelectedSubtree(),c=c.cloneNode(!b),b&&(f=a.getSubtreeIterator(),c.appendChild(l(f)),f.detach(!0));if(c.nodeType==10)throw new e("HIERARCHY_REQUEST_ERR");d.appendChild(c)}return d}function m(a,b,d){var e,f;d=d||{stop:!1};for(var g,h;g=a.next();)if(a.isPartiallySelectedSubtree()){if(b(g)===!1){d.stop=!0;return}h=a.getSubtreeIterator(),m(h,b,d),h.detach(!0);if(d.stop)return}else{e=c.createIterator(g);while(f=e.next())if(b(f)===!1){d.stop=!0;return}}}function n(a){var b;while(a.next())a.isPartiallySelectedSubtree()?(b=a.getSubtreeIterator(),n(b),b.detach(!0)):a.remove()}function o(a){for(var b,c=g(a.range).createDocumentFragment(),d;b=a.next();){a.isPartiallySelectedSubtree()?(b=b.cloneNode(!1),d=a.getSubtreeIterator(),b.appendChild(o(d)),d.detach(!0)):a.remove();if(b.nodeType==10)throw new e("HIERARCHY_REQUEST_ERR");c.appendChild(b)}return c}function p(a,b,c){var d=!!b&&!!b.length,e,f=!!c;d&&(e=new RegExp("^("+b.join("|")+")$"));var g=[];return m(new r(a,!1),function(a){(!d||e.test(a.nodeType))&&(!f||c(a))&&g.push(a)}),g}function q(a){var b=typeof a.getName=="undefined"?"Range":a.getName();return"["+b+"("+c.inspectNode(a.startContainer)+":"+a.startOffset+", "+c.inspectNode(a.endContainer)+":"+a.endOffset+")]"}function r(a,b){this.range=a,this.clonePartiallySelectedTextNodes=b;if(!a.collapsed){this.sc=a.startContainer,this.so=a.startOffset,this.ec=a.endContainer,this.eo=a.endOffset;var d=a.commonAncestorContainer;this.sc===this.ec&&c.isCharacterDataNode(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc===d&&!c.isCharacterDataNode(this.sc)?this.sc.childNodes[this.so]:c.getClosestAncestorIn(this.sc,d,!0),this._last=this.ec===d&&!c.isCharacterDataNode(this.ec)?this.ec.childNodes[this.eo-1]:c.getClosestAncestorIn(this.ec,d,!0))}}function s(a){this.code=this[a],this.codeName=a,this.message="RangeException: "+this.codeName}function t(a,b,c){this.nodes=p(a,b,c),this._next=this.nodes[0],this._position=0}function z(a){return function(b,d){var e,f=d?b:b.parentNode;while(f){e=f.nodeType;if(c.arrayContains(a,e))return f;f=f.parentNode}return null}}function E(a,b){if(D(a,b))throw new s("INVALID_NODE_TYPE_ERR")}function F(a){if(!a.startContainer)throw new e("INVALID_STATE_ERR")}function G(a,b){if(!c.arrayContains(b,a.nodeType))throw new s("INVALID_NODE_TYPE_ERR")}function H(a,b){if(b<0||b>(c.isCharacterDataNode(a)?a.length:a.childNodes.length))throw new e("INDEX_SIZE_ERR")}function I(a,b){if(B(a,!0)!==B(b,!0))throw new e("WRONG_DOCUMENT_ERR")}function J(a){if(C(a,!0))throw new e("NO_MODIFICATION_ALLOWED_ERR")}function K(a,b){if(!a)throw new e(b)}function L(a){return!c.arrayContains(v,a.nodeType)&&!B(a,!0)}function M(a,b){return b<=(c.isCharacterDataNode(a)?a.length:a.childNodes.length)}function N(a){F(a);if(L(a.startContainer)||L(a.endContainer)||!M(a.startContainer,a.startOffset)||!M(a.endContainer,a.endOffset))throw new Error("Range error: Range is no longer valid after DOM mutation ("+a.inspect()+")")}function X(){}function Y(a){a.START_TO_START=P,a.START_TO_END=Q,a.END_TO_END=R,a.END_TO_START=S,a.NODE_BEFORE=T,a.NODE_AFTER=U,a.NODE_BEFORE_AND_AFTER=V,a.NODE_INSIDE=W}function Z(a){Y(a),Y(a.prototype)}function $(a,b){return function(){N(this);var d=this.startContainer,e=this.startOffset,f=this.commonAncestorContainer,g=new r(this,!0),h,i;d!==f&&(h=c.getClosestAncestorIn(d,f,!0),i=j(h),d=i.node,e=i.offset),m(g,J),g.reset();var k=a(g);return g.detach(),b(this,d,e,d,e),k}}function _(b,d,e){function g(a,b){return function(c){F(this),G(c,u),G(A(c),v);var d=(a?i:j)(c);(b?h:k)(this,d.node,d.offset)}}function h(a,b,e){var f=a.endContainer,g=a.endOffset;if(b!==a.startContainer||e!==this.startOffset){if(A(b)!=A(f)||c.comparePoints(b,e,f,g)==1)f=b,g=e;d(a,b,e,f,g)}}function k(a,b,e){var f=a.startContainer,g=a.startOffset;if(b!==a.endContainer||e!==this.endOffset){if(A(b)!=A(f)||c.comparePoints(b,e,f,g)==-1)f=b,g=e;d(a,f,g,b,e)}}function l(a,b,c){(b!==a.startContainer||c!==this.startOffset||b!==a.endContainer||c!==this.endOffset)&&d(a,b,c,b,c)}b.prototype=new X,a.util.extend(b.prototype,{setStart:function(a,b){F(this),E(a,!0),H(a,b),h(this,a,b)},setEnd:function(a,b){F(this),E(a,!0),H(a,b),k(this,a,b)},setStartBefore:g(!0,!0),setStartAfter:g(!1,!0),setEndBefore:g(!0,!1),setEndAfter:g(!1,!1),collapse:function(a){N(this),a?d(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):d(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(a){F(this),E(a,!0),d(this,a,0,a,c.getNodeLength(a))},selectNode:function(a){F(this),E(a,!1),G(a,u);var b=i(a),c=j(a);d(this,b.node,b.offset,c.node,c.offset)},extractContents:$(o,d),deleteContents:$(n,d),canSurroundContents:function(){N(this),J(this.startContainer),J(this.endContainer);var a=new r(this,!0),b=a._first&&f(a._first,this)||a._last&&f(a._last,this);return a.detach(),!b},detach:function(){e(this)},splitBoundaries:function(){N(this);var a=this.startContainer,b=this.startOffset,e=this.endContainer,f=this.endOffset,g=a===e;c.isCharacterDataNode(e)&&f>0&&f<e.length&&c.splitDataNode(e,f),c.isCharacterDataNode(a)&&b>0&&b<a.length&&(a=c.splitDataNode(a,b),g?(f-=b,e=a):e==a.parentNode&&f>=c.getNodeIndex(a)&&f++,b=0),d(this,a,b,e,f)},normalizeBoundaries:function(){N(this);var a=this.startContainer,b=this.startOffset,e=this.endContainer,f=this.endOffset,g=function(a){var b=a.nextSibling;b&&b.nodeType==a.nodeType&&(e=a,f=a.length,a.appendData(b.data),b.parentNode.removeChild(b))},h=function(d){var g=d.previousSibling;if(g&&g.nodeType==d.nodeType){a=d;var h=d.length;b=g.length,d.insertData(0,g.data),g.parentNode.removeChild(g);if(a==e)f+=b,e=a;else if(e==d.parentNode){var i=c.getNodeIndex(d);f==i?(e=d,f=h):f>i&&f--}}},i=!0;if(c.isCharacterDataNode(e))e.length==f&&g(e);else{if(f>0){var j=e.childNodes[f-1];j&&c.isCharacterDataNode(j)&&g(j)}i=!this.collapsed}if(i){if(c.isCharacterDataNode(a))b==0&&h(a);else if(b<a.childNodes.length){var k=a.childNodes[b];k&&c.isCharacterDataNode(k)&&h(k)}}else a=e,b=f;d(this,a,b,e,f)},collapseToPoint:function(a,b){N(this),E(a,!0),H(a,b),l(this,a,b)}}),Z(b)}function ba(a){a.collapsed=a.startContainer===a.endContainer&&a.startOffset===a.endOffset,a.commonAncestorContainer=a.collapsed?a.startContainer:c.getCommonAncestor(a.startContainer,a.endContainer)}function bb(a,b,c,d,e){var f=a.startContainer!==b||a.startOffset!==c,g=a.endContainer!==d||a.endOffset!==e;a.startContainer=b,a.startOffset=c,a.endContainer=d,a.endOffset=e,ba(a),h(a,"boundarychange",{startMoved:f,endMoved:g})}function bc(a){F(a),a.startContainer=a.startOffset=a.endContainer=a.endOffset=null,a.collapsed=a.commonAncestorContainer=null,h(a,"detach",null),a._listeners=null}function bd(a){this.startContainer=a,this.startOffset=0,this.endContainer=a,this.endOffset=0,this._listeners={boundarychange:[],detach:[]},ba(this)}a.requireModules(["DomUtil"]);var c=a.dom,d=c.DomPosition,e=a.DOMException;r.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var a=this._current=this._next;return a&&(this._next=a!==this._last?a.nextSibling:null,c.isCharacterDataNode(a)&&this.clonePartiallySelectedTextNodes&&(a===this.ec&&(a=a.cloneNode(!0)).deleteData(this.eo,a.length-this.eo),this._current===this.sc&&(a=a.cloneNode(!0)).deleteData(0,this.so))),a},remove:function(){var a=this._current,b,d;!c.isCharacterDataNode(a)||a!==this.sc&&a!==this.ec?a.parentNode&&a.parentNode.removeChild(a):(b=a===this.sc?this.so:0,d=a===this.ec?this.eo:a.length,b!=d&&a.deleteData(b,d-b))},isPartiallySelectedSubtree:function(){var a=this._current;return f(a,this.range)},getSubtreeIterator:function(){var a;if(this.isSingleCharacterDataNode)a=this.range.cloneRange(),a.collapse();else{a=new bd(g(this.range));var b=this._current,d=b,e=0,f=b,h=c.getNodeLength(b);c.isAncestorOf(b,this.sc,!0)&&(d=this.sc,e=this.so),c.isAncestorOf(b,this.ec,!0)&&(f=this.ec,h=this.eo),bb(a,d,e,f,h)}return new r(a,this.clonePartiallySelectedTextNodes)},detach:function(a){a&&this.range.detach(),this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}},s.prototype={BAD_BOUNDARYPOINTS_ERR:1,INVALID_NODE_TYPE_ERR:2},s.prototype.toString=function(){return this.message},t.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){return this._current=this._next,this._next=this.nodes[++this._position],this._current},detach:function(){this._current=this._next=this.nodes=null}};var u=[1,3,4,5,7,8,10],v=[2,9,11],w=[5,6,10,12],x=[1,3,4,5,7,8,10,11],y=[1,3,4,5,7,8],A=c.getRootContainer,B=z([9,11]),C=z(w),D=z([6,10,12]),O=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],P=0,Q=1,R=2,S=3,T=0,U=1,V=2,W=3;X.prototype={attachListener:function(a,b){this._listeners[a].push(b)},compareBoundaryPoints:function(a,b){N(this),I(this.startContainer,b.startContainer);var d,e,f,g,h=a==S||a==P?"start":"end",i=a==Q||a==P?"start":"end";return d=this[h+"Container"],e=this[h+"Offset"],f=b[i+"Container"],g=b[i+"Offset"],c.comparePoints
(d,e,f,g)},insertNode:function(a){N(this),G(a,x),J(this.startContainer);if(c.isAncestorOf(a,this.startContainer,!0))throw new e("HIERARCHY_REQUEST_ERR");var b=k(a,this.startContainer,this.startOffset);this.setStartBefore(b)},insertNodeAfter:function(a){N(this),G(a,x),J(this.startContainer);if(c.isAncestorOf(a,this.startContainer,!0))throw new e("HIERARCHY_REQUEST_ERR");var b=k(a,this.startContainer,this.endOffset)},cloneContents:function(){N(this);var a,b;if(this.collapsed)return g(this).createDocumentFragment();if(this.startContainer===this.endContainer&&c.isCharacterDataNode(this.startContainer))return a=this.startContainer.cloneNode(!0),a.data=a.data.slice(this.startOffset,this.endOffset),b=g(this).createDocumentFragment(),b.appendChild(a),b;var d=new r(this,!0);return a=l(d),d.detach(),a},canSurroundContents:function(){N(this),J(this.startContainer),J(this.endContainer);var a=new r(this,!0),b=a._first&&f(a._first,this)||a._last&&f(a._last,this);return a.detach(),!b},surroundContents:function(a){G(a,y);if(!this.canSurroundContents())throw new s("BAD_BOUNDARYPOINTS_ERR");var b=this.extractContents();if(a.hasChildNodes())while(a.lastChild)a.removeChild(a.lastChild);k(a,this.startContainer,this.startOffset),a.appendChild(b),this.selectNode(a)},cloneRange:function(){N(this);var a=new bd(g(this)),b=O.length,c;while(b--)c=O[b],a[c]=this[c];return a},toString:function(){N(this);var a=this.startContainer;if(a===this.endContainer&&c.isCharacterDataNode(a))return a.nodeType==3||a.nodeType==4?a.data.slice(this.startOffset,this.endOffset):"";var b=[],d=new r(this,!0);return m(d,function(a){(a.nodeType==3||a.nodeType==4)&&b.push(a.data)}),d.detach(),b.join("")},compareNode:function(a){N(this);var b=a.parentNode,d=c.getNodeIndex(a);if(!b)throw new e("NOT_FOUND_ERR");var f=this.comparePoint(b,d),g=this.comparePoint(b,d+1);return f<0?g>0?V:T:g>0?U:W},comparePoint:function(a,b){return N(this),K(a,"HIERARCHY_REQUEST_ERR"),I(a,this.startContainer),c.comparePoints(a,b,this.startContainer,this.startOffset)<0?-1:c.comparePoints(a,b,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:function(a){F(this);var b=g(this),c=b.createElement("div");c.innerHTML=a;var d=b.createDocumentFragment(),e;while(e=c.firstChild)d.appendChild(e);return d},toHtml:function(){N(this);var a=g(this).createElement("div");return a.appendChild(this.cloneContents()),a.innerHTML},intersectsNode:function(a,b){N(this),K(a,"NOT_FOUND_ERR");if(c.getDocument(a)!==g(this))return!1;var d=a.parentNode,e=c.getNodeIndex(a);K(d,"NOT_FOUND_ERR");var f=c.comparePoints(d,e,this.endContainer,this.endOffset),h=c.comparePoints(d,e+1,this.startContainer,this.startOffset);return b?f<=0&&h>=0:f<0&&h>0},isPointInRange:function(a,b){return N(this),K(a,"HIERARCHY_REQUEST_ERR"),I(a,this.startContainer),c.comparePoints(a,b,this.startContainer,this.startOffset)>=0&&c.comparePoints(a,b,this.endContainer,this.endOffset)<=0},intersectsRange:function(a,b){N(this);if(g(a)!=g(this))throw new e("WRONG_DOCUMENT_ERR");var d=c.comparePoints(this.startContainer,this.startOffset,a.endContainer,a.endOffset),f=c.comparePoints(this.endContainer,this.endOffset,a.startContainer,a.startOffset);return b?d<=0&&f>=0:d<0&&f>0},intersection:function(a){if(this.intersectsRange(a)){var b=c.comparePoints(this.startContainer,this.startOffset,a.startContainer,a.startOffset),d=c.comparePoints(this.endContainer,this.endOffset,a.endContainer,a.endOffset),e=this.cloneRange();return b==-1&&e.setStart(a.startContainer,a.startOffset),d==1&&e.setEnd(a.endContainer,a.endOffset),e}return null},union:function(a){if(this.intersectsRange(a,!0)){var b=this.cloneRange();return c.comparePoints(a.startContainer,a.startOffset,this.startContainer,this.startOffset)==-1&&b.setStart(a.startContainer,a.startOffset),c.comparePoints(a.endContainer,a.endOffset,this.endContainer,this.endOffset)==1&&b.setEnd(a.endContainer,a.endOffset),b}throw new s("Ranges do not intersect")},containsNode:function(a,b){return b?this.intersectsNode(a,!1):this.compareNode(a)==W},containsNodeContents:function(a){return this.comparePoint(a,0)>=0&&this.comparePoint(a,c.getNodeLength(a))<=0},containsRange:function(a){return this.intersection(a).equals(a)},containsNodeText:function(a){var b=this.cloneRange();b.selectNode(a);var c=b.getNodes([3]);if(c.length>0){b.setStart(c[0],0);var d=c.pop();b.setEnd(d,d.length);var e=this.containsRange(b);return b.detach(),e}return this.containsNodeContents(a)},createNodeIterator:function(a,b){return N(this),new t(this,a,b)},getNodes:function(a,b){return N(this),p(this,a,b)},getDocument:function(){return g(this)},collapseBefore:function(a){F(this),this.setEndBefore(a),this.collapse(!1)},collapseAfter:function(a){F(this),this.setStartAfter(a),this.collapse(!0)},getName:function(){return"DomRange"},equals:function(a){return bd.rangesEqual(this,a)},inspect:function(){return q(this)}},_(bd,bb,bc),a.rangePrototype=X.prototype,bd.rangeProperties=O,bd.RangeIterator=r,bd.copyComparisonConstants=Z,bd.createPrototypeRange=_,bd.inspect=q,bd.getRangeDocument=g,bd.rangesEqual=function(a,b){return a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset},a.DomRange=bd,a.RangeException=s}),rangy.createModule("WrappedRange",function(a,b){function g(a){var b=a.parentElement(),c=a.duplicate();c.collapse(!0);var e=c.parentElement();c=a.duplicate(),c.collapse(!1);var f=c.parentElement(),g=e==f?e:d.getCommonAncestor(e,f);return g==b?g:d.getCommonAncestor(b,g)}function h(a){return a.compareEndPoints("StartToEnd",a)==0}function i(a,b,c,f){var g=a.duplicate();g.collapse(c);var h=g.parentElement();d.isAncestorOf(b,h,!0)||(h=b);if(!h.canHaveHTML)return new e(h.parentNode,d.getNodeIndex(h));var i=d.getDocument(h).createElement("span"),j,k=c?"StartToStart":"StartToEnd",l,m,n,o;do h.insertBefore(i,i.previousSibling),g.moveToElementText(i);while((j=g.compareEndPoints(k,a))>0&&i.previousSibling);o=i.nextSibling;if(j==-1&&o&&d.isCharacterDataNode(o)){g.setEndPoint(c?"EndToStart":"EndToEnd",a);var p;if(/[\r\n]/.test(o.data)){var q=g.duplicate(),r=q.text.replace(/\r\n/g,"\r").length;p=q.moveStart("character",r);while((j=q.compareEndPoints("StartToEnd",q))==-1)p++,q.moveStart("character",1)}else p=g.text.length;n=new e(o,p)}else l=(f||!c)&&i.previousSibling,m=(f||c)&&i.nextSibling,m&&d.isCharacterDataNode(m)?n=new e(m,0):l&&d.isCharacterDataNode(l)?n=new e(l,l.length):n=new e(h,d.getNodeIndex(i));return i.parentNode.removeChild(i),n}function j(a,b){var c,e,f=a.offset,g=d.getDocument(a.node),h,i,j=g.body.createTextRange(),k=d.isCharacterDataNode(a.node);return k?(c=a.node,e=c.parentNode):(i=a.node.childNodes,c=f<i.length?i[f]:null,e=a.node),h=g.createElement("span"),h.innerHTML="&#feff;",c?e.insertBefore(h,c):e.appendChild(h),j.moveToElementText(h),j.collapse(!b),e.removeChild(h),k&&j[b?"moveStart":"moveEnd"]("character",f),j}a.requireModules(["DomUtil","DomRange"]);var c,d=a.dom,e=d.DomPosition,f=a.DomRange;if(a.features.implementsDomRange&&(!a.features.implementsTextRange||!a.config.preferTextRange))(function(){function g(a){var c=b.length,d;while(c--)d=b[c],a[d]=a.nativeRange[d]}function h(a,b,c,d,e){var f=a.startContainer!==b||a.startOffset!=c,g=a.endContainer!==d||a.endOffset!=e;if(f||g)a.setEnd(d,e),a.setStart(b,c)}function i(a){a.nativeRange.detach(),a.detached=!0;var c=b.length,d;while(c--)d=b[c],a[d]=null}var a,b=f.rangeProperties,e,j;c=function(a){if(!a)throw new Error("Range must be specified");this.nativeRange=a,g(this)},f.createPrototypeRange(c,h,i),a=c.prototype,a.selectNode=function(a){this.nativeRange.selectNode(a),g(this)},a.deleteContents=function(){this.nativeRange.deleteContents(),g(this)},a.extractContents=function(){var a=this.nativeRange.extractContents();return g(this),a},a.cloneContents=function(){return this.nativeRange.cloneContents()},a.surroundContents=function(a){this.nativeRange.surroundContents(a),g(this)},a.collapse=function(a){this.nativeRange.collapse(a),g(this)},a.cloneRange=function(){return new c(this.nativeRange.cloneRange())},a.refresh=function(){g(this)},a.toString=function(){return this.nativeRange.toString()};var k=document.createTextNode("test");d.getBody(document).appendChild(k);var l=document.createRange();l.setStart(k,0),l.setEnd(k,0);try{l.setStart(k,1),e=!0,a.setStart=function(a,b){this.nativeRange.setStart(a,b),g(this)},a.setEnd=function(a,b){this.nativeRange.setEnd(a,b),g(this)},j=function(a){return function(b){this.nativeRange[a](b),g(this)}}}catch(m){e=!1,a.setStart=function(a,b){try{this.nativeRange.setStart(a,b)}catch(c){this.nativeRange.setEnd(a,b),this.nativeRange.setStart(a,b)}g(this)},a.setEnd=function(a,b){try{this.nativeRange.setEnd(a,b)}catch(c){this.nativeRange.setStart(a,b),this.nativeRange.setEnd(a,b)}g(this)},j=function(a,b){return function(c){try{this.nativeRange[a](c)}catch(d){this.nativeRange[b](c),this.nativeRange[a](c)}g(this)}}}a.setStartBefore=j("setStartBefore","setEndBefore"),a.setStartAfter=j("setStartAfter","setEndAfter"),a.setEndBefore=j("setEndBefore","setStartBefore"),a.setEndAfter=j("setEndAfter","setStartAfter"),l.selectNodeContents(k),l.startContainer==k&&l.endContainer==k&&l.startOffset==0&&l.endOffset==k.length?a.selectNodeContents=function(a){this.nativeRange.selectNodeContents(a),g(this)}:a.selectNodeContents=function(a){this.setStart(a,0),this.setEnd(a,f.getEndOffset(a))},l.selectNodeContents(k),l.setEnd(k,3);var n=document.createRange();n.selectNodeContents(k),n.setEnd(k,4),n.setStart(k,2),l.compareBoundaryPoints(l.START_TO_END,n)==-1&l.compareBoundaryPoints(l.END_TO_START,n)==1?a.compareBoundaryPoints=function(a,b){return b=b.nativeRange||b,a==b.START_TO_END?a=b.END_TO_START:a==b.END_TO_START&&(a=b.START_TO_END),this.nativeRange.compareBoundaryPoints(a,b)}:a.compareBoundaryPoints=function(a,b){return this.nativeRange.compareBoundaryPoints(a,b.nativeRange||b)},d.getBody(document).removeChild(k),l.detach(),n.detach()})(),a.createNativeRange=function(a){return a=a||document,a.createRange()};else if(a.features.implementsTextRange){c=function(a){this.textRange=a,this.refresh()},c.prototype=new f(document),c.prototype.refresh=function(){var a,b,c=g(this.textRange);h(this.textRange)?b=a=i(this.textRange,c,!0,!0):(a=i(this.textRange,c,!0,!1),b=i(this.textRange,c,!1,!1)),this.setStart(a.node,a.offset),this.setEnd(b.node,b.offset)},c.rangeToTextRange=function(a){if(a.collapsed)return j(new e(a.startContainer,a.startOffset),!0);var b=j(new e(a.startContainer,a.startOffset),!0),c=j(new e(a.endContainer,a.endOffset),!1),f=d.getDocument(a.startContainer).body.createTextRange();return f.setEndPoint("StartToStart",b),f.setEndPoint("EndToEnd",c),f},f.copyComparisonConstants(c);var k=function(){return this}();typeof k.Range=="undefined"&&(k.Range=c),a.createNativeRange=function(a){return a=a||document,a.body.createTextRange()}}c.prototype.getName=function(){return"WrappedRange"},a.WrappedRange=c,a.createRange=function(b){return b=b||document,new c(a.createNativeRange(b))},a.createRangyRange=function(a){return a=a||document,new f(a)},a.createIframeRange=function(b){return a.createRange(d.getIframeDocument(b))},a.createIframeRangyRange=function(b){return a.createRangyRange(d.getIframeDocument(b))},a.addCreateMissingNativeApiListener(function(b){var c=b.document;typeof c.createRange=="undefined"&&(c.createRange=function(){return a.createRange(this)}),c=b=null})}),rangy.createModule("WrappedSelection",function(a,b){function n(a){return(a||window).getSelection()}function o(a){return(a||window).document.selection}function C(a,b,c){var d=c?"end":"start",e=c?"start":"end";a.anchorNode=b[d+"Container"],a.anchorOffset=b[d+"Offset"],a.focusNode=b[e+"Container"],a.focusOffset=b[e+"Offset"]}function D(a){var b=a.nativeSelection;a.anchorNode=b.anchorNode,a.anchorOffset=b.anchorOffset,a.focusNode=b.focusNode,a.focusOffset=b.focusOffset}function E(a){a.anchorNode=a.focusNode=null,a.anchorOffset=a.focusOffset=0,a.rangeCount=0,a.isCollapsed=!0,a._ranges.length=0}function F(b){var c;return b instanceof g?(c=b._selectionNativeRange,c||(c=a.createNativeRange(e.getDocument(b.startContainer)),c.setEnd(b.endContainer,b.endOffset),c.setStart(b.startContainer,b.startOffset),b._selectionNativeRange=c,b.attachListener("detach",function(){this._selectionNativeRange=null}))):b instanceof h?c=b.nativeRange:a.features.implementsDomRange&&b instanceof e.getWindow(b.startContainer).Range&&(c=b),c}function G(a){if(!a.length||a[0].nodeType!=1)return!1;for(var b=1,c=a.length;b<c;++b)if(!e.isAncestorOf(a[0],a[b]))return!1;return!0}function H(a){var b=a.getNodes();if(!G(b))throw new Error("getSingleElementFromRange: range "+a.inspect()+" did not consist of a single element");return b[0]}function I(a){return!!a&&typeof a.text!="undefined"}function J(a,b){var c=new h(b);a._ranges=[c],C(a,c,!1),a.rangeCount=1,a.isCollapsed=c.collapsed}function K(b){b._ranges.length=0;if(b.docSelection.type=="None")E(b);else{var c=b.docSelection.createRange();if(I(c))J(b,c);else{b.rangeCount=c.length;var d,f=e.getDocument(c.item(0));for(var g=0;g<b.rangeCount;++g)d=a.createRange(f),d.selectNode(c.item(g)),b._ranges.push(d);b.isCollapsed=b.rangeCount==1&&b._ranges[0].collapsed,C(b,b._ranges[b.rangeCount-1],!1)}}}function L(a,b){var c=a.docSelection.createRange(),d=H(b),f=e.getDocument(c.item(0)),g=e.getBody(f).createControlRange();for(var h=0,i=c.length;h<i;++h)g.add(c.item(h));try{g.add(d)}catch(j){throw new Error("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}g.select(),K(a)}function N(a,b,c){this.nativeSelection=a,this.docSelection=b,this._ranges=[],this.win=c,this.refresh()}function P(a,b){var c=e.getDocument(b[0].startContainer),d=e.getBody(c).createControlRange();for(var f=0,g;f<rangeCount;++f){g=H(b[f]);try{d.add(g)}catch(h){throw new Error("setRanges(): Element within the one of the specified Ranges could not be added to control selection (does it have layout?)")}}d.select(),K(a)}function U(a,b){if(a.anchorNode&&e.getDocument(a.anchorNode)!==e.getDocument(b))throw new i("WRONG_DOCUMENT_ERR")}function V(a){var b=[],c=new j(a.anchorNode,a.anchorOffset),d=new j(a.focusNode,a.focusOffset),e=typeof a.getName=="function"?a.getName():"Selection";if(typeof a.rangeCount!="undefined")for(var f=0,h=a.rangeCount;f<h;++f)b[f]=g.inspect(a.getRangeAt(f));return"["+e+"(Ranges: "+b.join(", ")+")(anchor: "+c.inspect()+", focus: "+d.inspect()+"]"}a.requireModules(["DomUtil","DomRange","WrappedRange"]),a.config.checkSelectionRanges=!0;var c="boolean",d="_rangySelection",e=a.dom,f=a.util,g=a.DomRange,h=a.WrappedRange,i=a.DOMException,j=e.DomPosition,k,l,m="Control",p=a.util.isHostMethod(window,"getSelection"),q=a.util.isHostObject(document,"selection"),r=q&&(!p||a.config.preferTextRange);r?(k=o,a.isSelectionValid=function(a){var b=(a||window).document,c=b.selection;return c.type!="None"||e.getDocument(c.createRange().parentElement())==b}):p?(k=n,a.isSelectionValid=function(){return!0}):b.fail("Neither document.selection or window.getSelection() detected."),a.getNativeSelection=k;var s=k(),t=a.createNativeRange(document),u=e.getBody(document),v=f.areHostObjects(s,["anchorNode","focusNode"]&&f.areHostProperties(s,["anchorOffset","focusOffset"]));a.features.selectionHasAnchorAndFocus=v;var w=f.isHostMethod(s,"extend");a.features.selectionHasExtend=w;var x=typeof s.rangeCount=="number";a.features.selectionHasRangeCount=x;var y=!1,z=!0;f.areHostMethods(s,["addRange","getRangeAt","removeAllRanges"])&&typeof s.rangeCount=="number"&&a.features.implementsDomRange&&function(){var a=document.createElement("iframe");u.appendChild(a);var b=e.getIframeDocument(a);b.open(),b.write("<html><head></head><body>12</body></html>"),b.close();var c=e.getIframeWindow(a).getSelection(),d=b.documentElement,f=d.lastChild,g=f.firstChild,h=b.createRange();h.setStart(g,1),h.collapse(!0),c.addRange(h),z=c.rangeCount==1,c.removeAllRanges();var i=h.cloneRange();h.setStart(g,0),i.setEnd(g,2),c.addRange(h),c.addRange(i),y=c.rangeCount==2,h.detach(),i.detach(),u.removeChild(a)}(),a.features.selectionSupportsMultipleRanges=y,a.features.collapsedNonEditableSelectionsSupported=z;var A=!1,B;u&&f.isHostMethod(u,"createControlRange")&&(B=u.createControlRange(),f.areHostProperties(B,["item","add"])&&(A=!0)),a.features.implementsControlRange=A,v?l=function(a){return a.anchorNode===a.focusNode&&a.anchorOffset===a.focusOffset}:l=function(a){return a.rangeCount?a.getRangeAt(a.rangeCount-1).collapsed:!1};var M;f.isHostMethod(s,"getRangeAt")?M=function(a,b){try{return a.getRangeAt(b)}catch(c){return null}}:v&&(M=function(b){var c=e.getDocument(b.anchorNode),d=a.createRange(c);return d.setStart(b.anchorNode,b.anchorOffset),d.setEnd(b.focusNode,b.focusOffset),d.collapsed!==this.isCollapsed&&(d.setStart(b.focusNode,b.focusOffset),d.setEnd(b.anchorNode,b.anchorOffset)),d}),a.getSelection=function(a){a=a||window;var b=a[d],c=k(a),e=q?o(a):null;return b?(b.nativeSelection=c,b.docSelection=e,b.refresh(a)):(b=new N(c,e,a),a[d]=b),b},a.getIframeSelection=function(b){return a.getSelection(e.getIframeWindow(b))};var O=N.prototype;if(!r&&v&&f.areHostMethods(s,["removeAllRanges","addRange"])){O.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),E(this)};var Q=function(b,c){var d=g.getRangeDocument(c),e=a.createRange(d);e.collapseToPoint(c.endContainer,c.endOffset),b.nativeSelection.addRange(F(e)),b.nativeSelection.extend(c.startContainer,c.startOffset),b.refresh()};x?O.addRange=function(b,c){if(A&&q&&this.docSelection.type==m)L(this,b);else if(c&&w)Q(this,b);else{var d;y?d=this.rangeCount:(this.removeAllRanges(),d=0),this.nativeSelection.addRange(F(b)),this.rangeCount=this.nativeSelection.rangeCount;if(this.rangeCount==d+1){if(a.config.checkSelectionRanges){var e=M(this.nativeSelection,this.rangeCount-1);e&&!g.rangesEqual(e,b)&&(b=new h(e))}this._ranges[this.rangeCount-1]=b,C(this,b,T(this.nativeSelection)),this.isCollapsed=l(this)}else this.refresh()}}:O.addRange=function(a,b){b&&w?Q(this,a):(this.nativeSelection.addRange(F(a)),this.refresh())},O.setRanges=function(a){if(A&&a.length>1)P(this,a);else{this.removeAllRanges();for(var b=0,c=a.length;b<c;++b)this.addRange(a[b])}}}else if(f.isHostMethod(s,"empty")&&f.isHostMethod(t,"select")&&A&&r)O.removeAllRanges=function(){try{this.docSelection.empty();if(this.docSelection.type!="None"){var a;if(this.anchorNode)a=e.getDocument(this.anchorNode);else if(this.docSelection.type==m){var b=this.docSelection.createRange();b.length&&(a=e.getDocument(b.item(0)).body.createTextRange())}if(a){var c=a.body.createTextRange();c.select(),this.docSelection.empty()}}}catch(d){}E(this)},O.addRange=function(a){this.docSelection.type==m?L(this,a):(h.rangeToTextRange(a).select(),this._ranges[0]=a,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,C(this,a,!1))},O.setRanges=function(a){this.removeAllRanges();var b=a.length;b>1?P(this,a):b&&this.addRange(a[0])};else return b.fail("No means of selecting a Range or TextRange was found"),!1;O.getRangeAt=function(a){if(a<0||a>=this.rangeCount)throw new i("INDEX_SIZE_ERR");return this._ranges[a]};var R;if(r)R=function(b){var c;a.isSelectionValid(b.win)?c=b.docSelection.createRange():(c=e.getBody(b.win.document).createTextRange(),c.collapse(!0)),b.docSelection.type==m?K(b):I(c)?J(b,c):E(b)};else if(f.isHostMethod(s,"getRangeAt")&&typeof s.rangeCount=="number")R=function(b){if(A&&q&&b.docSelection.type==m)K(b);else{b._ranges.length=b.rangeCount=b.nativeSelection.rangeCount;if(b.rangeCount){for(var c=0,d=b.rangeCount;c<d;++c)b._ranges[c]=new a.WrappedRange(b.nativeSelection.getRangeAt(c));C(b,b._ranges[b.rangeCount-1],T(b.nativeSelection)),b.isCollapsed=l(b)}else E(b)}};else if(v&&typeof s.isCollapsed==c&&typeof t.collapsed==c&&a.features.implementsDomRange)R=function(a){var b,c=a.nativeSelection;c.anchorNode?(b=M(c,0),a._ranges=[b],a.rangeCount=1,D(a),a.isCollapsed=l(a)):E(a)};else return b.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;O.refresh=function(a){var b=a?this._ranges.slice(0):null;R(this);if(a){var c=b.length;if(c!=this._ranges.length)return!1;while(c--)if(!g.rangesEqual(b[c],this._ranges[c]))return!1;return!0}};var S=function(a,b){var c=a.getAllRanges(),d=!1;a.removeAllRanges();for(var e=0,f=c.length;e<f;++e)d||b!==c[e]?a.addRange(c[e]):d=!0;a.rangeCount||E(a)};A?O.removeRange=function(a){if(this.docSelection.type==m){var b=this.docSelection.createRange(),c=H(a),d=e.getDocument(b.item(0)),f=e.getBody(d).createControlRange(),g,h=!1;for(var i=0,j=b.length;i<j;++i)g=b.item(i),g!==c||h?f.add(b.item(i)):h=!0;f.select(),K(this)}else S(this,a)}:O.removeRange=function(a){S(this,a)};var T;!r&&v&&a.features.implementsDomRange?(T=function(a){var b=!1;return a.anchorNode&&(b=e.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset)==1),b},O.isBackwards=function(){return T(this)}):T=O.isBackwards=function(){return!1},O.toString=function(){var a=[];for(var b=0,c=this.rangeCount;b<c;++b)a[b]=""+this._ranges[b];return a.join("")},O.collapse=function(b,c){U(this,b);var d=a.createRange(e.getDocument(b));d.collapseToPoint(b,c),this.removeAllRanges(),this.addRange(d),this.isCollapsed=!0},O.collapseToStart=function(){if(!this.rangeCount)throw new i("INVALID_STATE_ERR");var a=this._ranges[0];this.collapse(a.startContainer,a.startOffset)},O.collapseToEnd=function(){if(!this.rangeCount)throw new i("INVALID_STATE_ERR");var a=this._ranges[this.rangeCount-1];this.collapse(a.endContainer,a.endOffset)},O.selectAllChildren=function(b){U(this,b);var c=a.createRange(e.getDocument(b));c.selectNodeContents(b),this.removeAllRanges(),this.addRange(c)},O.deleteFromDocument=function(){if(A&&q&&this.docSelection.type==m){var a=this.docSelection.createRange(),b;while(a.length)b=a.item(0),a.remove(b),b.parentNode.removeChild(b);this.refresh()}else if(this.rangeCount){var c=this.getAllRanges();this.removeAllRanges();for(var d=0,e=c.length;d<e;++d)c[d].deleteContents();this.addRange(c[e-1])}},O.getAllRanges=function(){return this._ranges.slice(0)},O.setSingleRange=function(a){this.setRanges([a])},O.containsNode=function(a,b){for(var c=0,d=this._ranges.length;c<d;++c)if(this._ranges[c].containsNode(a,b))return!0;return!1},O.toHtml=function(){var a="";if(this.rangeCount){var b=g.getRangeDocument(this._ranges[0]).createElement("div");for(var c=0,d=this._ranges.length;c<d;++c)b.appendChild(this._ranges[c].cloneContents());a=b.innerHTML}return a},O.getName=function(){return"WrappedSelection"},O.inspect=function(){return V(this)},O.detach=function(){this.win[d]=null,this.win=this.anchorNode=this.focusNode=null},N.inspect=V,a.Selection=N,a.selectionPrototype=O,a.addCreateMissingNativeApiListener(function(b){typeof b.getSelection=="undefined"&&(b.getSelection=function(){return a.getSelection(this)}),b=null})}),rangy.createModule("CssClassApplier",function(a,b){function e(a){return a.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function f(a,b){return a.className&&(new RegExp("(?:^|\\s)"+b+"(?:\\s|$)")).test(a.className)}function g(a,b){a.className?f(a,b)||(a.className+=" "+b):a.className=b}function i(a){return a.split(/\s+/).sort().join(" ")}function j(a){return i(a.className)}function k(a,b){return j(a)==j(b)}function l(a){var b=a.parentNode;while(a.hasChildNodes())b.insertBefore(a.firstChild,a);b.removeChild(a)}function m(a,b){var c=a.cloneRange();c.selectNodeContents(b);var d=c.intersection(a),e=d?d.toString():"";return c.detach(),e!=""}function n(a){return a.getNodes([3],function(b){return m(a,b)})}function o(a,b){if(a.attributes.length!=b.attributes.length)return!1;for(var c=0,d=a.attributes.length,e,f,g;c<d;++c){e=a.attributes[c],g=e.name;if(g!="class"){f=b.attributes.getNamedItem(g);if(e.specified!=f.specified)return!1;if(e.specified&&e.nodeValue!==f.nodeValue)return!1}}return!0}function p(a,b){for(var d=0,e=a.attributes.length,f;d<e;++d){f=a.attributes[d].name;if((!b||!c.arrayContains(b,f))&&a.attributes[d].specified&&f!="class")return!0}return!1}function q(a,b){for(var c in b)if(b.hasOwnProperty(c)&&a[c]!==b[c])return!1;return!0}function t(a){var b;return a&&a.nodeType==1&&((b=a.parentNode)&&b.nodeType==9&&b.designMode=="on"||s(a)&&!s(a.parentNode))}function u(a){return(s(a)||a.nodeType!=1&&s(a.parentNode))&&!t(a)}function w(a){return a&&a.nodeType==1&&!v.test(r(a,"display"))}function y(a){if(a.data.length==0)return!0;if(x.test(a.data))return!1;var b=r(a.parentNode,"whiteSpace");switch(b){case"pre":case"pre-wrap":case"-moz-pre-wrap":return!1;case"pre-line":if(/[\r\n]/.test(a.data))return!1}return w(a.previousSibling)||w(a.nextSibling)}function z(a,b){return c.isCharacterDataNode(a)?b==0?!!a.previousSibling:b==a.length?!!a.nextSibling:!0:b>0&&b<a.childNodes.length}function A(a,d,e,f){var g,h=e==0;if(c.isAncestorOf(d,a))throw b.createError("descendant is ancestor of node");if(c.isCharacterDataNode(d))if(e==0)e=c.getNodeIndex(d),d=d.parentNode;else if(e==d.length)e=c.getNodeIndex(d)+1,d=d.parentNode;else throw b.createError("splitNodeAt should not be called with offset in the middle of a data node ("+e+" in "+d.data);if(z(d,e)){if(!g){g=d.cloneNode(!1),g.id&&g.removeAttribute("id");var i;while(i=d.childNodes[e])g.appendChild(i);c.insertAfter(g,d)}return d==a?g:A(a,g.parentNode,c.getNodeIndex(g),f)}if(a!=d){g=d.parentNode;var j=c.getNodeIndex(d);return h||j++,A(a,g,j,f)}return a}function B(a,b){return a.tagName==b.tagName&&k(a,b)&&o(a,b)}function C(a){var b=a?"nextSibling":"previousSibling";return function(c,d){var e=c.parentNode,f=c[b];if(f){if(f&&f.nodeType==3)return f}else if(d){f=e[b];if(f&&f.nodeType==1&&B(e,f))return f[a?"firstChild":"lastChild"]}return null}}function F(a){this.isElementMerge=a.nodeType==1,this.firstTextNode=this.isElementMerge?a.lastChild:a,this.textNodes=[this.firstTextNode]}function I(a,b,c){this.cssClass=a;var d,f,g,h,j=null;if(typeof b=="object"&&b!==null){c=b.tagNames,j=b.elementProperties;for(f=0;h=G[f++];)b.hasOwnProperty(h)&&(this[h]=b[h]);d=b.normalize}else d=b;this.normalize=typeof d=="undefined"?!0:d,this.attrExceptions=[];var k=document.createElement(this.elementTagName);this.elementProperties={};for(var l in j)j.hasOwnProperty(l)&&(H.hasOwnProperty(l)&&(l=H[l]),k[l]=j[l],this.elementProperties[l]=k[l],this.attrExceptions.push(l));this.elementSortedClassName=this.elementProperties.hasOwnProperty("className")?i(this.elementProperties.className+" "+a):a,this.applyToAnyTagName=!1;var m=typeof c;if(m=="string")c=="*"?this.applyToAnyTagName=!0:this.tagNames=e(c.toLowerCase()).split(/\s*,\s*/);else if(m=="object"&&typeof c.length=="number"){this.tagNames=[];for(f=0,g=c.length;f<g;++f)c[f]=="*"?this.applyToAnyTagName=!0:this.tagNames.push(c[f].toLowerCase())}else this.tagNames=[this.elementTagName]}function J(a,b,c){return new I(a,b,c)}a.requireModules(["WrappedSelection","WrappedRange"]);var c=a.dom,d="span",h=function(){function a(a,b,c){return b&&c?" ":""}return function(b,c){b.className&&(b.className=b.className.replace(new RegExp("(?:^|\\s)"+c+"(?:\\s|$)"),a))}}(),r;typeof window.getComputedStyle!="undefined"?r=function(a,b){return c.getWindow(a).getComputedStyle(a,null)[b]}:typeof document.documentElement.currentStyle!="undefined"?r=function(a,b){return a.currentStyle[b]}:b.fail("No means of obtaining computed style properties found");var s;(function(){var a=document.createElement("div");typeof a.isContentEditable=="boolean"?s=function(a){return a&&a.nodeType==1&&a.isContentEditable}:s=function(a){return!a||a.nodeType!=1||a.contentEditable=="false"?!1:a.contentEditable=="true"||s(a.parentNode)}})();var v=/^inline(-block|-table)?$/i,x=/[^\r\n\t\f \u200B]/,D=C(!1),E=C(!0);F.prototype={doMerge:function(){var a=[],b,c,d;for(var e=0,f=this.textNodes.length;e<f;++e)b=this.textNodes[e],c=b.parentNode,a[e]=b.data,e&&(c.removeChild(b),c.hasChildNodes()||c.parentNode.removeChild(c));return this.firstTextNode.data=d=a.join(""),d},getLength:function(){var a=this.textNodes.length,b=0;while(a--)b+=this.textNodes[a].length;return b},toString:function(){var a=[];for(var b=0,c=this.textNodes.length;b<c;++b)a[b]="'"+this.textNodes[b].data+"'";return"[Merge("+a.join(",")+")]"}};var G=["elementTagName","ignoreWhiteSpace","applyToEditableOnly"],H={"class":"className"};I.prototype={elementTagName:d,elementProperties:{},ignoreWhiteSpace:!0,applyToEditableOnly:!1,hasClass:function(a){return a.nodeType==1&&c.arrayContains(this.tagNames,a.tagName.toLowerCase())&&f(a,this.cssClass)},getSelfOrAncestorWithClass:function(a){while(a){if(this.hasClass(a,this.cssClass))return a;a=a.parentNode}return null},isModifiable:function(a){return!this.applyToEditableOnly||u(a)},isIgnorableWhiteSpaceNode:function(a){return this.ignoreWhiteSpace&&a&&a.nodeType==3&&y(a)},postApply:function(a,b,c){var d=a[0],e=a[a.length-1],f=[],g,h=d,i=e,j=0,k=e.length,l,m;for(var n=0,o=a.length;n<o;++n)l=a[n],m=D(l,!c),m?(g||(g=new F(m),f.push(g)),g.textNodes.push(l),l===d&&(h=g.firstTextNode,j=h.length),l===e&&(i=g.firstTextNode,k=g.getLength())):g=null;var p=E(e,!c);p&&(g||(g=new F(e),f.push(g)),g.textNodes.push(p));if(f.length){for(n=0,o=f.length;n<o;++n)f[n].doMerge();b.setStart(h,j),b.setEnd(i,k)}},createContainer:function(b){var c=b.createElement(this.elementTagName);return a.util.extend(c,this.elementProperties),g(c,this.cssClass),c},applyToTextNode:function(a){var b=a.parentNode;if(b.childNodes.length==1&&c.arrayContains(this.tagNames,b.tagName.toLowerCase()))g(b,this.cssClass);else{var d=this.createContainer(c.getDocument(a));a.parentNode.insertBefore(d,a),d.appendChild(a)}},isRemovable:function(a){return a.tagName.toLowerCase()==this.elementTagName&&j(a)==this.elementSortedClassName&&q(a,this.elementProperties)&&!p(a,this.attrExceptions)&&this.isModifiable(a)},undoToTextNode:function(a,b,c){if(!b.containsNode(c)){var d=b.cloneRange();d.selectNode(c),d.isPointInRange(b.endContainer,b.endOffset)&&(A(c,b.endContainer,b.endOffset,[b]),b.setEndAfter(c)),d.isPointInRange(b.startContainer,b.startOffset)&&(c=A(c,b.startContainer,b.startOffset,[b]))}this.isRemovable(c)?l(c):h(c,this.cssClass)},applyToRange:function(a){a.splitBoundaries();var b=n(a);if(b.length){var c;for(var d=0,e=b.length;d<e;++d)c=b[d],!this.isIgnorableWhiteSpaceNode(c)&&!this.getSelfOrAncestorWithClass(c)&&this.isModifiable(c)&&this.applyToTextNode(c);a.setStart(b[0],0),c=b[b.length-1],a.setEnd(c,c.length),this.normalize&&this.postApply(b,a,!1)}},applyToSelection:function(b){b=b||window;var c=a.getSelection(b),d,e=c.getAllRanges();c.removeAllRanges();var f=e.length;while(f--)d=e[f],this.applyToRange(d),c.addRange(d)},undoToRange:function(a){a.splitBoundaries();var b=n(a),c,d,e=b[b.length-1];if(b.length){for(var f=0,g=b.length;f<g;++f)c=b[f],d=this.getSelfOrAncestorWithClass(c),d&&this.isModifiable(c)&&this.undoToTextNode(c,a,d),a.setStart(b[0],0),a.setEnd(e,e.length);this.normalize&&this.postApply(b,a,!0)}},undoToSelection:function(b){b=b||window;var c=a.getSelection(b),d=c.getAllRanges(),e;c.removeAllRanges();for(var f=0,g=d.length;f<g;++f)e=d[f],this.undoToRange(e),c.addRange(e)},getTextSelectedByRange:function(a,b){var c=b.cloneRange();c.selectNodeContents(a);var d=c.intersection(b),e=d?d.toString():"";return c.detach(),e},isAppliedToRange:function(a){if(a.collapsed)return!!this.getSelfOrAncestorWithClass(a.commonAncestorContainer);var b=a.getNodes([3]);for(var c=0,d;d=b[c++];)if(!this.isIgnorableWhiteSpaceNode(d)&&m(a,d)&&this.isModifiable(d)&&!this.getSelfOrAncestorWithClass(d))return!1;return!0},isAppliedToSelection:function(b){b=b||window;var c=a.getSelection(b),d=c.getAllRanges(),e=d.length;while(e--)if(!this.isAppliedToRange(d[e]))return!1;return!0},toggleRange:function(a){this.isAppliedToRange(a)?this.undoToRange(a):this.applyToRange(a)},toggleSelection:function(a){this.isAppliedToSelection(a)?this.undoToSelection(a):this.applyToSelection(a)},detach:function(){}},I.util={hasClass:f,addClass:g,removeClass:h,hasSameClasses:k,replaceWithOwnChildren:l,elementsHaveSameNonClassAttributes:o,elementHasNonClassAttributes:p,splitNodeAt:A,isEditableElement:s,isEditingHost:t,isEditable:u},a.CssClassApplier=I,a.createCssClassApplier=J}),rangy.createModule("SaveRestore",function(a,b){function e(a,b){return(b||document).getElementById(a)}function f(a,b){var e="selectionBoundary_"+ +(new Date)+"_"+(""+Math.random()).slice(2),f,g=c.getDocument(a.startContainer),h=a.cloneRange();return h.collapse(b),f=g.createElement("span"),f.id=e,f.className="selectionBoundary",f.style.lineHeight="0",f.style.display="none",f.appendChild(g.createTextNode(d)),h.insertNode(f),h.detach(),f}function g(a,c,d,f){var g=e(d,a);g?(c[f?"setStartBefore":"setEndBefore"](g),g.parentNode.removeChild(g)):b.warn("Marker element has been removed. Cannot restore selection.")}function h(a,b){return b.compareBoundaryPoints(a.START_TO_START,a)}function i(c){c=c||window;var d=c.document;if(!
a.isSelectionValid(c)){b.warn("Cannot save selection. This usually happens when the selection is collapsed and the selection document has lost focus.");return}var g=a.getSelection(c),i=g.getAllRanges(),j=[],k,l,m;i.sort(h);for(var n=0,o=i.length;n<o;++n)m=i[n],m.collapsed?(l=f(m,!1),j.push({markerId:l.id,collapsed:!0})):(l=f(m,!1),k=f(m,!0),j[n]={startMarkerId:k.id,endMarkerId:l.id,collapsed:!1,backwards:i.length==1&&g.isBackwards()});for(n=o-1;n>=0;--n)m=i[n],m.collapsed?m.collapseBefore(e(j[n].markerId,d)):(m.setEndBefore(e(j[n].endMarkerId,d)),m.setStartAfter(e(j[n].startMarkerId,d)));return g.setRanges(i),{win:c,doc:d,rangeInfos:j,restored:!1}}function j(c,d){if(!c.restored){var f=c.rangeInfos,h=a.getSelection(c.win),i=[];for(var j=f.length,k=j-1,l,m;k>=0;--k){l=f[k],m=a.createRange(c.doc);if(l.collapsed){var n=e(l.markerId,c.doc);if(n){n.style.display="inline";var o=n.previousSibling;o&&o.nodeType==3?(n.parentNode.removeChild(n),m.collapseToPoint(o,o.length)):(m.collapseBefore(n),n.parentNode.removeChild(n))}else b.warn("Marker element has been removed. Cannot restore selection.")}else g(c.doc,m,l.startMarkerId,!0),g(c.doc,m,l.endMarkerId,!1);j==1&&m.normalizeBoundaries(),i[k]=m}j==1&&d&&a.features.selectionHasExtend&&f[0].backwards?(h.removeAllRanges(),h.addRange(i[0],!0)):h.setRanges(i),c.restored=!0}}function k(a,b){var c=e(b,a);c&&c.parentNode.removeChild(c)}function l(a){var b=a.rangeInfos;for(var c=0,d=b.length,e;c<d;++c)e=b[c],e.collapsed?k(a.doc,e.markerId):(k(a.doc,e.startMarkerId),k(a.doc,e.endMarkerId))}a.requireModules(["DomUtil","DomRange","WrappedRange"]);var c=a.dom,d="﻿";a.saveSelection=i,a.restoreSelection=j,a.removeMarkerElement=k,a.removeMarkers=l}),rangy.createModule("Serializer",function(a,b){function f(a){return a.replace(/</g,"&lt;").replace(/>/g,"&gt;")}function g(a,b){b=b||[];var c=a.nodeType,d=a.childNodes,e=d.length,h=[c,a.nodeName,e].join(":"),i="",j="";switch(c){case 3:i=f(a.nodeValue);break;case 8:i="<!--"+f(a.nodeValue)+"-->";break;default:i="<"+h+">",j="</>"}i&&b.push(i);for(var k=0;k<e;++k)g(d[k],b);return j&&b.push(j),b}function h(a){var b=g(a).join("");return d(b).toString(16)}function i(a,b,c){var d=[],f=a;c=c||e.getDocument(a).documentElement;while(f&&f!=c)d.push(e.getNodeIndex(f,!0)),f=f.parentNode;return d.join("/")+":"+b}function j(a,c,d){c?d=d||e.getDocument(c):(d=d||document,c=d.documentElement);var f=a.split(":"),g=c,h=f[0]?f[0].split("/"):[],i=h.length,j;while(i--){j=parseInt(h[i],10);if(j<g.childNodes.length)g=g.childNodes[parseInt(h[i],10)];else throw b.createError("deserializePosition failed: node "+e.inspectNode(g)+" has no child with index "+j+", "+i)}return new e.DomPosition(g,parseInt(f[1],10))}function k(b,c,d){d=d||a.DomRange.getRangeDocument(b).documentElement;if(!e.isAncestorOf(d,b.commonAncestorContainer,!0))throw new Error("serializeRange: range is not wholly contained within specified root node");var f=i(b.startContainer,b.startOffset,d)+","+i(b.endContainer,b.endOffset,d);return c||(f+="{"+h(d)+"}"),f}function l(b,c,d){c?d=d||e.getDocument(c):(d=d||document,c=d.documentElement);var f=/^([^,]+),([^,\{]+)({([^}]+)})?$/.exec(b),g=f[4],i=h(c);if(g&&g!==h(c))throw new Error("deserializeRange: checksums of serialized range root node ("+g+") and target root node ("+i+") do not match");var k=j(f[1],c,d),l=j(f[2],c,d),m=a.createRange(d);return m.setStart(k.node,k.offset),m.setEnd(l.node,l.offset),m}function m(a,b,c){b?c=c||e.getDocument(b):(c=c||document,b=c.documentElement);var d=/^([^,]+),([^,]+)({([^}]+)})?$/.exec(a),f=d[3];return!f||f===h(b)}function n(b,c,d){b=b||a.getSelection();var e=b.getAllRanges(),f=[];for(var g=0,h=e.length;g<h;++g)f[g]=k(e[g],c,d);return f.join("|")}function o(b,c,d){c?d=d||e.getWindow(c):(d=d||window,c=d.document.documentElement);var f=b.split("|"),g=a.getSelection(d),h=[];for(var i=0,j=f.length;i<j;++i)h[i]=l(f[i],c,d.document);return g.setRanges(h),g}function p(a,b,c){var d;b?d=c?c.document:e.getDocument(b):(c=c||window,b=c.document.documentElement);var f=a.split("|");for(var g=0,h=f.length;g<h;++g)if(!m(f[g],b,d))return!1;return!0}function r(a){var b=a.split(/[;,]/);for(var c=0,d=b.length,e,f;c<d;++c){e=b[c].split("=");if(e[0].replace(/^\s+/,"")==q){f=e[1];if(f)return decodeURIComponent(f.replace(/\s+$/,""))}}return null}function s(a){a=a||window;var b=r(a.document.cookie);b&&o(b,a.doc)}function t(b,c){b=b||window,c=typeof c=="object"?c:{};var d=c.expires?";expires="+c.expires.toUTCString():"",e=c.path?";path="+c.path:"",f=c.domain?";domain="+c.domain:"",g=c.secure?";secure":"",h=n(a.getSelection(b));b.document.cookie=encodeURIComponent(q)+"="+encodeURIComponent(h)+d+e+f+g}a.requireModules(["WrappedSelection","WrappedRange"]);var c="undefined";(typeof encodeURIComponent==c||typeof decodeURIComponent==c)&&b.fail("Global object is missing encodeURIComponent and/or decodeURIComponent method");var d=function(){function a(a){var b=[];for(var c=0,d=a.length,e;c<d;++c)e=a.charCodeAt(c),e<128?b.push(e):e<2048?b.push(e>>6|192,e&63|128):b.push(e>>12|224,e>>6&63|128,e&63|128);return b}function c(){var a=[];for(var b=0,c,d;b<256;++b){d=b,c=8;while(c--)(d&1)==1?d=d>>>1^3988292384:d>>>=1;a[b]=d>>>0}return a}function d(){return b||(b=c()),b}var b=null;return function(b){var c=a(b),e=-1,f=d();for(var g=0,h=c.length,i;g<h;++g)i=(e^c[g])&255,e=e>>>8^f[i];return(e^-1)>>>0}}(),e=a.dom,q="rangySerializedSelection";a.serializePosition=i,a.deserializePosition=j,a.serializeRange=k,a.deserializeRange=l,a.canDeserializeRange=m,a.serializeSelection=n,a.deserializeSelection=o,a.canDeserializeSelection=p,a.restoreSelectionFromCookie=s,a.saveSelectionCookie=t,a.getElementChecksum=h}),function(a){a.fn.tipTip=function(b){var c={activation:"hover",keepAlive:!0,maxWidth:"400px",edgeOffset:3,defaultPosition:"bottom",delay:0,fadeIn:200,fadeOut:200,attribute:"title",content:!1,enter:function(){},exit:function(){}},d=a.extend(c,b);if(a("#tiptip_holder").length<=0){var e=a('<div id="tiptip_holder" style="max-width:'+d.maxWidth+';"></div>'),f=a('<div id="tiptip_content"></div>'),g=a('<div id="tiptip_arrow"></div>');a("body").append(e.html(f).prepend(g.html('<div id="tiptip_arrow_inner"></div>')))}else{var e=a("#tiptip_holder"),f=a("#tiptip_content"),g=a("#tiptip_arrow");a("#tiptip_holder").css("max-width",d.maxWidth),a("#tiptip_content").css("top","0")}return this.each(function(){function b(){d.enter.call(this),f.html(h),e.hide().removeAttr("class").css("margin","0"),f.css("top","0"),g.removeAttr("style");var b=parseInt(c.offset().top),j=parseInt(c.offset().left),k=parseInt(c.outerWidth()),l=parseInt(c.outerHeight()),m=e.outerWidth(),n=e.outerHeight(),o=Math.round((k-m)/2),p=Math.round((l-n)/2),q=Math.round(j+o),r=Math.round(b+l+d.edgeOffset),s="",t="",u=Math.round(m-12)/2;d.defaultPosition=="bottom"?s="_bottom":d.defaultPosition=="top"?s="_top":d.defaultPosition=="left"?s="_left":d.defaultPosition=="right"&&(s="_right");var v=o+j<parseInt(a(window).scrollLeft()),w=m+j>parseInt(a(window).width());if(v&&o<0||s=="_right"&&!w||s=="_left"&&j<m+d.edgeOffset+5)s="_right",t=Math.round(n-13)/2,u=-12,q=Math.round(j+k+d.edgeOffset),r=Math.round(b+p);else if(w&&o<0||s=="_left"&&!v)s="_left",t=Math.round(n-13)/2,u=Math.round(m),q=Math.round(j-(m+d.edgeOffset+5)),r=Math.round(b+p);var x=b+l+d.edgeOffset+n+8>parseInt(a(window).height()+a(window).scrollTop()),y=b+l-(d.edgeOffset+n+8)<0;if(x||s=="_bottom"&&x||s=="_top"&&!y)s=="_top"||s=="_bottom"?s="_top":s+="_top",t=n,r=Math.round(b-(n+5+d.edgeOffset));else if(y|(s=="_top"&&y)||s=="_bottom"&&!x)s=="_top"||s=="_bottom"?s="_bottom":s+="_bottom",t=-12,r=Math.round(b+l+d.edgeOffset);if(s=="_right_top"||s=="_left_top")r+=5;else if(s=="_right_bottom"||s=="_left_bottom")r-=5;if(s=="_left_top"||s=="_left_bottom")q+=5;g.css({"margin-left":u+"px","margin-top":t+"px"}),e.css({"margin-left":q+"px","margin-top":r+"px"}).attr("class","tip"+s),i&&clearTimeout(i),i=setTimeout(function(){e.stop(!0,!0).fadeIn(d.fadeIn)},d.delay)}var c=a(this);if(d.content)var h=d.content;else var h=c.attr(d.attribute);if(h!=""){d.content||c.removeAttr(d.attribute);var i=!1;d.activation=="hover"?(c.hover(function(){b()},function(){d.keepAlive||j()}),d.keepAlive&&e.hover(function(){},function(){j()})):d.activation=="focus"?c.focus(function(){b()}).blur(function(){j()}):d.activation=="open"?b():d.activation=="click"&&c.click(function(){b()});function j(){d.exit.call(this),i&&clearTimeout(i),e.fadeOut(d.fadeOut)}}})}}(jQuery),$document=$(document),$body=$("body");var authenticityToken=$("meta[name=csrf-token]").attr("content"),authenticityTokenParameter="?authenticity_token="+encodeURIComponent(authenticityToken);$("a#cms-open-tag-window").click(function(){var a=$(this).data().planId;return openLightbox(),$("div#lightbox-content").load("/cms/topics/assign?plan_id="+a),!1}),$("#plan_item_start_book").change(function(){$("#plan_item_end_book").val($(this).val())});var corporate_id;$("a#open-add-users").click(function(){return corporate_id=$(this).data().corporateId,openLightbox(),$("div#lightbox-content").load("/admin/corporates/add_users"),!1}),$("form#admin-user-search").live("submit",function(){var a=$("input#name",$(this)).val();return $table=$("table#admin-user-results"),$table.html("<tbody><tr><th>User Id</th><th>Name</th><th></th></tr></tbody>"),$.ajax({type:"POST",url:"/admin/users/search.json"+authenticityTokenParameter+"&name="+a,success:function(a){$.each(a,function(a,b){var c=b.user,d="<tr>";d+="<td>"+c.id+"</td>",d+="<td>"+c.name+"</td>",d+='<td><a href="#" class="button add-corporates-user" data-user-id="'+c.id+'">Add User</a></td>',d+="</tr>",$("tbody",$table).append(d)})}}),!1}),$("a.add-corporates-user").live("click",function(){var a=$(this).data().userId,b={corporate_member:{user_id:a}};return $.ajax({type:"POST",url:"/admin/corporates/"+corporate_id+"/corporate_users.json"+authenticityTokenParameter,data:b,success:function(a){window.location="/admin/corporates/"+corporate_id}}),!1});var KEY={DOWN:40,ESC:27,RETURN:13,TAB:9,UP:38,W_COMMAND:91,G_COMMAND:224,CONTROL:17,C:67,V:86};$(window).load(function(){String.prototype.replaceAt=function(a,b){return this.substr(0,a)+b+this.substr(a+b.length)};var a=$("#query-gray"),b=$("#ac-list"),c=$("#ac-list li"),d,e,f=$("input#query"),g=[""],h=localStorage.getItem("ac_dictionary");h==null?$.getJSON("/json/dictionary.json",function(a){$.each(a.words,function(a,b){g.push(b.toLowerCase())});var b=JSON.stringify(g);localStorage.setItem("ac_dictionary",b)}):g=JSON.parse(h),$("input#query").live("keyup",function(c){$ac_selected=$("#ac-list .ac-selected"),f.val().length?b.show():(a.val(""),b.hide());var h=f.val().toLowerCase(),j=$.grep(g,function(a,b){return a.indexOf(h)==0});j=j.slice(0,6);if(c.keyCode==KEY.TAB)return b.hide(),!1;if(c.keyCode==KEY.UP)$("#ac-list .ac-selected").length?($(".ac-selected").prev().addClass("ac-selected"),$(".ac-selected").last().removeClass("ac-selected"),f.val($("#ac-list .ac-selected").first().text()),a.val($("#ac-list .ac-selected").first().text())):($("#ac-list li").last().addClass("ac-selected"),f.val($("#ac-list .ac-selected").first().text()),a.val($("#ac-list .ac-selected").first().text())),$(".ac-selected").length||(a.val(e),f.val(d));else if(c.keyCode==KEY.DOWN)$("#ac-list .ac-selected").length?($("#ac-list .ac-selected").next().addClass("ac-selected"),$("#ac-list .ac-selected").first().removeClass("ac-selected"),f.val($("#ac-list .ac-selected").first().text()),a.val($("#ac-list .ac-selected").first().text())):($("#ac-list li").first().addClass("ac-selected"),f.val($("#ac-list .ac-selected").first().text()),a.val($("#ac-list .ac-selected").first().text())),$("#ac-list .ac-selected").length||(a.val(e),f.val(d));else if(c.keyCode==KEY.ESC)a.val(""),b.html("").hide();else{a.val(""),b.html(""),$(j).each(function(a,c){b.append("<li>"+c+"</li>")});var k=$("#ac-list li").first(),m=k.text();for(i=0;i<f.val().length;i++)f.val().charAt(i)!=m.charAt(i)&&(m=m.replaceAt(i,m.charAt(i).toUpperCase()));d=f.val(),e=m;var n=new RegExp(d,"gi");$.each($("#ac-list li"),function(){inner=$(this).html().replace(n,function(a){return"<span>"+a+"</span>"}),$(this).html(inner)}),a.val(m),(m==f.val()||!k.length)&&b.hide()}}),$("input#query").live("keydown",function(c){if(c.keyCode==KEY.TAB){c.preventDefault();var d=$("#ac-list li").first(),e=d.text();b.hide();if($("#ac-list .ac-selected").length)f.val($("#ac-list .ac-selected").text()),a.val(""),b.html("");else if(e.length>0){b.html("");for(i=0;i<f.val().length;i++)f.val().charAt(i)!=e.charAt(i)&&(e=e.replaceAt(i,e.charAt(i).toUpperCase()));f.val(e)}}c.keyCode==KEY.RETURN&&$("form#query-form").submit();if(c.keyCode==KEY.UP)return c.preventDefault(),!1}),c.live("click",function(){lit=$(this).text(),a.val(lit),f.val(lit),b.hide(),$("form#query-form").submit()}),$home_query=$("section#home-query input#query"),$query=$("input#query"),$query_submit=$("input#query-submit"),$home_query.length&&$home_query.val().length==0&&($home_query.focus(),$query_submit.addClass("focus")),$query.focus(function(){$query_submit.addClass("focus")}),$query.blur(function(){$query_submit.removeClass("focus")})}),$("a.translation-no-access").click(function(a){return openLightbox(a),$("div#lightbox-content").load("/bible/translation_coming"),!1}),$highlights=$("div#reading > p span.highlight"),$.each($highlights,function(){var a,b;$this=$(this),b=$this.data().journalId,$.each($("span.highlight",$this),function(){a=$(this).data().journalId,a<b&&$(this).addClass("hide-highlight")})}),$fixable=$("div.fixable");if($fixable.length)var notes_top=$fixable.offset().top-parseFloat($fixable.css("marginTop").replace(/auto/,0));$(window).scroll(function(){$fixable.length&&fixedScroller()}),$focus_verse=$("span.focus-verse"),$focus_verse.length&&setTimeout(function(){$focus_verse.addClass("fade-out")},3e3),$(window).load(function(){$notes=$("ol#verse-notes-sidebar li"),$notes.each(function(){var a,b,c,d;b=1,a=$(this),d=a.data().startVerseId,$verse=$("sup#"+d),$first_verse=$("#reading sup").first(),$verse.length>0?a.css("top",$verse.position().top):a.css("top",$first_verse.position().top),c=a.position().top,$notes.each(function(){c==$(this).position().top&&a.data().journalId!=$(this).data().journalId&&(b+=1,a.addClass("multi-note"),a.attr("title",b+" notes"))})}),$notes.css("visibility","visible")}),$("a#add-bookmark").click(function(a){if(accountRequired(a)==0)return!1;$nav_ribbon=$("nav#ribbon ul"),$nav_ribbon.prepend($ajax_indicator);var b,c=$("p",$reading).first().data(),d=$("p",$reading).last().data(),e=c.book,f=c.chapter;return CHAPTER_PAGE==1?b={start_book:e,start_chapter:f,type:"chapter"}:SECTION_PAGE==1?b={start_book:e,start_chapter:f,section_id:c.sectionId,type:"section"}:VERSE_PAGE==1?b={start_book:e,start_chapter:f,start_verse:R_START_VERSE,type:"verse"}:PASSAGE_PAGE==1&&(b={start_book:e,start_chapter:R_START_CHAPTER,start_verse:R_START_VERSE,end_chapter:R_END_CHAPTER,end_verse:R_END_VERSE,type:"passage"}),$.ajax({type:"POST",url:"/ribbons"+authenticityTokenParameter,data:b,success:function(a){title=a.title,url=a.url;var b=0;$("li.bookmark",$nav_ribbon).each(function(a){title==$(this).text()&&$(this).remove(),b+=1}),b>=10&&$("li.bookmark",$nav_ribbon).last().remove(),$("span#ribbon-icon").addClass("active-ribbon"),$("li#ribbon-header").after('<li class="bookmark"><a href="'+url+'">'+title+"</a></li>"),$("div#ajax-indicator").remove()}}),!1}),$("div#bookmarks ul li").live("hover",function(){$this=$(this),$("a.delete",$this).toggle()}),$("div#bookmarks ul li a.delete").live("click",function(){return $this=$(this),$.ajax({url:$this.attr("href")+authenticityTokenParameter,type:"DELETE",complete:function(a){$this.parent().remove()}}),!1}),$("#save-css").click(function(){var a;return $this=$(this),$this.hide(),$this.after($ajax_indicator),a=$this.data().corporateId,$.ajax({type:"PUT",url:"/corporates/"+a+".json",data:{corporate:{custom_css:$("#custom_css").val()}},success:function(a){setTimeout(function(){$this.show(),$ajax_indicator.remove()},200)}}),!1}),$("#add-user-open").click(function(){return corporate_id=$(this).data().corporateId,openLightbox(),$("div#lightbox-content").load("/corporates/add_members"),!1}),$("form#user-search-email").live("submit",function(){var a=$("input#email",$(this)).val();return $table=$("table#user-results"),$table.html("<tbody><tr><th>Name</th><th></th><th></th></tr></tbody>"),$table.before($ajax_indicator).hide(),$.ajax({type:"POST",url:"/users/search_by_email.json?email="+a,success:function(a){var b,c;$ajax_indicator.remove(),$.each(a,function(a,d){b=d.user,c="<tr>",c+="<td>"+b.name+"</td>",c+='<td><a href="#" class="add-corporate-member" data-user-id="'+b.id+'">Add User</a></td>',c+="<td></td>",c+="</tr>",$("tbody",$table).append(c)}),$table.show()}}),!1});var corporate_id;$("a.add-corporate-member").live("click",function(){$this=$(this);var a,b;return b=$this.data().userId,a={corporate_member:{user_id:b}},$.ajax({type:"POST",url:"/corporates/"+corporate_id+"/members.json",data:a,success:function(a){window.location="/corporates/members"}}),!1}),$("#corporate_id").change(function(){$this=$(this);var a=$("option:selected",$this).val();$.ajax({url:"/corporates/change.json?corporate_id="+a,success:function(a){window.location=window.location.href}})}),$("a#get-explanation").live("click",function(){resetPanel(),loadingPanel();var a=text_selection;return $.ajax({type:"GET",url:"/explain/verse/MH/"+start_book+"/"+start_chapter+"/"+start_verse+".json",success:function(b){loadCommentary(a,b),$("div.panel-tab").hide(),loadStrongs(a,b)}}),!1}),$("p#strongs-list a").live("click",function(){var a=$(this).data().strongCode;return $("div#panel-content").scrollTo("td#"+a,200),!1}),$("a.strong-word").live("click",function(){var a=$(this).data().strongCode;return $.ajax({type:"GET",url:"/explain/strong/"+a+".json",success:function(a){showDefinition(a)}}),!1}),$("p#commentary-info-links a").live("click",function(){loadingPanel();var a=$("a#book-summary").data().book,b=$("a#chapter-summary").data().chapter,c="Matthew Henry Concise",d,e;return $(this).attr("id")=="book-summary"?(d="/explain/verse/MH/"+a+".json",e=a):(d="/explain/verse/MH/"+a+"/"+b+".json",e=a+" "+b),$.ajax({type:"GET",dataType:"json",url:d,success:function(c){var c=c.commentary.commentary,d=e,f="<h2>"+c.source+"</h2>";f+='<p id="commentary-info-links">',f+='<a href="'+a+'" id="book-summary">Book Summary</a>',f+='<a href="'+b+'" id="chapter-summary">Chapter Summary</a>',f+="</p>",f+="<p>"+c.text+"</p>";var g=!0,h=e;loadPanelContent(d,f,g,h)}}),!1}),$("a.get-concordance").live("click",function(){loadingPanel();var a=$(this).data(),b=a.book,c=a.chapter,d=a.verse,e=a.strongCode,f=$(this).html(),g="/explain/concordance/Strong/"+e;return $.ajax({type:"GET",dataType:"json",url:g,success:function(a){var b=a.concordances,c="Concordance",d="<h2>Concordance: "+f+"</h2>";$.each(b,function(a,b){d+='<a href="/query?query='+escape(b.concordance.location)+'">'+b.concordance.location+" - ",d+=b.concordance.word+"</a><br />"});var e=!0,g=c;loadPanelContent(c,d,e,g)}}),!1}),$(".getting-started").click(function(){openLightbox();var a='<p style="text-align: center"><iframe src="http://player.vimeo.com/video/30157925?title=0&amp;byline=0&amp;portrait=0&autoplay=1" width="660" height="363" frameborder="0" style="margin-bottom: 4px;" webkitAllowFullScreen allowFullScreen></iframe></p>';return $(this).attr("id")=="getting-started"&&(a+='<a href="#" class="button" id="hide-getting-started" style="margin: 0 5px 8px 0;">Hide this forever</a>'),$("div#lightbox-content").html(a),!1}),$("a#hide-getting-started").live("click",function(){return $.ajax({type:"POST",url:"/bible/hide_getting_started.json"+authenticityTokenParameter,complete:function(a){$("img#getting-started").remove(),closeLightbox()}}),!1}),$document.click(function(){$("nav.menu > a").removeClass("active"),$("nav.menu nav").hide(),$("#nav-pages ul li a").removeClass("active"),$("#nav-pages ul li ul").hide()}),$("#nav-pages ul > li > a").click(function(a){a.stopPropagation(),$this=$(this),$menu=$this.next("ul"),$this.toggleClass("active"),$menu.toggle()}),$("nav.menu > a").click(function(a){a.stopPropagation(),$this=$(this),$menu=$this.next("nav"),$("nav.menu > a").not($this).removeClass("active"),$this.toggleClass("active"),$menu.css("display")=="block"?$("nav.menu nav").hide():($("nav.menu nav").hide(),$menu.show());var b=$(this).attr("href");if(b=="#")return!1}),$("a#new-note").live("click",function(a){return accountRequired(a)==0?!1:(openLightbox(a),$("div#lightbox-content").load("/journals/new",function(){$("input#journal_title").focus()}),!1)}),$("form#new_journal").live("submit",function(a){category=$(this).attr("id"),$journal_text=$("textarea#journal_text"),title=$("input#journal_title").val(),text=$journal_text.val();if(text.length==0)return $("label",$journal_text.parent()).append('<span class="error"> - Cannot be blank</span>'),$journal_text.wrap('<div class="field_with_errors" />'),!1;$("input.button.save",$(this)).val("Saving...").attr("disabled","disabled");var b={journal:{start_section_id:start_section_id,start_book:start_book,start_chapter:start_chapter,start_verse:start_verse,start_paragraph_id:start_paragraph_id,end_section_id:end_section_id,end_book:end_book,end_chapter:end_chapter,end_paragraph_id:end_paragraph_id,end_verse:end_verse,category:CAT_NOTE,title:title,text:text}};return $.ajax({type:"POST",dataType:"JSON",data:b,url:"/journals.json",success:function(a){journal=a.journal,$sidebar=$("ol#verse-notes-sidebar");if($sidebar.length){journal.text.length>80&&(journal.text=journal.text.substr(0,80)),$new_journal=$("<li></li>"),$new_journal.addClass("note tip-tip-hover"),$new_journal.attr("data-start-verse-id",journal.start_verse_id),$new_journal.attr("data-title",journal.title),$new_journal.attr("data-text",journal.text),$new_journal.attr("data-journal-id",journal.id),$new_journal.attr("title",journal.text),$new_journal.html('<a href="#"></a>'),$sidebar.append($new_journal),$verse=$("sup#"+journal.start_verse_id),$first_verse=$("#reading sup").first(),$verse.length>0?$new_journal.css("top",$verse.position().top):$new_journal.css("top",$first_verse.position().top);var b=1;$notes=$("ol#verse-notes-sidebar li"),$notes.each(function(){$new_journal.position().top==$(this).position().top&&a.journal.id!=$(this).data().journalId&&(b+=1,$new_journal.addClass("multi-note"),$new_journal.attr("title",b+" notes"))}),$new_journal.css("visibility","visible"),$(".tip-tip-hover").tipTip({activation:"hover",defaultPosition:"left"})}if($("section#dashboard").length){$notes=$("ul#notes");var c="<li data-journal-id="+journal.id+' style="display:none">';c+='<a href="/journals/'+journal.id+'" class="open-journal">',c+="<strong>"+journal.title+"</strong><br />",c+='<span class="journal-time">A moment ago</span><br />',c+='<span class="gray-text">'+journal.text.substr(0,95)+"</span>",c+="</a>",c+="</li>",$notes.prepend(c),$("li",$notes).first().fadeIn(),$("li",$notes).length>5&&$("li",$notes).last().remove(),$(".journals-start-show").removeClass("journals-start-show"),$(".journals-start-hide").remove()}$("div#lightbox-content").load("/journals/"+journal.id)}}),!1}),$("form.edit_journal").live("submit",function(){return $("input.button.save",$(this)).val("Saving...").attr("disabled","disabled"),$.ajax({type:"PUT",dataType:"JSON",data:$(this).serialize(),url:$(this).attr("action"),success:function(a){var b=a.journal;b.text.length>95&&(b.text=b.text.substr(0,95)+"..."),$("ol#verse-notes-sidebar").length&&($journal=$('li[data-journal-id="'+b.id+'"]'),$('li[data-start-verse-id="'+b.start_verse_id+'"]').length==1&&$journal.attr("title",b.text),$journal.data("title",b.title),$journal.data("text",b.text),$(".tip-tip-hover").tipTip({activation:"hover",defaultPosition:"left"})),$("section#dashboard").length&&($journal=$('section#dashboard ul li[data-journal-id="'+a.journal.id+'"]'),$("strong",$journal).html(b.title),$("span.gray-text",$journal).html(b.text)),$("div#journals").length&&($journal=$('article[data-journal-id="'+a.journal.id+'"]'),$("h2",$journal).html(b.title),$("pre.journal-text",$journal).html(b.text)),closeLightbox()}}),!1});var delete_journal_id;$("div#reading > p span").live("click",function(a){if(a.target.tagName=="SUB")return!1;a.stopPropagation(),$this=$(this),delete_journal_id=$(this).data().journalId;if(delete_journal_id!=null){var b='<ul id="journal-options">';b+='<li><a href="#" id="delete-annotation">Delete</a></li>',b+="</ul>",$this.attr("title",b).tipTip({activation:"open",delay:0,defaultPosition:"top"})}}),$("a#delete-annotation").live("click",function(){return $.ajax({type:"DELETE",dataTYPE:"json",url:"/journals/"+delete_journal_id+".json?reparse=true",success:function(a){$.each(a.verses,function(a,b){$('span[data-verse-id="'+a+'"]').replaceWith(b)}),$(".tip-tip-click").tipTip({activation:"click",delay:0,keepAlive:!0})}}),!1}),$("a#delete-journal").live("click",function(){var a=$("input#journal_id").val();return $.ajax({type:"DELETE",dataTYPE:"json",url:"/journals/"+a+".json",success:function(b){$("ol#verse-notes-sidebar").length&&($('li[data-journal-id="'+a+'"]').remove(),$notes=$('li[data-start-verse-id="'+b.journal.start_verse_id+'"]'),$notes.length==1?($notes.removeClass("multi-note"),$notes.attr("title",$notes.first().data().text)):$notes.attr("title",$notes.length+" notes"),$(".tip-tip-hover").tipTip({activation:"hover",defaultPosition:"left"})),$("section#dashboard").length&&($journal=$('section#dashboard ul li[data-journal-id="'+b.journal.id+'"]'),$journal.remove()),$("div#journals").length&&($journal=$('article[data-journal-id="'+b.journal.id+'"]'),$journal.remove()),closeLightbox()}}),!1}),$("ol#verse-notes-sidebar li.note a").live("click",function(a){$this=$(this);var b,c,d,e,f;return c=$this.parent().data(),d=c.journalId,$this.parent().hasClass("multi-note")?($notes=$('ol#verse-notes-sidebar li[data-start-verse-id="'+c.startVerseId+'"]'),e=$this.parent().position().top,$all_notes=$("ol#verse-notes-sidebar li"),$all_notes.each(function(){$(this).position().top==e&&c.startVerseId!=$(this).data().startVerseId&&$notes.push($(this))}),b="",$notes.each(function(){b+='<a href="#" class="multi-note" data-journal-id="'+$(this).data().journalId+'">',b+="<strong>"+$(this).data().title+"</strong><br />",b+=$(this).data().text,b+="</a>"}),$this.tipTip({content:b,activation:"open",keepAlive:!0,defaultPosition:"left",maxWidth:"250px"})):(openLightbox(a),$("div#lightbox-content").load("/journals/"+d)),!1}),$("#tiptip_content a.multi-note").live("click",function(a){var b=$(this).data().journalId;return openLightbox(a),$("div#lightbox-content").load("/journals/"+b),!1}),$("input#cancel-form").live("click",function(a){return closeLightbox(),!1}),$("a.open-journal").live("click",function(a){if(accountRequired(a)==0)return!1;var b=$(this).attr("href");return openLightbox(a),$("div#lightbox-content").load(b),!1}),$("a#edit-journal").live("click",function(a){var b=$(this).data().journalId;return openEditJournal(b,a),!1}),$("div#journals > div.page-right > article").live("mouseenter",function(){$("a.journal-edit").hide(),$("a.journal-edit",$(this)).show()}).live("mouseleave",function(){$("a.journal-edit",$(this)).hide()}),$("div#journals article a.journal-edit").live("click",function(a){var b=$(this).data().journalId;return openEditJournal(b,a),!1});var journal_offset=10;$(window).scroll(function(){$journal_trigger=$("div#journals > div.page-right > article.scroll-trigger:in-viewport"),$journal_trigger.length>0&&loadMoreJournals()}),$(".close-lightbox").live("click",function(){return closeLightbox(),!1}),$body.live("keyup",function(a){$lightbox_container=$("div#lightbox-container"),a.keyCode==KEY.ESC&&$lightbox_container&&closeLightbox()}),$("ul#local-nav li a").click(function(){var a=$(this).data().navTarget;return $("div.page-right").hide(),$("div#"+a).show(),$("ul#local-nav li a").removeClass("active"),$(this).addClass("active"),!1}),$(window).load(function(){$panel_container=$("div#panel-container");var a=localStorage.getItem("panel_version"),b="0.1";a!=b&&localStorage.clear(),localStorage.setItem("panel_version",b);var c=localStorage.getItem("panel_open"),d=localStorage.getItem("panel_title"),e=localStorage.getItem("panel_content");if(c=="true"&&d!=null&&e!=null){var f=d,g=e;loadingPanel(),loadPanelContent(f,g)}$panel_container.jqDrag("#panel-header").jqResize("#panel-resizable"),$("a#panel-close").live("click",function(){return closePanel(),!1}),$("ul#panel-tabs-nav li.open-panel-tab a.tab-nav-title").live("click",function(){var a=$(this).parent().attr("id"),b="active-panel-tab",c="div#tab-"+a;$("#panel-content div.panel-tab").hide(),$("ul#panel-tabs-nav li.active-panel-tab").removeClass(b),$(this).parent().addClass(b),$(c).show(),$(c).children().show();var d=$("div#panel-content").html();localStorage.setItem("panel_active",a),localStorage.setItem("panel_content",d);var e=$(this).text();return $("div#panel-header h1").text(e),localStorage.setItem("panel_title",e),!1}),$("ul#panel-tabs-nav li").live("mouseleave",function(){var a=localStorage.getItem("open_tabs");checkPanelTabsWidth(a)}),$("ul#panel-tabs-nav").live("mouseleave",function(){var a=localStorage.getItem("open_tabs");checkPanelTabsWidth(a)}),$("ul#panel-tabs-nav li a.close-panel").live("click",function(){var a=localStorage.getItem("open_tabs"),b=$(this).parent().attr("id"),c="div#tab-"+b;a!=null&&(a=parseInt(a),a-=1,localStorage.setItem("open_tabs",a)),$("ul#panel-tabs-nav li.active-panel-tab").removeClass("active-panel-tab"),$("div.panel-tab").hide();var d=$(c).next(),e=$(c).prev();if(d.length){d.show(),d.children().show(),$(this).parent().next().addClass("active-panel-tab");var f=$(this).parent().next().attr("id")}else e.show(),e.children().show(),$(this).parent().prev().addClass("active-panel-tab"),f=$(this).parent().prev().attr("id");$(c).remove(),$(this).parent().remove();var g=$("ul#panel-tabs-nav li.active-panel-tab a.tab-nav-title").text(),h=g;$("div#panel-header h1").text(g),localStorage.setItem("panel_title",h);var i=$("ul#panel-tabs-nav").html(),j=$("div#panel-content").html();return localStorage.setItem("panel_tabs",i),localStorage.setItem("panel_active",f),localStorage.setItem("panel_content",j),a==0&&closePanel(),!1})}),$(".subscribe-plan").live("click",function(a){if(accountRequired(a)==0)return!1;$this=$(this);var b=$this.attr("href")+".json";return $this.hide(),$plan_option=$("a.plan-option",$this.parent()).hide(),$this.after($ajax_indicator),$.ajax({type:"POST",url:b,success:function(a){var b=a.plan.plan.category,c=a.product.plan_user.subscription_id,d=a.plan_item.plan_item.sequence_id,e="/plans/item/"+c+"/"+d;$this.text("Unsubscribe").attr("href","/plans/unsubscribe/"+c).removeClass("subscribe-plan").removeClass("button").addClass("unsubscribe-plan"),b!=PLAN_CATEGORY_DAILY_VERSE&&b!=PLAN_CATEGORY_VERSE&&$plan_option.attr("href",e).html("Read Next &#10142;"),setTimeout(function(){$ajax_indicator.remove(),$this.show(),$this.parent().parent().addClass("active"),b!=PLAN_CATEGORY_DAILY_VERSE&&b!=PLAN_CATEGORY_VERSE&&$plan_option.show(),openLightbox(),$("div#lightbox-content").load("/plans/share/"+$this.data().planId)},200)},error:function(a){$("p#notice").remove(),$this.show().parent().after('<p id="notice">'+a.responseText+"</p>"),$ajax_indicator.remove()}}),!1}),$(".unsubscribe-plan").live("click",function(a){if(accountRequired(a)==0)return!1;$this=$(this);var b=$this.attr("href")+".json";return $this.hide(),$this.after($ajax_indicator),$plan_option=$("a.plan-option",$this.parent()).hide(),$this.parent().parent().removeClass("active"),$.ajax({type:"POST",url:b,success:function(a){var b=a.plan.plan.id,c=a.plan.plan.category,d="/plans/preview/"+b;$this.text("Subscribe").attr("href","/plans/subscribe/"+b).removeClass("unsubscribe-plan").addClass("button subscribe-plan"),$plan_option.attr("href",d).html("Preview"),setTimeout(function(){$ajax_indicator.remove(),$this.show(),$plan_option.show()},200)},error:function(a){$("p#notice").remove(),$this.show().parent().after('<p id="notice">'+a.responseText+"</p>"),$ajax_indicator.remove()}}),!1}),$(".sub-cancel").click(function(){$this=$(this);var a,b,c;a=$this.data().subSetStatus,b=$this.data().subId,c="/plans/subscriptions/"+b+".json?product="+a;var d=confirm("Are you sure you want to cancel this plan?");return d==0?!1:($.ajax({type:"PUT",url:c,complete:function(a){$div=$('div[data-sub-id="'+b+'"]'),$div.fadeOut("400",function(){$div.css("visibility","hidden"),$div.show()})}}),!1)}),$("input.plan_status").change(function(){var a,b,c;$this=$(this),$label=$this.next(),b=$this.data().subId,$this.attr("checked")=="checked"?a=PLAN_USER_STATUS_ACTIVE:a=PLAN_USER_STATUS_PAUSED,c="/plans/subscriptions/"+b+".json?product="+a,$this.hide(),$label.hide(),$this.after($ajax_indicator),$.ajax(
{type:"PUT",url:c,complete:function(a){setTimeout(function(){$ajax_indicator.remove(),$this.fadeIn(),$label.fadeIn()},200)}})}),$("a.show-hidden").click(function(){return $(this).remove(),$(".hidden").fadeIn(),!1}),$("a.show-scripture").click(function(){return $(this).remove(),$(".hidden-scripture").fadeIn(),!1});var item_offset=10;$(window).scroll(function(){$item_trigger=$("div#plans-index.preview article.scroll-trigger:in-viewport"),$item_trigger.length>0&&loadMorePlanItems()}),$("a#load-more-plans").click(function(){var a="/plans?load_more=1";return $this=$(this),$this.hide(),$this.before($ajax_indicator),$plans_container=$("div#plans-grid"),$.ajax({type:"GET",url:a,success:function(a){$plans_container.append(a),$ajax_indicator.remove()}}),!1}),$("a#open-share").live("click",function(){var a="/shares/new/"+start_verse_id+"/"+end_verse_id+"?horizontal=1";return $.ajax({url:a,success:function(a){$("span.selectionBoundary").first().show().tipTip({content:a,activation:"open",keepAlive:!0,defaultPosition:"top"});try{FB.XFBML.parse()}catch(b){}$("#tiptip_holder").css("max-width","600px")}}),!1}),$("a.share-page").live("click",function(){$this=$(this);var a="/shares/new";return $this.hasClass("create-discussion")?(journal_id=$this.data().journalId,$.ajax({url:"/discussions.json",data:{journal_id:$this.data().journalId},type:"POST",success:function(b){a+="?description="+encodeURIComponent($this.data().description),a+="&title="+encodeURIComponent($this.data().title),a+="&url="+encodeURIComponent(b.discussion_url),a+="&twitter_msg="+encodeURIComponent($this.data().twitterMsg),openShareDialog($this,a)}})):(a+="?description="+encodeURIComponent($this.data().description),a+="&title="+encodeURIComponent($this.data().title),a+="&url="+encodeURIComponent($this.data().url),openShareDialog($this,a)),!1}),$(".share-option.open a").live("click",function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n;f=$("input#excerpt").val()+"\n\n",h=$("input#share_url").val(),i=$(this).data().source,k=$("input#title").val(),j="eBible - "+k,m=600,g=700,e="\n\n via eBible.com \n Digital Bible for the web, iPhone, iPad and more.",f==0&&(f=""),i=="gmail"&&(d="[Your message here]\n\n"+f+"Click on link:\n"+h+e,l="http://mail.google.com/mail/?view=cm&fs=1&tf=1&su="+escape(j)+"&body="+escape(d)),i=="aol"&&(d=k+" "+h,l="http://mail.aol.com/35141-111/aol-6/en-us/mail/compose-message.aspx?to=&subject="+escape(j)+"&body="+escape(d),g=800,m=1024),i=="yahoo"&&(d=k+" - "+h,l="http://us.mg5.mail.yahoo.com/neo/launch?.rand=1207552911&action=compose&To=&Subj="+escape(j)+"&Body="+d,g=800,m=1024),i=="hotmail"&&(d="[Your message here] \n\n"+f+"Click on link:\n"+h+e,l="http://sn104w.snt104.mail.live.com/default.aspx?rru=compose%3fsubject="+escape(j)+"&body="+escape(d),g=800,m=1024),c=document,n=window,a=n.open(l,"Compose Mail","scrollbars=auto,width="+m+",height="+g+",top=175,left=175,status=yes,resizable=yes,toolbar=yes"),document.all||(T=setTimeout("popw.focus()",50)),void 0}),$(window).scroll(function(){$(".hide-tiptip-on-scroll").remove()});var selection,start_verse_id,start_location,end_verse_id,end_location,text_selection,start_data,end_data,start_section_id,start_book,start_chapter,start_verse,start_paragraph_id,end_section_id,end_book,end_chapter,end_verse,end_paragraph_id;$("div#reading").bind("mouseup dblclick",function(){selection=rangy.getSelection().toHtml(),text_selection=rangy.getSelection().getRangeAt(0),text_selection=encodeURIComponent(text_selection);if(selection=="")return!1;insertNodeAtRange(),$start_selection_boundary=$("span.selectionBoundary").first(),$end_selection_boundary=$("span.selectionBoundary").last().addClass("last"),$start_verse=$("sup#"+start_verse_id).nextAll("span.verse").first();var a;$.browser.webkit?a=$start_verse.html().replace(/^(.*?)<span id=".*?" class="selectionBoundary" style=".*?">.*/i,"$1"):$.browser.msie?$.browser.version=="8.0"?a=$start_verse.html().replace(/^(.*?)<span style=".*?" id=.*? class=selectionBoundary>.*/i,"$1"):a=$start_verse.html().replace(/^(.*?)<span style=".*?" id=".*?" class="selectionBoundary">.*/i,"$1"):a=$start_verse.html().replace(/^(.*?)<span style=".*?" class="selectionBoundary" id=".*?">.*/i,"$1"),a=a.replace(/<sub.*?>.*?<\/sub>/gi,""),a=a.replace(/<span.*?>(.*?)<\/span>/gi,"$1"),a=a.replace(/<span.*?>|<\/span>/gi,""),a=a.replace(/\s+/gi," "),a=a.replace(/<br> /gi,""),a=a.replace(/^ /,""),$start_selection_boundary.parent().get(0).tagName=="SUP"?start_location=1:$start_selection_boundary.parent().get(0).tagName=="P"?start_location=1:$start_selection_boundary.parent().get(0).tagName=="SUB"?start_location=1:start_location=a.split(" ").length,$end_verse=$("sup#"+end_verse_id).nextAll("span.verse").first();var b;$.browser.webkit?match=$end_verse.html().match(/^(.*)<span id=".*?" class="selectionBoundary last" style=".*?">/):$.browser.msie?$.browser.version=="8.0"?match=$end_verse.html().match(/^(.*)<span style=".*?" id=.*? class="selectionBoundary last">/i):match=$end_verse.html().match(/^(.*)<span style=".*?" id=.*? class="selectionBoundary last">/i):match=$end_verse.html().match(/^(.*)<span style=".*?" class="selectionBoundary last" id=".*?">/),match!=null&&(b=match[1].replace(/\<span id=".*?" class=".*?" style=".*?"\>.*?\<\/span\>/,"")),b==null&&(b=$end_verse.html()),b=b.replace(/<sub.*?>.*?<\/sub>/gi,""),b=b.replace(/<br> /gi,""),b=b.replace(/<span.*?>(.*?)<\/span>/gi,"$1"),b=b.replace(/<span.*?>|<\/span>/gi,""),b=b.replace(/\s+/gi," "),b=$.trim(b),end_location=b.split(" ").length;var c='<ul id="journal-options">';c+='<li><a href="#" class="account-required journal-option highlight '+OPT_HIGHLIGHT_YELLOW+'">'+OPT_HIGHLIGHT_YELLOW+"</a></li>",c+='<li><a href="#" class="account-required journal-option highlight '+OPT_HIGHLIGHT_RED+'">'+OPT_HIGHLIGHT_RED+"</a></li>",c+='<li><a href="#" class="account-required journal-option highlight '+OPT_HIGHLIGHT_GREEN+'">'+OPT_HIGHLIGHT_GREEN+"</a></li>",c+='<li><a href="#" class="account-required journal-option highlight '+OPT_HIGHLIGHT_BLUE+'">'+OPT_HIGHLIGHT_BLUE+"</a></li>",c+='<li><a href="#" class="account-required journal-option highlight '+OPT_HIGHLIGHT_PURPLE+'">'+OPT_HIGHLIGHT_PURPLE+"</a></li>",c+='<li><a href="#" class="account-required journal-option highlight '+OPT_HIGHLIGHT_PINK+'">'+OPT_HIGHLIGHT_PINK+"</a></li>",c+='<li><a href="#" class="account-required journal-option">'+CAT_UNDERLINE+"</a></li>",c+='<li><a href="#" class="account-required" id="open-verse-journal">'+CAT_NOTE+"</a></li>",c+='<li><a href="#" id="get-explanation">Explain</a></li>',c+='<li><a href="#" id="open-share">Share</a></li>',c+="</ul>",$start_selection_boundary.show().attr("title",c).tipTip({activation:"open",keepAlive:!0,defaultPosition:"top"}),start_data=$("span.selectionBoundary").first().parents("p").data(),end_data=$("span.selectionBoundary").last().parents("p").data(),start_section_id=start_data.sectionId,start_book=start_data.book,start_chapter=start_data.chapter,start_verse=start_verse_id.match(/[0-9][0-9][0-9]$/),start_verse=start_verse.toString().replace(/^0+/,""),start_paragraph_id=$("sup#"+start_verse_id).parent().attr("id"),end_data==null&&(end_data=start_data),end_section_id=end_data.sectionId,end_book=end_data.book,end_chapter=end_data.chapter,end_verse=end_verse_id.match(/[0-9][0-9][0-9]$/),end_verse=end_verse.toString().replace(/^0+/,""),end_paragraph_id=$("sup#"+end_verse_id).parent().attr("id")});var savedSel=null,savedSelActiveElement=null,range;$("a.journal-option").live("click",function(a){if(accountRequired(a)==0)return!1;$this=$(this);var b=null,c=null;$this.hasClass("highlight")?b=CAT_HIGHLIGHT:b=CAT_UNDERLINE,b==CAT_HIGHLIGHT&&(c=$this.text());var d={journal:{start_section_id:start_section_id,start_book:start_book,start_chapter:start_chapter,start_verse:start_verse,start_location:start_location,start_verse_id:start_verse_id,end_section_id:end_section_id,end_book:end_book,end_chapter:end_chapter,end_verse:end_verse,end_location:end_location,end_verse_id:end_verse_id,category:b,option:c,start_paragraph_id:start_paragraph_id,end_paragraph_id:end_paragraph_id},reparse:!0};return $.ajax({type:"POST",dataType:"JSON",data:d,url:"/journals.json",success:function(a){$.each(a.verses,function(a,b){$('span[data-verse-id="'+a+'"]').replaceWith(b)}),$(".tip-tip-click").tipTip({activation:"click",delay:0,keepAlive:!0})}}),!1}),$("a#open-verse-journal").live("click",function(a){if(accountRequired(a)==0)return!1;openLightbox(a);var b=start_book+" "+start_chapter+":"+start_verse;return start_chapter!=end_chapter&&(b+=" - "+end_chapter),end_verse!=start_verse&&start_chapter==end_chapter&&(b+="-"+end_verse),start_chapter!=end_chapter&&(b+=":"+end_verse),$("div#lightbox-content").load("/journals/new",function(){$("input#journal_title").val(b),$("textarea#journal_text").focus()}),!1}),$("a#add-journal-note").click(function(a){if(accountRequired(a)==0)return!1;openLightbox(a),$first_paragraph=$("p",$reading).first(),$last_paragraph=$("p",$reading).last();var b=$first_paragraph.data(),c=$last_paragraph.data();start_book=b.book,start_chapter=b.chapter,start_section_id=b.sectionId,start_paragraph_id=null,end_book=c.book,end_chapter=c.chapter,end_section_id=c.sectionId,end_paragraph_id=null,start_verse=null,end_verse=null,start_verse_id=null,end_verse_id=null;var d=start_book+" "+start_chapter;return $("div#lightbox-content").load("/journals/new",function(){$("input#journal_title").val(d),$("textarea#journal_text").focus()}),!1}),$(".toggle-follow").click(function(){$this=$(this);var a=$(this).data(),b=a.id,c=a.following;return $this.after(ajax_indicator),c==0?$.ajax({type:"POST",url:"/users/follow/"+b+".json"+authenticityTokenParameter,complete:function(){$this.removeClass("green").addClass("red").data("following",!0).text("Unfollow"),$("div#ajax-indicator").remove()}}):c==1&&$.ajax({type:"POST",url:"/users/unfollow/"+b+".json"+authenticityTokenParameter,complete:function(){$this.removeClass("red").addClass("green").data("following",!1).text("Follow"),$("div#ajax-indicator").remove()}}),!1}),$document=$(document),$window=$(window),$body=$("body"),$reading=$("div#reading");var authenticityToken,authenticityTokenParameter;authenticityToken=$("meta[name=csrf-token]").attr("content"),authenticityTokenParameter="?authenticity_token="+encodeURIComponent(authenticityToken),$ajax_indicator=$('<div id="ajax-indicator"></div>'),$(window).load(function(){$(".tip-tip").tipTip({activation:"click"}),$(".tip-tip-hover").tipTip({activation:"hover",defaultPosition:"left"}),$(".tip-tip-hover-top").tipTip({activation:"hover",defaultPosition:"top"}),$(".tip-tip-click").tipTip({activation:"click"}),$body.click(function(){$("#tiptip_holder").hide()})}),$(".account-required").live("click",function(a){accountRequired(a)})
