text: window.Mercury={config:{toolbars:{primary:{save:["Save","Save this page"],preview:["Preview","Preview this page",{toggle:!0,mode:!0}],sep1:" ",undoredo:{undo:["Undo","Undo your last action"],redo:["Redo","Redo your last action"],sep:" "},insertLink:["Link","Insert Link",{modal:"/mercury/modals/link.html",regions:["full","markdown"]}],insertMedia:["Media","Insert Media (images and videos)",{modal:"/mercury/modals/media.html",regions:["full","markdown"]}],insertTable:["Table","Insert Table",{modal:"/mercury/modals/table.html",regions:["full","markdown"]}],insertCharacter:["Character","Special Characters",{modal:"/mercury/modals/character.html",regions:["full","markdown"]}]},editable:{_regions:["full","markdown"],predefined:{style:["Style",null,{select:"/mercury/selects/style.html",preload:!0}],sep1:" ",formatblock:["Block Format",null,{select:"/mercury/selects/formatblock.html",preload:!0}],sep2:"-"},colors:{backColor:["Background Color",null,{palette:"/mercury/palettes/backcolor.html",context:!0,preload:!0,regions:["full"]}],sep1:" ",foreColor:["Text Color",null,{palette:"/mercury/palettes/forecolor.html",context:!0,preload:!0,regions:["full"]}],sep2:"-"},decoration:{bold:["Bold",null,{context:!0}],italic:["Italicize",null,{context:!0}],overline:["Overline",null,{context:!0,regions:["full"]}],strikethrough:["Strikethrough",null,{context:!0,regions:["full"]}],underline:["Underline",null,{context:!0,regions:["full"]}],sep:"-"},script:{subscript:["Subscript",null,{context:!0}],superscript:["Superscript",null,{context:!0}],sep:"-"},justify:{justifyLeft:["Align Left",null,{context:!0,regions:["full"]}],justifyCenter:["Center",null,{context:!0,regions:["full"]}],justifyRight:["Align Right",null,{context:!0,regions:["full"]}],justifyFull:["Justify Full",null,{context:!0,regions:["full"]}],sep:"-"},list:{insertUnorderedList:["Unordered List",null,{context:!0}],insertOrderedList:["Numbered List",null,{context:!0}],sep:"-"},indent:{outdent:["Decrease Indentation"],indent:["Increase Indentation"],sep:"-"},table:{_context:!0,insertRowBefore:["Insert Table Row","Insert a table row before the cursor",{regions:["full"]}],insertRowAfter:["Insert Table Row","Insert a table row after the cursor",{regions:["full"]}],deleteRow:["Delete Table Row","Delete this table row",{regions:["full"]}],insertColumnBefore:["Insert Table Column","Insert a table column before the cursor",{regions:["full"]}],insertColumnAfter:["Insert Table Column","Insert a table column after the cursor",{regions:["full"]}],deleteColumn:["Delete Table Column","Delete this table column",{regions:["full"]}],sep1:" ",increaseColspan:["Increase Cell Columns","Increase the cells colspan"],decreaseColspan:["Decrease Cell Columns","Decrease the cells colspan and add a new cell"],increaseRowspan:["Increase Cell Rows","Increase the cells rowspan"],decreaseRowspan:["Decrease Cell Rows","Decrease the cells rowspan and add a new cell"],sep2:"-"},rules:{horizontalRule:["Horizontal Rule","Insert a horizontal rule"],sep1:"-"},formatting:{removeFormatting:["Remove Formatting","Remove formatting for the selection",{regions:["full"]}],sep2:" "},editors:{htmlEditor:["Edit HTML","Edit the HTML content",{regions:["full"]}]}},snippets:{_custom:!0,actions:{editSnippet:["Edit Snippet Settings"],sep1:" ",removeSnippet:["Remove Snippet"]}}},regions:{attribute:"data-mercury",identifier:"id",dataAttributes:[]},snippets:{method:"POST",optionsUrl:"/mercury/snippets/:name/options.html",previewUrl:"/mercury/snippets/:name/preview.html"},uploading:{enabled:!0,allowedMimeTypes:["image/jpeg","image/gif","image/png"],maxFileSize:1235242880,inputName:"image[image]",url:"/mercury/images",handler:!1},localization:{enabled:!1,preferredLocale:"swedish_chef-BORK"},behaviors:{htmlEditor:function(){Mercury.modal("/mercury/modals/htmleditor.html",{title:"HTML Editor",fullHeight:!0,handler:"htmlEditor"})}},globalBehaviors:{exit:function(){window.location.href=this.iframeSrc()},barrelRoll:function(){$("body").css({webkitTransform:"rotate(360deg)"})}},csrfSelector:'meta[name="csrf-token"]',csrfHeader:"X-CSRF-Token",editorUrlRegEx:/([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i,nonHijackableClasses:[],pasting:{sanitize:"whitelist",whitelist:{h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],table:[],thead:[],tbody:[],tfoot:[],tr:[],th:["colspan","rowspan"],td:["colspan","rowspan"],div:["class"],span:["class"],ul:[],ol:[],li:[],b:[],strong:[],i:[],em:[],u:[],strike:[],br:[],p:[],hr:[],a:["href","target","title","name"],img:["src","title","alt"]}},injectedStyles:'[data-mercury]       { min-height: 10px; outline: 1px dotted #09F } [data-mercury]:focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }[data-mercury].focus { outline: none; -webkit-box-shadow: 0 0 10px #09F, 0 0 1px #045; box-shadow: 0 0 10px #09F, 0 0 1px #045 }[data-mercury]:after { content: "."; display: block; visibility: hidden; clear: both; height: 0; overflow: hidden; }[data-mercury] table { border: 1px dotted red; min-width: 6px; }[data-mercury] th    { border: 1px dotted red; min-width: 6px; }[data-mercury] td    { border: 1px dotted red; min-width: 6px; }[data-mercury] .mercury-textarea       { border: 0; box-sizing: border-box; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; resize: none; }[data-mercury] .mercury-textarea:focus { outline: none; -webkit-box-shadow: none; -moz-box-shadow: none; box-shadow: none; }'},silent:!1,debug:!1},$(window).on("mercury:ready",function(){var t=$("#mercury_iframe").contents().find("#edit_link");Mercury.saveUrl=t.data("save-url"),t.hide()}),$(window).bind("mercury:saved",function(){window.location=window.location.href.replace(/\/editor\//i,"/")}),function(t,e){function i(e,i){var r=e.nodeName.toLowerCase();return"area"===r?(i=e.parentNode,r=i.name,e.href&&r&&"map"===i.nodeName.toLowerCase()?(e=t("img[usemap=#"+r+"]")[0],!!e&&n(e)):!1):(/input|select|textarea|button|object/.test(r)?!e.disabled:"a"==r?e.href||i:i)&&n(e)}function n(e){return!t(e).parents().andSelf().filter(function(){return"hidden"===t.curCSS(this,"visibility")||t.expr.filters.hidden(this)}).length}t.ui=t.ui||{},t.ui.version||(t.extend(t.ui,{version:"1.8.13",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}}),t.fn.extend({_focus:t.fn.focus,focus:function(e,i){return"number"==typeof e?this.each(function(){var n=this;setTimeout(function(){t(n).focus(),i&&i.call(n)},e)}):this._focus.apply(this,arguments)},scrollParent:function(){var e;return e=t.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(t.curCSS(this,"position",1))&&/(auto|scroll)/.test(t.curCSS(this,"overflow",1)+t.curCSS(this,"overflow-y",1)+t.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(t.curCSS(this,"overflow",1)+t.curCSS(this,"overflow-y",1)+t.curCSS(this,"overflow-x",1))}).eq(0),/fixed/.test(this.css("position"))||!e.length?t(document):e},zIndex:function(i){if(i!==e)return this.css("zIndex",i);if(this.length){i=t(this[0]);for(var n;i.length&&i[0]!==document;){if(n=i.css("position"),("absolute"===n||"relative"===n||"fixed"===n)&&(n=parseInt(i.css("zIndex"),10),!isNaN(n)&&0!==n))return n;i=i.parent()}}return 0},disableSelection:function(){return this.bind((t.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(t){t.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),t.each(["Width","Height"],function(i,n){function r(e,i,n,r){return t.each(o,function(){i-=parseFloat(t.curCSS(e,"padding"+this,!0))||0,n&&(i-=parseFloat(t.curCSS(e,"border"+this+"Width",!0))||0),r&&(i-=parseFloat(t.curCSS(e,"margin"+this,!0))||0)}),i}var o="Width"===n?["Left","Right"]:["Top","Bottom"],s=n.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+n]=function(i){return i===e?a["inner"+n].call(this):this.each(function(){t(this).css(s,r(this,i)+"px")})},t.fn["outer"+n]=function(e,i){return"number"!=typeof e?a["outer"+n].call(this,e):this.each(function(){t(this).css(s,r(this,e,!0,i)+"px")})}}),t.extend(t.expr[":"],{data:function(e,i,n){return!!t.data(e,n[3])},focusable:function(e){return i(e,!isNaN(t.attr(e,"tabindex")))},tabbable:function(e){var n=t.attr(e,"tabindex"),r=isNaN(n);return(r||n>=0)&&i(e,!r)}}),t(function(){var e=document.body,i=e.appendChild(i=document.createElement("div"));t.extend(i.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0}),t.support.minHeight=100===i.offsetHeight,t.support.selectstart="onselectstart"in i,e.removeChild(i).style.display="none"}),t.extend(t.ui,{plugin:{add:function(e,i,n){e=t.ui[e].prototype;for(var r in n)e.plugins[r]=e.plugins[r]||[],e.plugins[r].push([i,n[r]])},call:function(t,e,i){if((e=t.plugins[e])&&t.element[0].parentNode)for(var n=0;n<e.length;n++)t.options[e[n][0]]&&e[n][1].apply(t.element,i)}},contains:function(t,e){return document.compareDocumentPosition?16&t.compareDocumentPosition(e):t!==e&&t.contains(e)},hasScroll:function(e,i){if("hidden"===t(e).css("overflow"))return!1;i=i&&"left"===i?"scrollLeft":"scrollTop";var n=!1;return e[i]>0?!0:(e[i]=1,n=e[i]>0,e[i]=0,n)},isOverAxis:function(t,e,i){return t>e&&e+i>t},isOver:function(e,i,n,r,o,s){return t.ui.isOverAxis(e,n,o)&&t.ui.isOverAxis(i,r,s)}}))}(jQuery),function(t,e){if(t.cleanData){var i=t.cleanData;t.cleanData=function(e){for(var n,r=0;null!=(n=e[r]);r++)t(n).triggerHandler("remove");i(e)}}else{var n=t.fn.remove;t.fn.remove=function(e,i){return this.each(function(){return i||(!e||t.filter(e,[this]).length)&&t("*",this).add([this]).each(function(){t(this).triggerHandler("remove")}),n.call(t(this),e,i)})}}t.widget=function(e,i,n){var r,o=e.split(".")[0];e=e.split(".")[1],r=o+"-"+e,n||(n=i,i=t.Widget),t.expr[":"][r]=function(i){return!!t.data(i,e)},t[o]=t[o]||{},t[o][e]=function(t,e){arguments.length&&this._createWidget(t,e)},i=new i,i.options=t.extend(!0,{},i.options),t[o][e].prototype=t.extend(!0,i,{namespace:o,widgetName:e,widgetEventPrefix:t[o][e].prototype.widgetEventPrefix||e,widgetBaseClass:r},n),t.widget.bridge(e,t[o][e])},t.widget.bridge=function(i,n){t.fn[i]=function(r){var o="string"==typeof r,s=Array.prototype.slice.call(arguments,1),a=this;return r=!o&&s.length?t.extend.apply(null,[!0,r].concat(s)):r,o&&"_"===r.charAt(0)?a:(o?this.each(function(){var n=t.data(this,i),o=n&&t.isFunction(n[r])?n[r].apply(n,s):n;return o!==n&&o!==e?(a=o,!1):void 0}):this.each(function(){var e=t.data(this,i);e?e.option(r||{})._init():t.data(this,i,new n(r,this))}),a)}},t.Widget=function(t,e){arguments.length&&this._createWidget(t,e)},t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:!1},_createWidget:function(e,i){t.data(i,this.widgetName,this),this.element=t(i),this.options=t.extend(!0,{},this.options,this._getCreateOptions(),e);var n=this;this.element.bind("remove."+this.widgetName,function(){n.destroy()}),this._create(),this._trigger("create"),this._init()},_getCreateOptions:function(){return t.metadata&&t.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName),this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},widget:function(){return this.element},option:function(i,n){var r=i;if(0===arguments.length)return t.extend({},this.options);if("string"==typeof i){if(n===e)return this.options[i];r={},r[i]=n}return this._setOptions(r),this},_setOptions:function(e){var i=this;return t.each(e,function(t,e){i._setOption(t,e)}),this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&this.widget()[e?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",e),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_trigger:function(e,i,n){var r=this.options[e];if(i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),n=n||{},i.originalEvent){e=t.event.props.length;for(var o;e;)o=t.event.props[--e],i[o]=i.originalEvent[o]}return this.element.trigger(i,n),!(t.isFunction(r)&&r.call(this.element[0],i,n)===!1||i.isDefaultPrevented())}}}(jQuery),function(t,e){var i=!1;t(document).mousedown(function(t){i=!1}),t.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.bind("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).bind("click."+this.widgetName,function(i){return!0===t.data(i.target,e.widgetName+".preventClickEvent")?(t.removeData(i.target,e.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(e){if(t(this.document||document).mousedown(function(t){i=!1}),!i){this._mouseStarted&&this._mouseUp(e),this._mouseDownEvent=e;var n=this,r=1==e.which,o="string"==typeof this.options.cancel?t(e.target).parents().add(e.target).filter(this.options.cancel).length:!1;return r&&!o&&this._mouseCapture(e)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){n.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(e)!==!1,!this._mouseStarted)?(e.preventDefault(),!0):(!0===t.data(e.target,this.widgetName+".preventClickEvent")&&t.removeData(e.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return n._mouseMove(t)},this._mouseUpDelegate=function(t){return n._mouseUp(t)},t(this.document||document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),e.preventDefault(),i=!0,!0)):!0}},_mouseMove:function(e){return!t.browser.msie||(this.document||document).documentMode>=9||e.button?this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted):this._mouseUp(e)},_mouseUp:function(e){return t(this.document||document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target==this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),!1},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(t){return this.mouseDelayMet},_mouseStart:function(t){},_mouseDrag:function(t){},_mouseStop:function(t){},_mouseCapture:function(t){return!0}})}(jQuery),function(t){t.widget("ui.draggable",t.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:!0,appendTo:"parent",axis:!1,connectToSortable:!1,containment:!1,cursor:"auto",cursorAt:!1,grid:!1,handle:!1,helper:"original",iframeFix:!1,opacity:!1,refreshPositions:!1,revert:!1,revertDuration:500,scope:"default",scroll:!0,scrollSensitivity:20,scrollSpeed:20,snap:!1,snapMode:"both",snapTolerance:20,stack:!1,zIndex:!1},_create:function(){"original"!=this.options.helper||/^(?:r|a|f)/.test(this.element.css("position"))||(this.element[0].style.position="relative"),this.options.addClasses&&this.element.addClass("ui-draggable"),this.options.disabled&&this.element.addClass("ui-draggable-disabled"),this._mouseInit()},destroy:function(){return this.element.data("draggable")?(this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled"),this._mouseDestroy(),this):void 0},_mouseCapture:function(e){var i=this.options;return this.helper||i.disabled||t(e.target).is(".ui-resizable-handle")?!1:(this.handle=this._getHandle(e),this.handle?(t(i.iframeFix===!0?"iframe":i.iframeFix).each(function(){t('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1e3}).css(t(this).offset()).appendTo("body")}),!0):!1)},_mouseStart:function(e){var i=this.options;return this.helper=this._createHelper(e),this._cacheHelperProportions(),t.ui.ddmanager&&(t.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(),this.offset=this.positionAbs=this.element.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this.position=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,i.cursorAt&&this._adjustOffsetFromHelper(i.cursorAt),i.containment&&this._setContainment(),this._trigger("start",e)===!1?(this._clear(),!1):(this._cacheHelperProportions(),t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.helper.addClass("ui-draggable-dragging"),this._mouseDrag(e,!0),!0)},_mouseDrag:function(e,i){if(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),!i){if(i=this._uiHash(),this._trigger("drag",e,i)===!1)return this._mouseUp({}),!1;this.position=i.position}return this.options.axis&&"y"==this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"==this.options.axis||(this.helper[0].style.top=this.position.top+"px"),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),!1},_mouseStop:function(e){var i=!1;if(t.ui.ddmanager&&!this.options.dropBehaviour&&(i=t.ui.ddmanager.drop(this,e)),this.dropped&&(i=this.dropped,this.dropped=!1),!(this.element[0]&&this.element[0].parentNode||"original"!=this.options.helper))return!1;if("invalid"==this.options.revert&&!i||"valid"==this.options.revert&&i||this.options.revert===!0||t.isFunction(this.options.revert)&&this.options.revert.call(this.element,i)){var n=this;t(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){n._trigger("stop",e)!==!1&&n._clear()})}else this._trigger("stop",e)!==!1&&this._clear();return!1},_mouseUp:function(e){return this.options.iframeFix===!0&&t("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)}),t.ui.mouse.prototype._mouseUp.call(this,e)},cancel:function(){return this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear(),this},_getHandle:function(e){var i=this.options.handle&&t(this.options.handle,this.element).length?!1:!0;return t(this.options.handle,this.element).find("*").andSelf().each(function(){this==e.target&&(i=!0)}),i},_createHelper:function(e){var i=this.options;return e=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e])):"clone"==i.helper?this.element.clone().removeAttr("id"):this.element,e.parents("body").length||e.appendTo("parent"==i.appendTo?this.element[0].parentNode:i.appendTo),e[0]!=this.element[0]&&!/(fixed|absolute)/.test(e.css("position"))&&e.css("position","absolute"),e},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"==this.cssPosition&&this.scrollParent[0]!=document&&t.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&"html"==this.offsetParent[0].tagName.toLowerCase()&&t.browser.msie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"==this.cssPosition){var t=this.element.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e=this.options;if("parent"==e.containment&&(e.containment=this.helper[0].parentNode),("document"==e.containment||"window"==e.containment)&&(this.containment=[("document"==e.containment?0:t(window).scrollLeft())-this.offset.relative.left-this.offset.parent.left,("document"==e.containment?0:t(window).scrollTop())-this.offset.relative.top-this.offset.parent.top,("document"==e.containment?0:t(window).scrollLeft())+t("document"==e.containment?document:window).width()-this.helperProportions.width-this.margins.left,("document"==e.containment?0:t(window).scrollTop())+(t("document"==e.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(e.containment)||e.containment.constructor==Array)e.containment.constructor==Array&&(this.containment=e.containment);else{e=t(e.containment);var i=e[0];if(i){e.offset();var n="hidden"!=t(i).css("overflow");this.containment=[(parseInt(t(i).css("borderLeftWidth"),10)||0)+(parseInt(t(i).css("paddingLeft"),10)||0),(parseInt(t(i).css("borderTopWidth"),10)||0)+(parseInt(t(i).css("paddingTop"),10)||0),(n?Math.max(i.scrollWidth,i.offsetWidth):i.offsetWidth)-(parseInt(t(i).css("borderLeftWidth"),10)||0)-(parseInt(t(i).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(n?Math.max(i.scrollHeight,i.offsetHeight):i.offsetHeight)-(parseInt(t(i).css("borderTopWidth"),10)||0)-(parseInt(t(i).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom],this.relative_container=e}}},_convertPositionTo:function(e,i){i||(i=this.position),e="absolute"==e?1:-1;var n="absolute"!=this.cssPosition||this.scrollParent[0]!=document&&t.ui.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,r=/(html|body)/i.test(n[0].tagName);return{top:i.top+this.offset.relative.top*e+this.offset.parent.top*e-(t.browser.safari&&t.browser.version<526&&"fixed"==this.cssPosition?0:("fixed"==this.cssPosition?-this.scrollParent.scrollTop():r?0:n.scrollTop())*e),left:i.left+this.offset.relative.left*e+this.offset.parent.left*e-(t.browser.safari&&t.browser.version<526&&"fixed"==this.cssPosition?0:("fixed"==this.cssPosition?-this.scrollParent.scrollLeft():r?0:n.scrollLeft())*e)}},_generatePosition:function(e){var i=this.options,n="absolute"!=this.cssPosition||this.scrollParent[0]!=document&&t.ui.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,r=/(html|body)/i.test(n[0].tagName),o=e.pageX,s=e.pageY;if(this.originalPosition){var a;this.containment&&(this.relative_container?(a=this.relative_container.offset(),a=[this.containment[0]+a.left,this.containment[1]+a.top,this.containment[2]+a.left,this.containment[3]+a.top]):a=this.containment,e.pageX-this.offset.click.left<a[0]&&(o=a[0]+this.offset.click.left),e.pageY-this.offset.click.top<a[1]&&(s=a[1]+this.offset.click.top),e.pageX-this.offset.click.left>a[2]&&(o=a[2]+this.offset.click.left),e.pageY-this.offset.click.top>a[3]&&(s=a[3]+this.offset.click.top)),i.grid&&(s=this.originalPageY+Math.round((s-this.originalPageY)/i.grid[1])*i.grid[1],s=a&&(s-this.offset.click.top<a[1]||s-this.offset.click.top>a[3])?s-this.offset.click.top<a[1]?s+i.grid[1]:s-i.grid[1]:s,o=this.originalPageX+Math.round((o-this.originalPageX)/i.grid[0])*i.grid[0],o=a&&(o-this.offset.click.left<a[0]||o-this.offset.click.left>a[2])?o-this.offset.click.left<a[0]?o+i.grid[0]:o-i.grid[0]:o)}return{top:s-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(t.browser.safari&&t.browser.version<526&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollTop():r?0:n.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(t.browser.safari&&t.browser.version<526&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollLeft():r?0:n.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging"),this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1},_trigger:function(e,i,n){return n=n||this._uiHash(),t.ui.plugin.call(this,e,[i,n]),"drag"==e&&(this.positionAbs=this._convertPositionTo("absolute")),t.Widget.prototype._trigger.call(this,e,i,n)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),t.extend(t.ui.draggable,{version:"1.8.13"}),t.ui.plugin.add("draggable","connectToSortable",{start:function(e,i){var n=t(this).data("draggable"),r=n.options,o=t.extend({},i,{item:n.element});n.sortables=[],t(r.connectToSortable).each(function(){var i=t.data(this,"sortable");i&&!i.options.disabled&&(n.sortables.push({instance:i,shouldRevert:i.options.revert}),i.refreshPositions(),i._trigger("activate",e,o))})},stop:function(e,i){var n=t(this).data("draggable"),r=t.extend({},i,{item:n.element});t.each(n.sortables,function(){this.instance.isOver?(this.instance.isOver=0,n.cancelHelperRemoval=!0,this.instance.cancelHelperRemoval=!1,this.shouldRevert&&(this.instance.options.revert=!0),this.instance._mouseStop(e),this.instance.options.helper=this.instance.options._helper,"original"==n.options.helper&&this.instance.currentItem.css({top:"auto",left:"auto"})):(this.instance.cancelHelperRemoval=!1,this.instance._trigger("deactivate",e,r))})},drag:function(e,i){var n=t(this).data("draggable"),r=this;t.each(n.sortables,function(){this.instance.positionAbs=n.positionAbs,this.instance.helperProportions=n.helperProportions,this.instance.offset.click=n.offset.click,this.instance._intersectsWith(this.instance.containerCache)?(this.instance.isOver||(this.instance.isOver=1,this.instance.currentItem=t(r).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",!0),this.instance.options._helper=this.instance.options.helper,this.instance.options.helper=function(){return i.helper[0]},e.target=this.instance.currentItem[0],this.instance._mouseCapture(e,!0),this.instance._mouseStart(e,!0,!0),this.instance.offset.click.top=n.offset.click.top,this.instance.offset.click.left=n.offset.click.left,this.instance.offset.parent.left-=n.offset.parent.left-this.instance.offset.parent.left,this.instance.offset.parent.top-=n.offset.parent.top-this.instance.offset.parent.top,n._trigger("toSortable",e),n.dropped=this.instance.element,n.currentItem=n.element,this.instance.fromOutside=n),this.instance.currentItem&&this.instance._mouseDrag(e)):this.instance.isOver&&(this.instance.isOver=0,this.instance.cancelHelperRemoval=!0,this.instance.options.revert=!1,this.instance._trigger("out",e,this.instance._uiHash(this.instance)),this.instance._mouseStop(e,!0),this.instance.options.helper=this.instance.options._helper,this.instance.currentItem.remove(),this.instance.placeholder&&this.instance.placeholder.remove(),n._trigger("fromSortable",e),n.dropped=!1)})}}),t.ui.plugin.add("draggable","cursor",{start:function(){var e=t("body"),i=t(this).data("draggable").options;e.css("cursor")&&(i._cursor=e.css("cursor")),e.css("cursor",i.cursor)},stop:function(){var e=t(this).data("draggable").options;e._cursor&&t("body").css("cursor",e._cursor)}}),t.ui.plugin.add("draggable","opacity",{start:function(e,i){e=t(i.helper),i=t(this).data("draggable").options,e.css("opacity")&&(i._opacity=e.css("opacity")),e.css("opacity",i.opacity)},stop:function(e,i){e=t(this).data("draggable").options,e._opacity&&t(i.helper).css("opacity",e._opacity)}}),t.ui.plugin.add("draggable","scroll",{start:function(){var e=t(this).data("draggable");e.scrollParent[0]!=document&&"HTML"!=e.scrollParent[0].tagName&&(e.overflowOffset=e.scrollParent.offset())},drag:function(e){var i=t(this).data("draggable"),n=i.options,r=!1;i.scrollParent[0]!=document&&"HTML"!=i.scrollParent[0].tagName?(n.axis&&"x"==n.axis||(i.overflowOffset.top+i.scrollParent[0].offsetHeight-e.pageY<n.scrollSensitivity?i.scrollParent[0].scrollTop=r=i.scrollParent[0].scrollTop+n.scrollSpeed:e.pageY-i.overflowOffset.top<n.scrollSensitivity&&(i.scrollParent[0].scrollTop=r=i.scrollParent[0].scrollTop-n.scrollSpeed)),n.axis&&"y"==n.axis||(i.overflowOffset.left+i.scrollParent[0].offsetWidth-e.pageX<n.scrollSensitivity?i.scrollParent[0].scrollLeft=r=i.scrollParent[0].scrollLeft+n.scrollSpeed:e.pageX-i.overflowOffset.left<n.scrollSensitivity&&(i.scrollParent[0].scrollLeft=r=i.scrollParent[0].scrollLeft-n.scrollSpeed))):(n.axis&&"x"==n.axis||(e.pageY-t(document).scrollTop()<n.scrollSensitivity?r=t(document).scrollTop(t(document).scrollTop()-n.scrollSpeed):t(window).height()-(e.pageY-t(document).scrollTop())<n.scrollSensitivity&&(r=t(document).scrollTop(t(document).scrollTop()+n.scrollSpeed))),n.axis&&"y"==n.axis||(e.pageX-t(document).scrollLeft()<n.scrollSensitivity?r=t(document).scrollLeft(t(document).scrollLeft()-n.scrollSpeed):t(window).width()-(e.pageX-t(document).scrollLeft())<n.scrollSensitivity&&(r=t(document).scrollLeft(t(document).scrollLeft()+n.scrollSpeed)))),r!==!1&&t.ui.ddmanager&&!n.dropBehaviour&&t.ui.ddmanager.prepareOffsets(i,e)}}),t.ui.plugin.add("draggable","snap",{start:function(){var e=t(this).data("draggable"),i=e.options;e.snapElements=[],t(i.snap.constructor!=String?i.snap.items||":data(draggable)":i.snap).each(function(){var i=t(this),n=i.offset();this!=e.element[0]&&e.snapElements.push({item:this,width:i.outerWidth(),height:i.outerHeight(),top:n.top,left:n.left})})},drag:function(e,i){for(var n=t(this).data("draggable"),r=n.options,o=r.snapTolerance,s=i.offset.left,a=s+n.helperProportions.width,l=i.offset.top,u=l+n.helperProportions.height,c=n.snapElements.length-1;c>=0;c--){var h=n.snapElements[c].left,p=h+n.snapElements[c].width,d=n.snapElements[c].top,f=d+n.snapElements[c].height;if(s>h-o&&p+o>s&&l>d-o&&f+o>l||s>h-o&&p+o>s&&u>d-o&&f+o>u||a>h-o&&p+o>a&&l>d-o&&f+o>l||a>h-o&&p+o>a&&u>d-o&&f+o>u){if("inner"!=r.snapMode){var m=Math.abs(d-u)<=o,g=Math.abs(f-l)<=o,y=Math.abs(h-a)<=o,v=Math.abs(p-s)<=o;m&&(i.position.top=n._convertPositionTo("relative",{top:d-n.helperProportions.height,left:0}).top-n.margins.top),g&&(i.position.top=n._convertPositionTo("relative",{top:f,left:0}).top-n.margins.top),y&&(i.position.left=n._convertPositionTo("relative",{top:0,left:h-n.helperProportions.width}).left-n.margins.left),v&&(i.position.left=n._convertPositionTo("relative",{top:0,left:p}).left-n.margins.left)}var b=m||g||y||v;"outer"!=r.snapMode&&(m=Math.abs(d-l)<=o,g=Math.abs(f-u)<=o,y=Math.abs(h-s)<=o,v=Math.abs(p-a)<=o,m&&(i.position.top=n._convertPositionTo("relative",{top:d,left:0}).top-n.margins.top),g&&(i.position.top=n._convertPositionTo("relative",{top:f-n.helperProportions.height,left:0}).top-n.margins.top),y&&(i.position.left=n._convertPositionTo("relative",{top:0,left:h}).left-n.margins.left),v&&(i.position.left=n._convertPositionTo("relative",{top:0,left:p-n.helperProportions.width}).left-n.margins.left)),!n.snapElements[c].snapping&&(m||g||y||v||b)&&n.options.snap.snap&&n.options.snap.snap.call(n.element,e,t.extend(n._uiHash(),{snapItem:n.snapElements[c].item})),n.snapElements[c].snapping=m||g||y||v||b}else n.snapElements[c].snapping&&n.options.snap.release&&n.options.snap.release.call(n.element,e,t.extend(n._uiHash(),{snapItem:n.snapElements[c].item})),n.snapElements[c].snapping=!1;
  }}}),t.ui.plugin.add("draggable","stack",{start:function(){var e=t(this).data("draggable").options;if(e=t.makeArray(t(e.stack)).sort(function(e,i){return(parseInt(t(e).css("zIndex"),10)||0)-(parseInt(t(i).css("zIndex"),10)||0)}),e.length){var i=parseInt(e[0].style.zIndex)||0;t(e).each(function(t){this.style.zIndex=i+t}),this[0].style.zIndex=i+e.length}}}),t.ui.plugin.add("draggable","zIndex",{start:function(e,i){e=t(i.helper),i=t(this).data("draggable").options,e.css("zIndex")&&(i._zIndex=e.css("zIndex")),e.css("zIndex",i.zIndex)},stop:function(e,i){e=t(this).data("draggable").options,e._zIndex&&t(i.helper).css("zIndex",e._zIndex)}})}(jQuery),function(t,e){t.widget("ui.sortable",t.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3},_create:function(){var t=this.options;this.document=t.document,this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===t.axis||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):!1,this.offset=this.element.offset(),this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData("sortable-item");return this},_setOption:function(e,i){"disabled"===e?(this.options[e]=i,this.widget()[i?"addClass":"removeClass"]("ui-sortable-disabled")):t.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(e,i){if(this.reverting)return!1;if(this.options.disabled||"static"==this.options.type)return!1;this._refreshItems(e);var n=null,r=this;t(e.target).parents().each(function(){return t.data(this,"sortable-item")==r?(n=t(this),!1):void 0});if(t.data(e.target,"sortable-item")==r&&(n=t(e.target)),!n)return!1;if(this.options.handle&&!i){var o=!1;if(t(this.options.handle,n).find("*").andSelf().each(function(){this==e.target&&(o=!0)}),!o)return!1}return this.currentItem=n,this._removeCurrentsFromItems(),!0},_mouseStart:function(e,i,n){var r=this.options,o=this;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,r.cursorAt&&this._adjustOffsetFromHelper(r.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!=this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),r.containment&&this._setContainment(),r.cursor&&(t("body").css("cursor")&&(this._storedCursor=t("body").css("cursor")),t("body").css("cursor",r.cursor)),r.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",r.opacity)),r.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",r.zIndex)),this.scrollParent[0]!=(this.document||document)&&"HTML"!=this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!n)for(var s=this.containers.length-1;s>=0;s--)this.containers[s]._trigger("activate",e,o._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!r.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){if(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll){var i=this.options,n=!1;this.scrollParent[0]!=(this.document||document)&&"HTML"!=this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY<i.scrollSensitivity?this.scrollParent[0].scrollTop=n=this.scrollParent[0].scrollTop+i.scrollSpeed:e.pageY-this.overflowOffset.top<i.scrollSensitivity&&(this.scrollParent[0].scrollTop=n=this.scrollParent[0].scrollTop-i.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-e.pageX<i.scrollSensitivity?this.scrollParent[0].scrollLeft=n=this.scrollParent[0].scrollLeft+i.scrollSpeed:e.pageX-this.overflowOffset.left<i.scrollSensitivity&&(this.scrollParent[0].scrollLeft=n=this.scrollParent[0].scrollLeft-i.scrollSpeed)):(e.pageY-t(this.document||document).scrollTop()<i.scrollSensitivity?n=t(this.document||document).scrollTop(t(this.document||document).scrollTop()-i.scrollSpeed):t(window).height()-(e.pageY-t(this.document||document).scrollTop())<i.scrollSensitivity&&(n=t(this.document||document).scrollTop(t(this.document||document).scrollTop()+i.scrollSpeed)),e.pageX-t(this.document||document).scrollLeft()<i.scrollSensitivity?n=t(this.document||document).scrollLeft(t(this.document||document).scrollLeft()-i.scrollSpeed):t(window).width()-(e.pageX-t(this.document||document).scrollLeft())<i.scrollSensitivity&&(n=t(this.document||document).scrollLeft(t(this.document||document).scrollLeft()+i.scrollSpeed))),n!==!1&&t.ui.ddmanager&&!i.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e)}this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"==this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"==this.options.axis||(this.helper[0].style.top=this.position.top+"px");for(var r=this.items.length-1;r>=0;r--){var o=this.items[r],s=o.item[0],a=this._intersectsWithPointer(o);if(a&&s!=this.currentItem[0]&&this.placeholder[1==a?"next":"prev"]()[0]!=s&&!t.ui.contains(this.placeholder[0],s)&&("semi-dynamic"==this.options.type?!t.ui.contains(this.element[0],s):!0)){if(this.direction=1==a?"down":"up","pointer"!=this.options.tolerance&&!this._intersectsWithSides(o))break;this._rearrange(e,o),this._trigger("change",e,this._uiHash());break}}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var n=this,r=n.placeholder.offset();n.reverting=!0,t(this.helper).animate({left:r.left-this.offset.parent.left-n.margins.left+(this.offsetParent[0]==(this.document||document).body?0:this.offsetParent[0].scrollLeft),top:r.top-this.offset.parent.top-n.margins.top+(this.offsetParent[0]==(this.document||document).body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){n._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){var e=this;if(this.dragging){this._mouseUp({target:null}),"original"==this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var i=this.containers.length-1;i>=0;i--)this.containers[i]._trigger("deactivate",null,e._uiHash(this)),this.containers[i].containerCache.over&&(this.containers[i]._trigger("out",null,e._uiHash(this)),this.containers[i].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!=this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),n=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[-=_](.+)/);i&&n.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!n.length&&e.key&&n.push(e.key+"="),n.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),n=[];return e=e||{},i.each(function(){n.push(t(e.item||this).attr(e.attribute||"id")||"")}),n},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,n=this.positionAbs.top,r=n+this.helperProportions.height,o=t.left,s=o+t.width,a=t.top,l=a+t.height,u=this.offset.click.top,c=this.offset.click.left,h=n+u>a&&l>n+u&&e+c>o&&s>e+c;return"pointer"==this.options.tolerance||this.options.forcePointerForContainers||"pointer"!=this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?h:o<e+this.helperProportions.width/2&&i-this.helperProportions.width/2<s&&a<n+this.helperProportions.height/2&&r-this.helperProportions.height/2<l},_intersectsWithPointer:function(e){var i=t.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,e.top,e.height),n=t.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,e.left,e.width),r=i&&n,o=this._getDragVerticalDirection(),s=this._getDragHorizontalDirection();return r?this.floating?s&&"right"==s||"down"==o?2:1:o&&("down"==o?2:1):!1},_intersectsWithSides:function(e){var i=t.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,e.top+e.height/2,e.height),n=t.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,e.left+e.width/2,e.width),r=this._getDragVerticalDirection(),o=this._getDragHorizontalDirection();return this.floating&&o?"right"==o&&n||"left"==o&&!n:r&&("down"==r&&i||"up"==r&&!i)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!=t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!=t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor==String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){var i=[],n=[],r=this._connectWith();if(r&&e)for(var o=r.length-1;o>=0;o--)for(var s=t(r[o]),a=s.length-1;a>=0;a--){var l=t.data(s[a],"sortable");l&&l!=this&&!l.options.disabled&&n.push([t.isFunction(l.options.items)?l.options.items.call(l.element):t(l.options.items,l.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),l])}n.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]);for(var o=n.length-1;o>=0;o--)n[o][0].each(function(){i.push(this)});return t(i)},_removeCurrentsFromItems:function(){for(var t=this.currentItem.find(":data(sortable-item)"),e=0;e<this.items.length;e++)for(var i=0;i<t.length;i++)t[i]==this.items[e].item[0]&&this.items.splice(e,1)},_refreshItems:function(e){this.items=[],this.containers=[this];var i=this.items,n=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],r=this._connectWith();if(r)for(var o=r.length-1;o>=0;o--)for(var s=t(r[o]),a=s.length-1;a>=0;a--){var l=t.data(s[a],"sortable");l&&l!=this&&!l.options.disabled&&(n.push([t.isFunction(l.options.items)?l.options.items.call(l.element[0],e,{item:this.currentItem}):t(l.options.items,l.element),l]),this.containers.push(l))}for(var o=n.length-1;o>=0;o--)for(var u=n[o][1],c=n[o][0],a=0,h=c.length;h>a;a++){var p=t(c[a]);p.data("sortable-item",u),i.push({item:p,instance:u,width:0,height:0,left:0,top:0})}},refreshPositions:function(e){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());for(var i=this.items.length-1;i>=0;i--){var n=this.items[i];if(n.instance==this.currentContainer||!this.currentContainer||n.item[0]==this.currentItem[0]){var r=this.options.toleranceElement?t(this.options.toleranceElement,n.item):n.item;e||(n.width=r.outerWidth(),n.height=r.outerHeight());var o=r.offset();n.left=o.left,n.top=o.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(var i=this.containers.length-1;i>=0;i--){var o=this.containers[i].element.offset();this.containers[i].containerCache.left=o.left,this.containers[i].containerCache.top=o.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight()}return this},_createPlaceholder:function(e){var i=e||this,n=i.options;if(!n.placeholder||n.placeholder.constructor==String){var r=n.placeholder;n.placeholder={element:function(){var e=t((this.document||document).createElement(i.currentItem[0].nodeName)).addClass(r||i.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];return r||(e.style.visibility="hidden"),e},update:function(t,e){(!r||n.forcePlaceholderSize)&&(e.height()||e.height(i.currentItem.innerHeight()-parseInt(i.currentItem.css("paddingTop")||0,10)-parseInt(i.currentItem.css("paddingBottom")||0,10)),e.width()||e.width(i.currentItem.innerWidth()-parseInt(i.currentItem.css("paddingLeft")||0,10)-parseInt(i.currentItem.css("paddingRight")||0,10)))}}}i.placeholder=t(n.placeholder.element.call(i.element,i.currentItem)),i.currentItem.after(i.placeholder),n.placeholder.update(i,i.placeholder)},_contactContainers:function(e){for(var i=null,n=null,r=this.containers.length-1;r>=0;r--)if(!t.ui.contains(this.currentItem[0],this.containers[r].element[0]))if(this._intersectsWith(this.containers[r].containerCache)){if(i&&t.ui.contains(this.containers[r].element[0],i.element[0]))continue;i=this.containers[r],n=r}else this.containers[r].containerCache.over&&(this.containers[r]._trigger("out",e,this._uiHash(this)),this.containers[r].containerCache.over=0);if(i)if(1===this.containers.length)this.containers[n]._trigger("over",e,this._uiHash(this)),this.containers[n].containerCache.over=1;else if(this.currentContainer!=this.containers[n]){for(var o=1e4,s=null,a=this.positionAbs[this.containers[n].floating?"left":"top"],l=this.items.length-1;l>=0;l--)if(t.ui.contains(this.containers[n].element[0],this.items[l].item[0])){var u=this.items[l][this.containers[n].floating?"left":"top"];Math.abs(u-a)<o&&(o=Math.abs(u-a),s=this.items[l])}if(!s&&!this.options.dropOnEmpty)return;this.currentContainer=this.containers[n],s?this._rearrange(e,s,null,!0):this._rearrange(e,null,this.containers[n].element,!0),this._trigger("change",e,this._uiHash()),this.containers[n]._trigger("change",e,this._uiHash(this)),this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[n]._trigger("over",e,this._uiHash(this)),this.containers[n].containerCache.over=1}},_createHelper:function(e){var i=this.options,n=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"==i.helper?this.currentItem.clone():this.currentItem;return n.parents("body").length||t("parent"!=i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(n[0]),n[0]==this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(""==n[0].style.width||i.forceHelperSize)&&n.width(this.currentItem.width()),(""==n[0].style.height||i.forceHelperSize)&&n.height(this.currentItem.height()),n},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"==this.cssPosition&&this.scrollParent[0]!=(this.document||document)&&t.ui.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]==(this.document||document).body||this.offsetParent[0].tagName&&"html"==this.offsetParent[0].tagName.toLowerCase()&&t.browser.msie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"==this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e=this.options;if("parent"==e.containment&&(e.containment=this.helper[0].parentNode),("document"==e.containment||"window"==e.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,t("document"==e.containment?this.document||document:window).width()-this.helperProportions.width-this.margins.left,(t("document"==e.containment?this.document||document:window).height()||(this.document||document).body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),!/^(document|window|parent)$/.test(e.containment)){var i=t(e.containment)[0],n=t(e.containment).offset(),r="hidden"!=t(i).css("overflow");this.containment=[n.left+(parseInt(t(i).css("borderLeftWidth"),10)||0)+(parseInt(t(i).css("paddingLeft"),10)||0)-this.margins.left,n.top+(parseInt(t(i).css("borderTopWidth"),10)||0)+(parseInt(t(i).css("paddingTop"),10)||0)-this.margins.top,n.left+(r?Math.max(i.scrollWidth,i.offsetWidth):i.offsetWidth)-(parseInt(t(i).css("borderLeftWidth"),10)||0)-(parseInt(t(i).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,n.top+(r?Math.max(i.scrollHeight,i.offsetHeight):i.offsetHeight)-(parseInt(t(i).css("borderTopWidth"),10)||0)-(parseInt(t(i).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(e,i){i||(i=this.position);var n="absolute"==e?1:-1,r=(this.options,"absolute"!=this.cssPosition||this.scrollParent[0]!=(this.document||document)&&t.ui.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent),o=/(html|body)/i.test(r[0].tagName);return{top:i.top+this.offset.relative.top*n+this.offset.parent.top*n-(t.browser.safari&&"fixed"==this.cssPosition?0:("fixed"==this.cssPosition?-this.scrollParent.scrollTop():o?0:r.scrollTop())*n),left:i.left+this.offset.relative.left*n+this.offset.parent.left*n-(t.browser.safari&&"fixed"==this.cssPosition?0:("fixed"==this.cssPosition?-this.scrollParent.scrollLeft():o?0:r.scrollLeft())*n)}},_generatePosition:function(e){var i=this.options,n="absolute"!=this.cssPosition||this.scrollParent[0]!=(this.document||document)&&t.ui.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,r=/(html|body)/i.test(n[0].tagName);"relative"!=this.cssPosition||this.scrollParent[0]!=(this.document||document)&&this.scrollParent[0]!=this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset());var o=e.pageX,s=e.pageY;if(this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.left<this.containment[0]&&(o=this.containment[0]+this.offset.click.left),e.pageY-this.offset.click.top<this.containment[1]&&(s=this.containment[1]+this.offset.click.top),e.pageX-this.offset.click.left>this.containment[2]&&(o=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(s=this.containment[3]+this.offset.click.top)),i.grid)){var a=this.originalPageY+Math.round((s-this.originalPageY)/i.grid[1])*i.grid[1];s=this.containment&&(a-this.offset.click.top<this.containment[1]||a-this.offset.click.top>this.containment[3])?a-this.offset.click.top<this.containment[1]?a+i.grid[1]:a-i.grid[1]:a;var l=this.originalPageX+Math.round((o-this.originalPageX)/i.grid[0])*i.grid[0];o=this.containment&&(l-this.offset.click.left<this.containment[0]||l-this.offset.click.left>this.containment[2])?l-this.offset.click.left<this.containment[0]?l+i.grid[0]:l-i.grid[0]:l}return{top:s-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(t.browser.safari&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollTop():r?0:n.scrollTop()),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(t.browser.safari&&"fixed"==this.cssPosition?0:"fixed"==this.cssPosition?-this.scrollParent.scrollLeft():r?0:n.scrollLeft())}},_rearrange:function(t,e,i,n){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"==this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var r=this,o=this.counter;window.setTimeout(function(){o==r.counter&&r.refreshPositions(!n)},0)},_clear:function(e,i){this.reverting=!1;var n=[];if(!this._noFinalSort&&this.currentItem[0].parentNode&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]==this.currentItem[0]){for(var r in this._storedCSS)("auto"==this._storedCSS[r]||"static"==this._storedCSS[r])&&(this._storedCSS[r]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();if(this.fromOutside&&!i&&n.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev==this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent==this.currentItem.parent()[0]||i||n.push(function(t){this._trigger("update",t,this._uiHash())}),!t.ui.contains(this.element[0],this.currentItem[0])){i||n.push(function(t){this._trigger("remove",t,this._uiHash())});for(var r=this.containers.length-1;r>=0;r--)t.ui.contains(this.containers[r].element[0],this.currentItem[0])&&!i&&(n.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.containers[r])),n.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.containers[r])))}for(var r=this.containers.length-1;r>=0;r--)i||n.push(function(t){return function(e){t._trigger("deactivate",e,this._uiHash(this))}}.call(this,this.containers[r])),this.containers[r].containerCache.over&&(n.push(function(t){return function(e){t._trigger("out",e,this._uiHash(this))}}.call(this,this.containers[r])),this.containers[r].containerCache.over=0);if(this._storedCursor&&t("body").css("cursor",this._storedCursor),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"==this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!i){this._trigger("beforeStop",e,this._uiHash());for(var r=0;r<n.length;r++)n[r].call(this,e);this._trigger("stop",e,this._uiHash())}return!1}if(i||this._trigger("beforeStop",e,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!=this.currentItem[0]&&this.helper.remove(),this.helper=null,!i){for(var r=0;r<n.length;r++)n[r].call(this,e);this._trigger("stop",e,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}}),t.extend(t.ui.sortable,{version:"1.8.13"})}(jQuery),!function(t){t.serializeObject=function(e){var i={},n=i,r=e;return t.each(r,function(){for(var t=this.name.replace(/\[([^\]]+)?\]/g,",$1").split(","),e=t.length-1,r=0;e>r;r++)n.push?(n[n.length-1]&&n[n.length-1].constructor===Object&&void 0===n[n.length-1][t[r+1]]||n.push({}),n=n[n.length-1]):n=n[t[r]]=n[t[r]]||(""==t[r+1]?[]:{});n.push?n.push(this.value):n[t[e]]=this.value,n=i}),i},t.deserializeObject=function i(t,e,n){var r,o,s,a;if(e=e||[],"[object Object]"===Object.prototype.toString.call(t)){for(r in t)if(s=n?[n,"[",r,"]"].join(""):r,t.hasOwnProperty(r))if(a=Object.prototype.toString.call(t[r]),"[object Array]"===a)for(o=0,jsonLen=t[r].length;o<jsonLen;o++)i(t[r][o],e,s+"[]");else"[object Object]"===a?i(t[r],e,s):e.push({name:s,value:t[r]})}else e.push({name:n,value:t});return e};var e=function(){var e=!!t.fn.prop;return function(t,i){e?t.prop("checked",i):t.attr("checked",i?"checked":null)}}();t.applySerializedArray=function(i,n){var r,o=t(i).find("input,select,textarea");e(o.filter(":checked"),!1);for(var s=n.length;s--;)r=o.filter("[name='"+n[s].name+"']"),r.filter(":checkbox").length?r.val()==n[s].value&&e(r.filter(":checkbox"),!0):r.filter(":radio").length?e(r.filter("[value='"+n[s].value+"']"),!0):r.val(n[s].value)},t.applySerializedObject=function(e,i){t.applySerializedArray(e,t.deserializeObject(i))},t.fn.serializeObject=t.fn.serializeObject||function(){return t.serializeObject(this.serializeArray())},t.fn.applySerializedObject=function(e){return t.applySerializedObject(this,e),this},t.fn.applySerializedArray=function(e){return t.applySerializedArray(this,e),this}}(jQuery),jQuery.extend(jQuery.easing,{easeInSine:function(t,e,i,n,r){return-n*Math.cos(e/r*(Math.PI/2))+n+i},easeOutSine:function(t,e,i,n,r){return n*Math.sin(e/r*(Math.PI/2))+i},easeInOutSine:function(t,e,i,n,r){return-n/2*(Math.cos(Math.PI*e/r)-1)+i}}),function(t){t.toJSON=function(e){if("object"==typeof JSON&&JSON.stringify)return JSON.stringify(e);var i=typeof e;if(null===e)return"null";if("undefined"==i)return void 0;if("number"==i||"boolean"==i)return e+"";if("string"==i)return t.quoteString(e);if("object"==i){if("function"==typeof e.toJSON)return t.toJSON(e.toJSON());if(e.constructor===Date){var n=e.getUTCFullYear(),r=e.getUTCMonth()+1;10>r&&(r="0"+r);var o=e.getUTCDate();10>o&&(o="0"+o);var s=e.getUTCHours();10>s&&(s="0"+s);var a=e.getUTCMinutes();10>a&&(a="0"+a);var l=e.getUTCSeconds();10>l&&(l="0"+l);var u=e.getUTCMilliseconds();return 100>u&&(u="0"+u),10>u&&(u="0"+u),'"'+n+"-"+r+"-"+o+"T"+s+":"+a+":"+l+"."+u+'Z"'}if(e.constructor===Array){for(var c=[],h=0;h<e.length;h++)c.push(t.toJSON(e[h])||"null");return"["+c.join(",")+"]"}var p=[];for(var d in e){var f;if(i=typeof d,"number"==i)f='"'+d+'"';else{if("string"!=i)continue;f=t.quoteString(d)}if("function"!=typeof e[d]){var m=t.toJSON(e[d]);p.push(f+":"+m)}}return"{"+p.join(", ")+"}"}},t.quoteString=function(t){return t.match(e)?'"'+t.replace(e,function(t){var e=i[t];return"string"==typeof e?e:(e=t.charCodeAt(),"\\u00"+Math.floor(e/16).toString(16)+(e%16).toString(16))})+'"':'"'+t+'"'};var e=/["\\\x00-\x1f\x7f-\x9f]/g,i={"\b":"\\b","	":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"}}(jQuery),function(t){t.fn.localize=function(e){this.find("*").contents().each(function(){var i=!1,n="";return"string"==typeof this.data&&(n=t.trim(this.data),n&&(i=e.sub[n]||e.top[n])&&(this.data=i)),"IMG"==this.nodeName&&this.attributes.src&&(n=this.attributes.src.nodeValue,n&&(i=e.sub[n]||e.top[n])&&t(this).attr("src",i)),"A"==this.nodeName&&this.attributes.href&&(n=t.trim(this.attributes.href.nodeValue),n&&(i=e.sub[n]||e.top[n])&&t(this).attr("href",i)),"INPUT"==this.nodeName&&this.attributes.type&&this.attributes.value&&["submit","reset","button"].indexOf(this.attributes.type.nodeValue.toLowerCase())>-1&&(n=t.trim(this.attributes.value.nodeValue),n&&(i=e.sub[n]||e.top[n])&&t(this).attr("value",i)),this})}}(jQuery),function(t){function e(t,e,i,n){if(!t.tag.isInline&&i.length>0){i.push("\n");for(var r=0;n>r;r++)i.push("	")}}function i(n,r){var o=[],s=0==n.attributes.length,h=0,d=null,f=n.tag.render&&(0==r.allowedTags.length||t.inArray(n.tag.name,r.allowedTags)>-1)&&(0==r.removeTags.length||-1==t.inArray(n.tag.name,r.removeTags));if(!n.isRoot&&f&&(o.push("<"),o.push(n.tag.name),t.each(n.attributes,function(){if(-1==t.inArray(this.name,r.removeAttrs)){var e=new RegExp(/^(['"]?)(.*?)['"]?$/).exec(this.value),i=e[2],s=e[1]||"'";"class"==this.name&&(i=t.grep(i.split(" "),function(e){return t.grep(r.allowedClasses,function(i){return i[0]==e&&(1==i.length||t.inArray(n.tag.name,i[1])>-1)}).length>0}).join(" "),s="'"),null!=i&&(i.length>0||t.inArray(this.name,n.tag.requiredAttributes)>-1)&&(o.push(" "),o.push(this.name),o.push("="),o.push(s),o.push(i),o.push(s))}})),n.tag.isSelfClosing)f&&o.push(" />"),s=!1;else if(n.tag.isNonClosing)s=!1;else{if(!n.isRoot&&f&&o.push(">"),h=r.formatIndent++,n.tag.toProtect)d=t.htmlClean.trim(n.children.join("")).replace(/<br>/gi,"\n"),o.push(d),s=0==d.length,r.formatIndent--;else{d=[];for(var m=0;m<n.children.length;m++){var g=n.children[m],y=t.htmlClean.trim(p(u(g)?g:g.childrenToString()));c(g)&&m>0&&y.length>0&&(a(g)||l(n.children[m-1]))&&d.push(" "),u(g)?y.length>0&&d.push(y):(m!=n.children.length-1||"br"!=g.tag.name)&&(r.format&&e(g,r,d,h),d=d.concat(i(g,r)))}r.formatIndent--,d.length>0&&(r.format&&"\n"!=d[0]&&e(n,r,o,h),o=o.concat(d),s=!1)}!n.isRoot&&f&&(r.format&&e(n,r,o,h-1),o.push("</"),o.push(n.tag.name),o.push(">"))}return!n.tag.allowEmpty&&s?[]:o}function n(e,i,r){return r=r||1,t.inArray(e[e.length-r].tag.name,i)>-1?!0:e.length-(r+1)>0&&n(e,i,r+1)?(e.pop(),!0):!1}function r(t){return t?(this.tag=t,this.isRoot=!1):(this.tag=new s("root"),this.isRoot=!0),this.attributes=[],this.children=[],this.hasAttribute=function(t){for(var e=0;e<this.attributes.length;e++)if(this.attributes[e].name==t)return!0;return!1},this.childrenToString=function(){return this.children.join("")},this}function o(t,e){return this.name=t,this.value=e,this}function s(e,i,n,r){return this.name=e.toLowerCase(),this.isSelfClosing=t.inArray(this.name,v)>-1,this.isNonClosing=t.inArray(this.name,b)>-1,this.isClosing=void 0!=i&&i.length>0,this.isInline=t.inArray(this.name,d)>-1,this.disallowNest=t.inArray(this.name,f)>-1,this.requiredParent=g[t.inArray(this.name,g)+1],this.allowEmpty=t.inArray(this.name,m)>-1,this.toProtect=t.inArray(this.name,y)>-1,this.rawAttributes=n,this.allowedAttributes=w[t.inArray(this.name,w)+1],this.requiredAttributes=M[t.inArray(this.name,M)+1],this.render=r&&-1==t.inArray(this.name,r.notRenderedTags),this}function a(e){for(;h(e)&&e.children.length>0;)e=e.children[0];return u(e)&&e.length>0&&t.htmlClean.isWhitespace(e.charAt(0))}function l(e){for(;h(e)&&e.children.length>0;)e=e.children[e.children.length-1];return u(e)&&e.length>0&&t.htmlClean.isWhitespace(e.charAt(e.length-1))}function u(t){return t.constructor==String}function c(t){return u(t)||t.tag.isInline}function h(t){return t.constructor==r}function p(t){return t.replace(/&nbsp;|\n/g," ").replace(/\s\s+/g," ")}t.fn.htmlClean=function(e){return this.each(function(){this.value?this.value=t.htmlClean(this.value,e):this.innerHTML=t.htmlClean(this.innerHTML,e)})},t.htmlClean=function(e,a){a=t.extend({},t.htmlClean.defaults,a);var l,c=/<(\/)?(\w+:)?([\w]+)([^>]*)>/gi,h=/(\w+)=(".*?"|'.*?'|[^\s>]*)/gi,p=new r,d=[p],f=p;a.bodyOnly&&(l=/<body[^>]*>((\n|.)*)<\/body>/i.exec(e))&&(e=l[1]),e=e.concat("<xxx>");for(var m;l=c.exec(e);){var g=new s(l[3],l[1],l[4],a),y=e.substring(m,l.index);if(y.length>0){var v=f.children[f.children.length-1];f.children.length>0&&u(v=f.children[f.children.length-1])?f.children[f.children.length-1]=v.concat(y):f.children.push(y)}if(m=c.lastIndex,g.isClosing)n(d,[g.name])&&(d.pop(),f=d[d.length-1]);else{for(var b,w=new r(g);b=h.exec(g.rawAttributes);){if("style"==b[1].toLowerCase()&&a.replaceStyles)for(var M=!g.isInline,_=0;_<a.replaceStyles.length;_++)a.replaceStyles[_][0].test(b[2])&&(M||(g.render=!1,M=!0),f.children.push(w),d.push(w),f=w,g=new s(a.replaceStyles[_][1],"","",a),w=new r(g));null!=g.allowedAttributes&&(0==g.allowedAttributes.length||t.inArray(b[1],g.allowedAttributes)>-1)&&w.attributes.push(new o(b[1],b[2]))}t.each(g.requiredAttributes,function(){var t=this.toString();w.hasAttribute(t)||w.attributes.push(new o(t,""));
  });for(var x=0;x<a.replace.length;x++)for(var C=0;C<a.replace[x][0].length;C++){var k="string"==typeof a.replace[x][0][C];if(k&&a.replace[x][0][C]==g.name||!k&&a.replace[x][0][C].test(l)){g.render=!1,f.children.push(w),d.push(w),f=w,g=new s(a.replace[x][1],l[1],l[4],a),w=new r(g),w.attributes=f.attributes,x=a.replace.length;break}}var S=!0;if(f.isRoot||(f.tag.isInline&&!g.isInline?S=!1:f.tag.disallowNest&&g.disallowNest&&!g.requiredParent?S=!1:g.requiredParent&&(S=n(d,g.requiredParent))&&(f=d[d.length-1])),S)if(f.children.push(w),g.toProtect)for(var P=null;P=c.exec(e);){var T=new s(P[3],P[1],P[4],a);if(T.isClosing&&T.name==g.name){w.children.push(RegExp.leftContext.substring(m)),m=c.lastIndex;break}}else g.isSelfClosing||g.isNonClosing||(d.push(w),f=w)}}return i(p,a).join("")},t.htmlClean.defaults={bodyOnly:!0,allowedTags:[],removeTags:["basefont","center","dir","font","frame","frameset","iframe","isindex","menu","noframes","s","strike","u"],removeAttrs:[],allowedClasses:[],notRenderedTags:[],format:!1,formatIndent:0,replace:[[["b","big"],"strong"],[["i"],"em"]],replaceStyles:[[/font-weight:\s*bold/i,"strong"],[/font-style:\s*italic/i,"em"],[/vertical-align:\s*super/i,"sup"],[/vertical-align:\s*sub/i,"sub"]]},t.htmlClean.trim=function(e){return t.htmlClean.trimStart(t.htmlClean.trimEnd(e))},t.htmlClean.trimStart=function(e){return e.substring(t.htmlClean.trimStartIndex(e))},t.htmlClean.trimStartIndex=function(e){for(var i=0;i<e.length-1&&t.htmlClean.isWhitespace(e.charAt(i));i++);return i},t.htmlClean.trimEnd=function(e){return e.substring(0,t.htmlClean.trimEndIndex(e))},t.htmlClean.trimEndIndex=function(e){for(var i=e.length-1;i>=0&&t.htmlClean.isWhitespace(e.charAt(i));i--);return i+1},t.htmlClean.isWhitespace=function(e){return-1!=t.inArray(e,_)};var d=["a","abbr","acronym","address","b","big","br","button","caption","cite","code","del","em","font","hr","i","input","img","ins","label","legend","map","q","samp","select","small","span","strong","sub","sup","tt","var"],f=["h1","h2","h3","h4","h5","h6","p","th","td"],m=["th","td"],g=[null,"li",["ul","ol"],"dt",["dl"],"dd",["dl"],"td",["tr"],"th",["tr"],"tr",["table","thead","tbody","tfoot"],"thead",["table"],"tbody",["table"],"tfoot",["table"]],y=["script","style","pre","code"],v=["br","hr","img","link","meta"],b=["!doctype","?xml"],w=[["class"],"?xml",[],"!doctype",[],"a",["accesskey","class","href","name","title","rel","rev","type","tabindex"],"abbr",["class","title"],"acronym",["class","title"],"blockquote",["cite","class"],"button",["class","disabled","name","type","value"],"del",["cite","class","datetime"],"form",["accept","action","class","enctype","method","name"],"input",["accept","accesskey","alt","checked","class","disabled","ismap","maxlength","name","size","readonly","src","tabindex","type","usemap","value"],"img",["alt","class","height","src","width"],"ins",["cite","class","datetime"],"label",["accesskey","class","for"],"legend",["accesskey","class"],"link",["href","rel","type"],"meta",["content","http-equiv","name","scheme"],"map",["name"],"optgroup",["class","disabled","label"],"option",["class","disabled","label","selected","value"],"q",["class","cite"],"td",["colspan","rowspan"],"th",["colspan","rowspan"],"script",["src","type"],"select",["class","disabled","multiple","name","size","tabindex"],"style",["type"],"table",["class","summary"],"textarea",["accesskey","class","cols","disabled","name","readonly","rows","tabindex"]],M=[[],"img",["alt"]],_=["\xa0"," ","	","\n","\r","\f"]}(jQuery);var LiquidMetal=function(){function t(t,e){var i=t.charAt(e);return i>="A"&&"Z">=i}function e(t,e){var i=t.charAt(e-1);return" "==i||"	"==i}function i(t,e,i,n){i=Math.max(i||0,0),n=Math.min(n||t.length,t.length);for(var r=i;n>r;r++)t[r]=e;return t}var n=0,r=1,o=.8,s=.9,a=.85;return{score:function(t,e){if(0==e.length)return o;if(e.length>t.length)return n;for(var i=this.buildScoreArray(t,e),r=0,s=0;s<i.length;s++)r+=i[s];return r/i.length},buildScoreArray:function(l,u){for(var c=new Array(l.length),h=l.toLowerCase(),p=u.toLowerCase().split(""),d=-1,f=!1,m=0;m<p.length;m++){var g=p[m],y=h.indexOf(g,d+1);if(0>y)return i(c,n);0==y&&(f=!0),e(l,y)?(c[y-1]=1,i(c,a,d+1,y-1)):t(l,y)?i(c,a,d+1,y):i(c,n,d+1,y),c[y]=r,d=y}var v=f?s:o;return i(c,v,d+1),c}}}(),Showdown={};Showdown.converter=function(){var t,e,i,n=0;this.makeHtml=function(n){return t=new Array,e=new Array,i=new Array,n=n.replace(/~/g,"~T"),n=n.replace(/\$/g,"~D"),n=n.replace(/\r\n/g,"\n"),n=n.replace(/\r/g,"\n"),n="\n\n"+n+"\n\n",n=I(n),n=n.replace(/^[ \t]+$/gm,""),n=a(n),n=s(n),n=u(n),n=E(n),n=n.replace(/~D/g,"$$"),n=n.replace(/~T/g,"~"),n=n.replace(/https?\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!]/g,function(t,e){var i=n.slice(0,e),r=n.slice(e);if(i.match(/<[^>]+$/)&&r.match(/^[^>]*>/))return t;var o=t.replace(/^http:\/\/github.com\//,"https://github.com/");return"<a href='"+o+"'>"+t+"</a>"}),n=n.replace(/[a-z0-9_\-+=.]+@[a-z0-9\-]+(\.[a-z0-9-]+)+/gi,function(t){return"<a href='mailto:"+t+"'>"+t+"</a>"}),n=n.replace(/[a-f0-9]{40}/gi,function(t,e){if("undefined"==typeof GitHub||"undefined"==typeof GitHub.nameWithOwner)return t;var i=n.slice(0,e),r=n.slice(e);return i.match(/@$/)||i.match(/<[^>]+$/)&&r.match(/^[^>]*>/)?t:"<a href='http://github.com/"+GitHub.nameWithOwner+"/commit/"+t+"'>"+t.substring(0,7)+"</a>"}),n=n.replace(/([a-z0-9_\-+=.]+)@([a-f0-9]{40})/gi,function(t,e,i,r){if("undefined"==typeof GitHub||"undefined"==typeof GitHub.nameWithOwner)return t;GitHub.repoName=GitHub.repoName||o();var s=n.slice(0,r),a=n.slice(r);return s.match(/\/$/)||s.match(/<[^>]+$/)&&a.match(/^[^>]*>/)?t:"<a href='http://github.com/"+e+"/"+GitHub.repoName+"/commit/"+i+"'>"+e+"@"+i.substring(0,7)+"</a>"}),n=n.replace(/([a-z0-9_\-+=.]+\/[a-z0-9_\-+=.]+)@([a-f0-9]{40})/gi,function(t,e,i){return"<a href='http://github.com/"+e+"/commit/"+i+"'>"+e+"@"+i.substring(0,7)+"</a>"}),n=n.replace(/#([0-9]+)/gi,function(t,e,i){if("undefined"==typeof GitHub||"undefined"==typeof GitHub.nameWithOwner)return t;var r=n.slice(0,i),o=n.slice(i);return""==r||r.match(/[a-z0-9_\-+=.]$/)||r.match(/<[^>]+$/)&&o.match(/^[^>]*>/)?t:"<a href='http://github.com/"+GitHub.nameWithOwner+"/issues/#issue/"+e+"'>"+t+"</a>"}),n=n.replace(/([a-z0-9_\-+=.]+)#([0-9]+)/gi,function(t,e,i,r){if("undefined"==typeof GitHub||"undefined"==typeof GitHub.nameWithOwner)return t;GitHub.repoName=GitHub.repoName||o();var s=n.slice(0,r),a=n.slice(r);return s.match(/\/$/)||s.match(/<[^>]+$/)&&a.match(/^[^>]*>/)?t:"<a href='http://github.com/"+e+"/"+GitHub.repoName+"/issues/#issue/"+i+"'>"+t+"</a>"}),n=n.replace(/([a-z0-9_\-+=.]+\/[a-z0-9_\-+=.]+)#([0-9]+)/gi,function(t,e,i){return"<a href='http://github.com/"+e+"/issues/#issue/"+i+"'>"+t+"</a>"})};var r,o=function(){return GitHub.nameWithOwner.match(/^.+\/(.+)$/)[1]},s=function(i){var i=i.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm,function(i,n,r,o,s){return n=n.toLowerCase(),t[n]=k(r),o?o+s:(s&&(e[n]=s.replace(/"/g,"&quot;")),"")});return i},a=function(t){t=t.replace(/\n/g,"\n\n");return t=t.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,l),t=t.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,l),t=t.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,l),t=t.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,l),t=t.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,l),t=t.replace(/\n\n/g,"\n")},l=function(t,e){var n=e;return n=n.replace(/\n\n/g,"\n"),n=n.replace(/^\n/,""),n=n.replace(/\n+$/g,""),n="\n\n~K"+(i.push(n)-1)+"K\n\n"},u=function(t){t=g(t);var e=b("<hr />");return t=t.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,e),t=t.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,e),t=t.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,e),t=y(t),t=v(t),t=x(t),t=a(t),t=C(t)},c=function(t){return t=w(t),t=h(t),t=S(t),t=f(t),t=p(t),t=P(t),t=k(t),t=_(t),t=t.replace(/  +\n/g," <br />\n")},h=function(t){var e=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;return t=t.replace(e,function(t){var e=t.replace(/(.)<\/?code>(?=.)/g,"$1`");return e=H(e,"\\`*_")})},p=function(t){return t=t.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,d),t=t.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,d),t=t.replace(/(\[([^\[\]]+)\])()()()()()/g,d)},d=function(i,n,r,o,s,a,l,u){void 0==u&&(u="");var c=n,h=r,p=o.toLowerCase(),d=s,f=u;if(""==d)if(""==p&&(p=h.toLowerCase().replace(/ ?\n/g," ")),d="#"+p,void 0!=t[p])d=t[p],void 0!=e[p]&&(f=e[p]);else{if(!(c.search(/\(\s*\)$/m)>-1))return c;d=""}d=H(d,"*_");var m='<a href="'+d+'"';return""!=f&&(f=f.replace(/"/g,"&quot;"),f=H(f,"*_"),m+=' title="'+f+'"'),m+=">"+h+"</a>"},f=function(t){return t=t.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,m),t=t.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,m)},m=function(i,n,r,o,s,a,l,u){var c=n,h=r,p=o.toLowerCase(),d=s,f=u;if(f||(f=""),""==d){if(""==p&&(p=h.toLowerCase().replace(/ ?\n/g," ")),d="#"+p,void 0==t[p])return c;d=t[p],void 0!=e[p]&&(f=e[p])}h=h.replace(/"/g,"&quot;"),d=H(d,"*_");var m='<img src="'+d+'" alt="'+h+'"';return f=f.replace(/"/g,"&quot;"),f=H(f,"*_"),m+=' title="'+f+'"',m+=" />"},g=function(t){return t=t.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(t,e){return b("<h1>"+c(e)+"</h1>")}),t=t.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(t,e){return b("<h2>"+c(e)+"</h2>")}),t=t.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(t,e,i){var n=e.length;return b("<h"+n+">"+c(i)+"</h"+n+">")})},y=function(t){t+="~0";var e=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return n?t=t.replace(e,function(t,e,i){var n=e,o=i.search(/[*+-]/g)>-1?"ul":"ol";n=n.replace(/\n{2,}/g,"\n\n\n");var s=r(n);return s=s.replace(/\s+$/,""),s="<"+o+">"+s+"</"+o+">\n"}):(e=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g,t=t.replace(e,function(t,e,i,n){var o=e,s=i,a=n.search(/[*+-]/g)>-1?"ul":"ol",s=s.replace(/\n{2,}/g,"\n\n\n"),l=r(s);return l=o+"<"+a+">\n"+l+"</"+a+">\n"})),t=t.replace(/~0/,"")};r=function(t){return n++,t=t.replace(/\n{2,}$/,"\n"),t+="~0",t=t.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,function(t,e,i,n,r){var o=r,s=e;return s||o.search(/\n{2,}/)>-1?o=u(j(o)):(o=y(j(o)),o=o.replace(/\n$/,""),o=c(o)),"<li>"+o+"</li>\n"}),t=t.replace(/~0/g,""),n--,t};var v=function(t){return t+="~0",t=t.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(t,e,i){var n=e,r=i;return n=M(j(n)),n=I(n),n=n.replace(/^\n+/g,""),n=n.replace(/\n+$/g,""),n="<pre><code>"+n+"\n</code></pre>",b(n)+r}),t=t.replace(/~0/,"")},b=function(t){return t=t.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(i.push(t)-1)+"K\n\n"},w=function(t){return t=t.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(t,e,i,n,r){var o=n;return o=o.replace(/^([ \t]*)/g,""),o=o.replace(/[ \t]*$/g,""),o=M(o),e+"<code>"+o+"</code>"})},M=function(t){return t=t.replace(/&/g,"&amp;"),t=t.replace(/</g,"&lt;"),t=t.replace(/>/g,"&gt;"),t=H(t,"*_{}[]\\",!1)},_=function(t){return t=t.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>"),t=t.replace(/(\w)_(\w)/g,"$1~E95E$2"),t=t.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>")},x=function(t){return t=t.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(t,e){var i=e;return i=i.replace(/^[ \t]*>[ \t]?/gm,"~0"),i=i.replace(/~0/g,""),i=i.replace(/^[ \t]+$/gm,""),i=u(i),i=i.replace(/(^|\n)/g,"$1  "),i=i.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(t,e){var i=e;return i=i.replace(/^  /gm,"~0"),i=i.replace(/~0/g,"")}),b("<blockquote>\n"+i+"\n</blockquote>")})},C=function(t){t=t.replace(/^\n+/g,""),t=t.replace(/\n+$/g,"");for(var e=t.split(/\n{2,}/g),n=new Array,r=e.length,o=0;r>o;o++){var s=e[o];s.search(/~K(\d+)K/g)>=0?n.push(s):s.search(/\S/)>=0&&(s=c(s),s=s.replace(/\n/g,"<br />"),s=s.replace(/^([ \t]*)/g,"<p>"),s+="</p>",n.push(s))}r=n.length;for(var o=0;r>o;o++)for(;n[o].search(/~K(\d+)K/)>=0;){var a=i[RegExp.$1];a=a.replace(/\$/g,"$$$$"),n[o]=n[o].replace(/~K\d+K/,a)}return n.join("\n\n")},k=function(t){return t=t.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;"),t=t.replace(/<(?![a-z\/?\$!])/gi,"&lt;")},S=function(t){return t=t.replace(/\\(\\)/g,Q),t=t.replace(/\\([`*_{}\[\]()>#+-.!])/g,Q)},P=function(t){return t=t.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,'<a href="$1">$1</a>'),t=t.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi,function(t,e){return T(E(e))})},T=function(t){function e(t){var e="0123456789ABCDEF",i=t.charCodeAt(0);return e.charAt(i>>4)+e.charAt(15&i)}var i=[function(t){return"&#"+t.charCodeAt(0)+";"},function(t){return"&#x"+e(t)+";"},function(t){return t}];return t="mailto:"+t,t=t.replace(/./g,function(t){if("@"==t)t=i[Math.floor(2*Math.random())](t);else if(":"!=t){var e=Math.random();t=e>.9?i[2](t):e>.45?i[1](t):i[0](t)}return t}),t='<a href="'+t+'">'+t+"</a>",t=t.replace(/">.+:/g,'">')},E=function(t){return t=t.replace(/~E(\d+)E/g,function(t,e){var i=parseInt(e);return String.fromCharCode(i)})},j=function(t){return t=t.replace(/^(\t|[ ]{1,4})/gm,"~0"),t=t.replace(/~0/g,"")},I=function(t){return t=t.replace(/\t(?=\t)/g,"    "),t=t.replace(/\t/g,"~A~B"),t=t.replace(/~B(.+?)~A/g,function(t,e,i){for(var n=e,r=4-n.length%4,o=0;r>o;o++)n+=" ";return n}),t=t.replace(/~A/g,"    "),t=t.replace(/~B/g,"")},H=function(t,e,i){var n="(["+e.replace(/([\[\]\\])/g,"\\$1")+"])";i&&(n="\\\\"+n);var r=new RegExp(n,"g");return t=t.replace(r,Q)},Q=function(t,e){var i=e.charCodeAt(0);return"~E"+i+"E"}},function(){var t=[].slice;this.Mercury||(this.Mercury={}),jQuery.extend(this.Mercury,{version:"0.9.0",Regions:Mercury.Regions||{},modalHandlers:Mercury.modalHandlers||{},lightviewHandlers:Mercury.lightviewHandlers||{},dialogHandlers:Mercury.dialogHandlers||{},preloadedViews:Mercury.preloadedViews||{},ajaxHeaders:function(){var t;return t={},t[Mercury.config.csrfHeader]=Mercury.csrfToken,t},on:function(t,e){return jQuery(window).on("mercury:"+t,e)},off:function(t,e){return jQuery(window).off("mercury:"+t,e)},one:function(t,e){return jQuery(window).one("mercury:"+t,e)},trigger:function(t,e){return Mercury.log(t,e),jQuery(window).trigger("mercury:"+t,e)},notify:function(){var e;return e=1<=arguments.length?t.call(arguments,0):[],window.alert(Mercury.I18n.apply(this,e))},warn:function(t,e){var i,n,r,o;if(null==e&&(e=0),console)try{return console.warn(t)}catch(r){if(i=r,e>=1)try{return console.debug(t)}catch(o){n=o}}else if(e>=1)return Mercury.notify(t)},deprecated:function(t){return console&&console.trace&&(t=t+" -- "+console.trace()),Mercury.warn("deprecated: "+t,1)},log:function(){var t,e;if(Mercury.debug&&console){if("hide:toolbar"===arguments[0]||"show:toolbar"===arguments[0])return;try{return console.debug(arguments)}catch(e){t=e}}},locale:function(){var t,e,i;return Mercury.determinedLocale?Mercury.determinedLocale:(Mercury.config.localization.enabled&&(t=[],navigator.language&&(t=navigator.language.toString().split("-")).length&&(i=Mercury.I18n[t[0]]||{},e=t.length>1?i["_"+t[1].toUpperCase()+"_"]:void 0),Mercury.I18n[t[0]]||(t=Mercury.config.localization.preferredLocale.split("-"),i=Mercury.I18n[t[0]]||{},e=t.length>1?i["_"+t[1].toUpperCase()+"_"]:void 0)),Mercury.determinedLocale={top:i||{},sub:e||{}})},I18n:function(){var e,i,n,r;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],i=Mercury.locale(),r=(i.sub[n]||i.top[n]||n||"").toString(),e.length?r.printf.apply(r,e):r}})}.call(this),function(){String.prototype.titleize=function(){return this[0].toUpperCase()+this.slice(1)},String.prototype.toHex=function(){return"#"===this[0]?this:this.replace(/rgb(a)?\(([0-9|%]+)[\s|,]?\s?([0-9|%]+)[\s|,]?\s?([0-9|%]+)[\s|,]?\s?([0-9|.|%]+\s?)?\)/gi,function(t,e,i,n,r,o){return"#"+parseInt(i).toHex()+parseInt(n).toHex()+parseInt(r).toHex()})},String.prototype.regExpEscape=function(){var t,e;return e=["/",".","*","+","?","|","(",")","[","]","{","}","\\"],t=new RegExp("(\\"+e.join("|\\")+")","g"),this.replace(t,"\\$1")},String.prototype.printf=function(){var t,e,i,n,r,o,s,a,l,u;for(i=this.split("%"),u=i[0],l=/^([sdf])([\s\S%]*)$/,s=0,n=r=0,o=i.length;o>r;n=++r)if(e=i[n],a=l.exec(e),0!==n&&a&&null!==arguments[n]){switch(t=arguments[n-1-s],a[1]){case"s":u+=t;break;case"d":case"i":u+=parseInt(t.toString(),10);break;case"f":u+=parseFloat(t)}u+=a[2]}else n>1&&(s+=2,u+="%"+e);return u},Number.prototype.toHex=function(){var t;return t=this.toString(16).toUpperCase(),t[1]?t:"0"+t},Number.prototype.toBytes=function(){var t,e;for(t=parseInt(this),e=0;t>1023;)t/=1024,e+=1;return e?""+t.toFixed(2)+[""," kb"," Mb"," Gb"," Tb"," Pb"," Eb"][e]:t+" bytes"}}.call(this),function(){this.Mercury.PageEditor=function(){function t(t,e){var i;if(this.saveUrl=null!=t?t:null,this.options=null!=e?e:{},window.mercuryInstance)throw Mercury.I18n("Mercury.PageEditor can only be instantiated once.");this.options.visible!==!1&&"false"!==this.options.visible&&(this.options.visible=!0),this.visible=this.options.visible,this.options.saveDataType===!1||this.options.saveDataType||(this.options.saveDataType="json"),window.mercuryInstance=this,this.regions=[],this.initializeInterface(),(i=jQuery(Mercury.config.csrfSelector).attr("content"))&&(Mercury.csrfToken=i)}return t.prototype.initializeInterface=function(){var t,e;return this.focusableElement=jQuery("<input>",{"class":"mercury-focusable",type:"text"}).appendTo(null!=(t=this.options.appendTo)?t:"body"),this.iframe=jQuery("<iframe>",{id:"mercury_iframe",name:"mercury_iframe","class":"mercury-iframe",frameborder:"0",src:"about:blank"}),this.iframe.appendTo(null!=(e=jQuery(this.options.appendTo).get(0))?e:"body"),this.toolbar=new Mercury.Toolbar(jQuery.extend(!0,{},this.options,this.options.toolbarOptions)),this.statusbar=new Mercury.Statusbar(jQuery.extend(!0,{},this.options,this.options.statusbarOptions)),this.resize(),this.iframe.one("load",function(t){return function(){return t.bindEvents()}}(this)),this.iframe.on("load",function(t){return function(){return t.initializeFrame()}}(this)),this.loadIframeSrc(null)},t.prototype.initializeFrame=function(){var t,e,i;try{if(this.iframe.data("loaded"))return;return this.iframe.data("loaded",!0),this.document=jQuery(this.iframe.get(0).contentWindow.document),jQuery('<style mercury-styles="true">').html(Mercury.config.injectedStyles).appendTo(this.document.find("head")),i=this.iframe.get(0).contentWindow,jQuery.globalEval=function(t){return t&&/\S/.test(t)?(i.execScript||function(t){return i.eval.call(i,t)})(t):void 0},i.Mercury=Mercury,window.History&&History.Adapter&&(i.History=History),this.bindDocumentEvents(),this.resize(),this.initializeRegions(),this.finalizeInterface(),Mercury.trigger("ready"),i.jQuery&&i.jQuery(i).trigger("mercury:ready"),i.Event&&i.Event.fire&&i.Event.fire(i,"mercury:ready"),i.onMercuryReady&&i.onMercuryReady(),this.iframe.css({visibility:"visible"})}catch(e){return t=e,Mercury.notify("Mercury.PageEditor failed to load: %s\n\nPlease try refreshing.",t)}},t.prototype.initializeRegions=function(){var t,e,i,n,r,o,s,a;for(this.regions=[],r=jQuery("["+Mercury.config.regions.attribute+"]",this.document),t=0,i=r.length;i>t;t++)s=r[t],this.buildRegion(jQuery(s));if(this.visible){for(o=this.regions,a=[],e=0,n=o.length;n>e;e++){if(s=o[e],s.focus){s.focus();break}a.push(void 0)}return a}},t.prototype.buildRegion=function(t){var e,i;if(t.data("region"))t=t.data("region");else{if(i=(t.attr(Mercury.config.regions.attribute)||("function"==typeof(e=Mercury.config.regions).determineType?e.determineType(t):void 0)||"unknown").titleize(),"Unknown"===i||!Mercury.Regions[i])throw Mercury.I18n('Region type is malformed, no data-type provided, or "%s" is unknown for the "%s" region.',i,t.attr("id")||"unknown");if(!Mercury.Regions[i].supported)return Mercury.notify("Mercury.Regions.%s is unsupported in this client. Supported browsers are %s.",i,Mercury.Regions[i].supportedText),!1;t=new Mercury.Regions[i](t,this.iframe.get(0).contentWindow),this.previewing&&t.togglePreview()}return this.regions.push(t)},t.prototype.finalizeInterface=function(){var t;return this.santizerElement=jQuery("<div>",{id:"mercury_sanitizer",contenteditable:"true",style:"position:fixed;width:100px;height:100px;min-width:0;top:0;left:-100px;opacity:0;overflow:hidden"}),this.santizerElement.appendTo(null!=(t=this.options.appendTo)?t:this.document.find("body")),this.snippetToolbar&&this.snippetToolbar.release(),this.snippetToolbar=new Mercury.SnippetToolbar(this.document),this.hijackLinksAndForms(),this.visible?void 0:Mercury.trigger("mode",{mode:"preview"})},t.prototype.bindDocumentEvents=function(){return this.document.on("mousedown",function(t){return Mercury.trigger("hide:dialogs"),Mercury.region&&jQuery(t.target).closest("["+Mercury.config.regions.attribute+"]").get(0)!==Mercury.region.element.get(0)?Mercury.trigger("unfocus:regions"):void 0}),jQuery(this.document).bind("keydown",function(t){return function(t){return(t.ctrlKey||t.metaKey)&&83===t.keyCode?(Mercury.trigger("action",{action:"save"}),t.preventDefault()):void 0}}(this))},t.prototype.bindEvents=function(){return Mercury.on("initialize:frame",function(t){return function(){return setTimeout(t.initializeFrame,100)}}(this)),Mercury.on("focus:frame",function(t){return function(){return t.iframe.focus()}}(this)),Mercury.on("focus:window",function(t){return function(){return setTimeout(function(){return t.focusableElement.focus()},10)}}(this)),Mercury.on("toggle:interface",function(t){return function(){return t.toggleInterface()}}(this)),Mercury.on("reinitialize",function(t){return function(){return t.initializeRegions()}}(this)),Mercury.on("mode",function(t){return function(e,i){return"preview"===i.mode?t.previewing=!t.previewing:void 0}}(this)),Mercury.on("action",function(t){return function(e,i){var n;return n=Mercury.config.globalBehaviors[i.action]||t[i.action],"function"==typeof n?(e.preventDefault(),n.call(t,i)):void 0}}(this)),jQuery(window).on("resize",function(t){return function(){return t.resize()}}(this)),jQuery(window).bind("keydown",function(t){return function(t){return(t.ctrlKey||t.metaKey)&&83===t.keyCode?(Mercury.trigger("action",{action:"save"}),t.preventDefault()):void 0}}(this)),window.onbeforeunload=this.beforeUnload},t.prototype.toggleInterface=function(){return this.visible?(this.visible=!1,this.toolbar.hide(),this.statusbar.hide(),this.previewing||Mercury.trigger("mode",{mode:"preview"}),this.previewing=!0,this.resize()):(this.visible=!0,this.iframe.animate({top:this.toolbar.height(!0)},200,"easeInOutSine",function(t){return function(){return t.resize()}}(this)),this.toolbar.show(),this.statusbar.show(),Mercury.trigger("mode",{mode:"preview"}),this.previewing=!1)},t.prototype.resize=function(){var t,e,i;return i=jQuery(window).width(),t=this.statusbar.top(),e=this.toolbar.top()+this.toolbar.height(),Mercury.displayRect={top:e,left:0,width:i,height:t-e,fullHeight:t},this.iframe.css({top:e,left:0,height:t-e}),Mercury.trigger("resize")},t.prototype.iframeSrc=function(t,e){var i;return null==t&&(t=null),null==e&&(e=!1),t=(null!=t?t:window.location.href).replace(null!=(i=Mercury.config).editorUrlRegEx?i.editorUrlRegEx:i.editorUrlRegEx=/([http|https]:\/\/.[^\/]*)\/editor\/?(.*)/i,"$1/$2"),t=t.replace(/[\?|\&]mercury_frame=true/gi,"").replace(/\&_=\d+/gi,"").replace(/#$/,""),e?""+t+(t.indexOf("?")>-1?"&":"?")+"mercury_frame=true&_="+(new Date).getTime():t},t.prototype.loadIframeSrc=function(t){return this.document&&this.document.off(),this.iframe.data("loaded",!1),this.iframe.get(0).contentWindow.document.location.href=this.iframeSrc(t,!0)},t.prototype.hijackLinksAndForms=function(){var t,e,i,n,r,o,s,a,l,u;for(a=jQuery("a, form",this.document),u=[],i=0,o=a.length;o>i;i++){for(e=a[i],n=!1,l=Mercury.config.nonHijackableClasses||[],r=0,s=l.length;s>r;r++)t=l[r],jQuery(e).hasClass(t)&&(n=!0);n||""!==e.target&&"_self"!==e.target||jQuery(e).closest("["+Mercury.config.regions.attribute+"]").length?u.push(void 0):u.push(jQuery(e).attr("target","_parent"))}return u},t.prototype.beforeUnload=function(){return Mercury.changes&&!Mercury.silent?Mercury.I18n("You have unsaved changes.  Are you sure you want to leave without saving them first?"):null},t.prototype.getRegionByName=function(t){var e,i,n,r;for(n=this.regions,e=0,i=n.length;i>e;e++)if(r=n[e],r.name===t)return r;return null},t.prototype.save=function(t){var e,i,n,r,o,s;return s=null!=(r=null!=(o=this.saveUrl)?o:Mercury.saveUrl)?r:this.iframeSrc(),e=this.serialize(),e={content:e},"POST"===this.options.saveMethod?i="POST":(i="PUT",e._method=i),Mercury.log("saving",e),n={headers:Mercury.ajaxHeaders(),type:i,dataType:this.options.saveDataType,data:e,success:function(e){return function(e){return Mercury.changes=!1,Mercury.trigger("saved",e),"function"==typeof t?t():void 0}}(this),error:function(t){return function(t){return Mercury.trigger("save_failed",t),Mercury.notify("Mercury was unable to save to the url: %s",s)}}(this)},"form"!==this.options.saveStyle&&(n.data=jQuery.toJSON(e),n.contentType="application/json"),jQuery.ajax(s,n)},t.prototype.serialize=function(){var t,e,i,n,r;for(r={},i=this.regions,t=0,e=i.length;e>t;t++)n=i[t],r[n.name]=n.serialize();return r},t}()}.call(this),function(){this.Mercury.HistoryBuffer=function(){function t(t){this.maxLength=null!=t?t:200,this.index=0,this.stack=[],this.markerRegExp=/<em class="mercury-marker"><\/em>/g}return t.prototype.push=function(t){if("string"===jQuery.type(t)){if(this.stack[this.index]&&this.stack[this.index].replace(this.markerRegExp,"")===t.replace(this.markerRegExp,""))return}else if("object"===jQuery.type(t)&&t.html&&this.stack[this.index]&&this.stack[this.index].html===t.html)return;return this.stack=this.stack.slice(0,this.index+1),this.stack.push(t),this.stack.length>this.maxLength&&this.stack.shift(),this.index=this.stack.length-1},t.prototype.undo=function(){return this.index<1?null:(this.index-=1,this.stack[this.index])},t.prototype.redo=function(){return this.index>=this.stack.length-1?null:(this.index+=1,this.stack[this.index])},t}()}.call(this),function(){this.Mercury.tableEditor=function(t,e,i){return Mercury.tableEditor.load(t,e,i),Mercury.tableEditor},jQuery.extend(Mercury.tableEditor,{load:function(t,e,i){return this.table=t,this.cell=e,this.cellContent=null!=i?i:"",this.row=this.cell.parent("tr"),this.columnCount=this.getColumnCount(),this.rowCount=this.getRowCount()},addColumnBefore:function(){return this.addColumn("before")},addColumnAfter:function(){return this.addColumn("after")},addColumn:function(t){var e,i,n,r,o,s,a,l,u,c,h,p;for(null==t&&(t="after"),p=this.cellSignatureFor(this.cell),l=this.table.find("tr"),u=[],e=n=0,r=l.length;r>n;e=++n)c=l[e],h=1,o="after"===t?{right:p.right}:{left:p.left},(s=this.findCellByOptionsFor(c,o))?(a=jQuery("<"+s.cell.get(0).tagName+">").html(this.cellContent),this.setRowspanFor(a,s.height),"before"===t?s.cell.before(a):s.cell.after(a),u.push(e+=s.height-1)):(i=this.findCellByIntersectionFor(c,p))?u.push(this.setColspanFor(i.cell,i.width+1)):u.push(void 0);return u},removeColumn:function(){var t,e,i,n,r,o,s,a,l,u,c,h,p,d,f,m;if(m=this.cellSignatureFor(this.cell),!(m.width>1)){for(p=[],t=[],h=this.table.find("tr"),i=r=0,a=h.length;a>r;i=++r)f=h[i],(c=this.findCellByOptionsFor(f,{left:m.left,width:m.width}))?(p.push(c.cell),i+=c.height-1):(n=this.findCellByIntersectionFor(f,m))&&t.push(n.cell);for(o=0,l=p.length;l>o;o++)e=p[o],jQuery(e).remove();for(d=[],s=0,u=t.length;u>s;s++)e=t[s],d.push(this.setColspanFor(e,this.colspanFor(e)-1));return d}},addRowBefore:function(){return this.addRow("before")},addRowAfter:function(){return this.addRow("after")},addRow:function(t){var e,i,n,r,o,s,a,l,u,c,h,p,d,f,m,g,y;for(null==t&&(t="after"),h=jQuery("<tr>"),(y=this.rowspanFor(this.cell))>1&&"after"===t&&(this.row=jQuery(this.row.nextAll("tr")[y-2])),i=0,d=this.row.find("th, td"),r=0,a=d.length;a>r;r++)e=d[r],n=this.colspanFor(e),c=jQuery("<"+e.tagName+">").html(this.cellContent),this.setColspanFor(c,n),i+=n,(y=this.rowspanFor(e))>1&&"after"===t?this.setRowspanFor(e,y+1):h.append(c);if(i<this.columnCount)for(g=0,f=this.row.prevAll("tr"),o=0,l=f.length;l>o;o++)for(p=f[o],g+=1,m=jQuery(p).find("td[rowspan], th[rowspan]"),s=0,u=m.length;u>s;s++)e=m[s],y=this.rowspanFor(e),y-1>=g&&"before"===t?this.setRowspanFor(e,y+1):y-1>=g&&"after"===t&&(y-1===g?(c=jQuery("<"+e.tagName+">").html(this.cellContent),this.setColspanFor(c,this.colspanFor(e)),h.append(c)):this.setRowspanFor(e,y+1));return"before"===t?this.row.before(h):this.row.after(h)},removeRow:function(){var t,e,i,n,r,o,s,a,l,u,c,h,p,d,f,m,g,y,v,b,w,M,_,x;for(_=!0,f=0,p=0,m=this.row.find("td, th"),n=0,s=m.length;s>n;n++)e=m[n],M=this.rowspanFor(e),f&&M!==f&&(_=!1),(p>M||!p)&&(p=M),f=M;if(_||!(this.rowspanFor(this.cell)>p)){if(p>1)for(i=r=0,g=p-2;g>=0?g>=r:r>=g;i=g>=0?++r:--r)jQuery(this.row.nextAll("tr")[i]).remove();for(y=this.row.find("td[rowspan], th[rowspan]"),o=0,a=y.length;a>o;o++)e=y[o],x=this.cellSignatureFor(e),x.height!==p&&(h=this.findCellByOptionsFor(this.row.nextAll("tr")[p-1],{left:x.left,forceAdjacent:!0}))&&(this.setRowspanFor(e,this.rowspanFor(e)-this.rowspanFor(this.cell)),"before"===h.direction?h.cell.before(jQuery(e).clone()):h.cell.after(jQuery(e).clone()));if(this.columnsFor(this.row.find("td, th"))<this.columnCount)for(w=0,v=this.row.prevAll("tr"),c=0,l=v.length;l>c;c++)for(t=v[c],w+=1,b=jQuery(t).find("td[rowspan], th[rowspan]"),d=0,u=b.length;u>d;d++)e=b[d],M=this.rowspanFor(e),M>w&&this.setRowspanFor(e,M-this.rowspanFor(this.cell));return this.row.remove()}},increaseColspan:function(){var t;return t=this.cell.next("td, th"),!t.length||this.rowspanFor(t)!==this.rowspanFor(this.cell)||this.cellIndexFor(t)>this.cellIndexFor(this.cell)+this.colspanFor(this.cell)?void 0:(this.setColspanFor(this.cell,this.colspanFor(this.cell)+this.colspanFor(t)),t.remove())},decreaseColspan:function(){var t;if(1!==this.colspanFor(this.cell))return this.setColspanFor(this.cell,this.colspanFor(this.cell)-1),t=jQuery("<"+this.cell.get(0).tagName+">").html(this.cellContent),this.setRowspanFor(t,this.rowspanFor(this.cell)),this.cell.after(t)},increaseRowspan:function(){var t,e,i;return i=this.cellSignatureFor(this.cell),e=this.row.nextAll("tr")[i.height-1],e&&(t=this.findCellByOptionsFor(e,{left:i.left,width:i.width}))?(this.setRowspanFor(this.cell,i.height+t.height),t.cell.remove()):void 0},decreaseRowspan:function(){var t,e,i,n;return n=this.cellSignatureFor(this.cell),1!==n.height?(i=this.row.nextAll("tr")[n.height-2],(t=this.findCellByOptionsFor(i,{left:n.left,forceAdjacent:!0}))?(e=jQuery("<"+this.cell.get(0).tagName+">").html(this.cellContent),this.setColspanFor(e,this.colspanFor(this.cell)),this.setRowspanFor(this.cell,n.height-1),"before"===t.direction?t.cell.before(e):t.cell.after(e)):void 0):void 0},getColumnCount:function(){return this.columnsFor(this.table.find("thead tr:first-child, tbody tr:first-child, tfoot tr:first-child").first().find("td, th"))},getRowCount:function(){return this.table.find("tr").length},cellIndexFor:function(t){var e,i,n,r,o,s,a,l,u,c,h,p;if(t=jQuery(t),h=t.parent("tr"),n=this.columnsFor(h.find("td, th")),r=this.columnsFor(t.prevAll("td, th")),n<this.columnCount)for(p=0,u=h.prevAll("tr"),o=0,a=u.length;a>o;o++)for(i=u[o],p+=1,c=jQuery(i).find("td[rowspan], th[rowspan]"),s=0,l=c.length;l>s;s++)e=c[s],this.rowspanFor(e)>p&&this.cellIndexFor(e)<=r&&(r+=this.colspanFor(e));return r},cellSignatureFor:function(t){var e;return e={cell:jQuery(t)},e.left=this.cellIndexFor(t),e.width=this.colspanFor(t),e.height=this.rowspanFor(t),e.right=e.left+e.width,e},findCellByOptionsFor:function(t,e){var i,n,r,o,s,a;for(s=jQuery(t).find("td, th"),n=0,r=s.length;r>n;n++){if(i=s[n],a=this.cellSignatureFor(i),"undefined"!=typeof e.right&&a.right===e.right)return a;if("undefined"!=typeof e.left)if(e.width){if(a.left===e.left&&a.width===e.width)return a}else if(e.forceAdjacent){if(e.forceAdjacent&&a.left>e.left)return o=jQuery(i).prev("td, th"),o.length?(a=this.cellSignatureFor(o),a.direction="after"):a.direction="before",a}else if(a.left===e.left)return a}return e.forceAdjacent?(a.direction="after",a):null},findCellByIntersectionFor:function(t,e){var i,n,r,o,s;for(o=jQuery(t).find("td, th"),n=0,r=o.length;r>n;n++)if(i=o[n],s=this.cellSignatureFor(i),s.right-e.left>=0&&s.right>e.left)return s;return null},columnsFor:function(t){var e,i,n,r;for(i=0,n=0,r=t.length;r>n;n++)e=t[n],i+=this.colspanFor(e);return i},colspanFor:function(t){return parseInt(jQuery(t).attr("colspan"))||1},rowspanFor:function(t){
  return parseInt(jQuery(t).attr("rowspan"))||1},setColspanFor:function(t,e){return jQuery(t).attr("colspan",e>1?e:null)},setRowspanFor:function(t,e){return jQuery(t).attr("rowspan",e>1?e:null)}})}.call(this),function(){this.Mercury.Dialog=function(){function t(t,e,i){this.url=t,this.name=e,this.options=null!=i?i:{},this.button=this.options["for"],this.build(),this.bindEvents(),this.preload()}return t.prototype.build=function(){var t;return this.element=jQuery("<div>",{"class":"mercury-dialog mercury-"+this.name+"-dialog loading",style:"display:none"}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body")},t.prototype.bindEvents=function(){return this.element.on("mousedown",function(t){return t.stopPropagation()})},t.prototype.preload=function(){return this.options.preload?this.load():void 0},t.prototype.toggle=function(){return this.visible?this.hide():this.show()},t.prototype.resize=function(){return this.show()},t.prototype.show=function(){return Mercury.trigger("hide:dialogs",this),this.visible=!0,this.loaded?(this.element.css({width:"auto",height:"auto"}),this.position(this.visible)):this.position(),this.appear()},t.prototype.position=function(t){},t.prototype.appear=function(){return this.element.css({display:"block",opacity:0}),this.element.animate({opacity:.95},200,"easeInOutSine",function(t){return function(){return t.loaded?void 0:t.load(function(){return t.resize()})}}(this))},t.prototype.hide=function(){return this.element.hide(),this.visible=!1},t.prototype.load=function(t){return this.url?Mercury.preloadedViews[this.url]?(this.loadContent(Mercury.preloadedViews[this.url]),Mercury.dialogHandlers[this.name]&&Mercury.dialogHandlers[this.name].call(this),t?t():void 0):jQuery.ajax(this.url,{success:function(e){return function(i){return e.loadContent(i),Mercury.dialogHandlers[e.name]&&Mercury.dialogHandlers[e.name].call(e),t?t():void 0}}(this),error:function(t){return function(){return t.hide(),t.button&&t.button.removeClass("pressed"),Mercury.notify('Mercury was unable to load %s for the "%s" dialog.',t.url,t.name)}}(this)}):void 0},t.prototype.loadContent=function(t){return this.loaded=!0,this.element.removeClass("loading"),this.element.html(t),Mercury.config.localization.enabled?this.element.localize(Mercury.locale()):void 0},t}()}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Palette=function(e){function i(t,e,n){this.url=t,this.name=e,this.options=null!=n?n:{},i.__super__.constructor.apply(this,arguments)}return t(i,e),i.prototype.build=function(){var t;return this.element=jQuery("<div>",{"class":"mercury-palette mercury-"+this.name+"-palette loading",style:"display:none"}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body")},i.prototype.bindEvents=function(){return Mercury.on("hide:dialogs",function(t){return function(e,i){return i!==t?t.hide():void 0}}(this)),i.__super__.bindEvents.apply(this,arguments)},i.prototype.position=function(t){var e,i;return this.element.css({top:0,left:0,display:"block",visibility:"hidden"}),e=this.button.position(),i=this.element.width(),e.left+i>jQuery(window).width()&&(e.left=e.left-i+this.button.width()),this.element.css({top:e.top+this.button.height(),left:e.left,display:t?"block":"none",visibility:"visible"})},i}(Mercury.Dialog)}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Select=function(e){function i(t,e,n){this.url=t,this.name=e,this.options=null!=n?n:{},i.__super__.constructor.apply(this,arguments)}return t(i,e),i.prototype.build=function(){var t;return this.element=jQuery("<div>",{"class":"mercury-select mercury-"+this.name+"-select loading",style:"display:none"}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body")},i.prototype.bindEvents=function(){return Mercury.on("hide:dialogs",function(t){return function(e,i){return i!==t?t.hide():void 0}}(this)),this.element.on("mousedown",function(t){return function(t){return t.preventDefault()}}(this)),i.__super__.bindEvents.apply(this,arguments)},i.prototype.position=function(t){var e,i,n,r,o,s,a;return this.element.css({top:0,left:0,display:"block",visibility:"hidden"}),s=this.button.position(),n=this.element.width(),i=this.element.height(),e=jQuery(document).height(),a=s.top+this.button.height()/2-i/2,a<s.top-100&&(a=s.top-100),20>a&&(a=20),r=this.loaded?"auto":i,a+i>=e-20&&(r=e-a-20),o=s.left,o+n>jQuery(window).width()&&(o=o-n+this.button.width()),this.element.css({top:a,left:o,height:r,display:t?"block":"none",visibility:"visible"})},i}(Mercury.Dialog)}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Panel=function(e){function i(t,e,n){this.url=t,this.name=e,this.options=null!=n?n:{},i.__super__.constructor.apply(this,arguments)}return t(i,e),i.prototype.build=function(){var t;return this.element=jQuery("<div>",{"class":"mercury-panel loading",style:"display:none;"}),this.titleElement=jQuery("<h1><span>"+Mercury.I18n(this.options.title)+"</span></h1>").appendTo(this.element),this.paneElement=jQuery("<div>",{"class":"mercury-panel-pane"}).appendTo(this.element),this.options.closeButton&&jQuery("<a/>",{"class":"mercury-panel-close"}).appendTo(this.titleElement).css({opacity:0}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body")},i.prototype.bindEvents=function(){return Mercury.on("resize",function(t){return function(){return t.position(t.visible)}}(this)),Mercury.on("hide:panels",function(t){return function(e,i){return i!==t?(t.button.removeClass("pressed"),t.hide()):void 0}}(this)),this.titleElement.find(".mercury-panel-close").on("click",function(t){return t.preventDefault(),Mercury.trigger("hide:panels")}),this.element.on("mousedown",function(t){return t.stopPropagation()}),this.element.on("ajax:beforeSend",function(t){return function(e,i,n){return n.success=function(e){return t.loadContent(e),t.resize()}}}(this)),i.__super__.bindEvents.apply(this,arguments)},i.prototype.show=function(){return Mercury.trigger("hide:panels",this),i.__super__.show.apply(this,arguments)},i.prototype.resize=function(){var t,e,i;return this.titleElement.find(".mercury-panel-close").css({opacity:0}),this.paneElement.css({display:"none"}),i=this.element.width(),this.paneElement.css({visibility:"hidden",width:"auto",display:"block"}),e=this.element.width(),this.paneElement.css({visibility:"visible",display:"none"}),t=this.element.offset(),this.element.animate({left:t.left-(e-i),width:e},200,"easeInOutSine",function(t){return function(){return t.titleElement.find(".mercury-panel-close").animate({opacity:1},100),t.paneElement.css({display:"block",width:e}),jQuery(t.paneElement.find(".focusable").get(0)).focus(),t.makeDraggable()}}(this)),this.visible?void 0:this.hide()},i.prototype.position=function(t){var e,i,n,r,o;return this.element.css({display:"block",visibility:"hidden"}),r=this.element.offset(),e=this.element.width(),i=Mercury.displayRect.height-16,o=i-this.titleElement.outerHeight(),this.paneElement.css({height:o,overflowY:30>o?"hidden":"auto"}),this.moved||(n=Mercury.displayRect.width-e-20),8>=n&&(n=8),(this.pinned||e+r.left>Mercury.displayRect.width-20)&&(n=Mercury.displayRect.width-e-20),this.element.css({top:Mercury.displayRect.top+8,left:n,height:i,display:t?"block":"none",visibility:"visible"}),this.makeDraggable(),t?void 0:this.element.hide()},i.prototype.loadContent=function(t){return this.loaded=!0,this.element.removeClass("loading"),this.paneElement.css({visibility:"hidden"}),this.paneElement.html(t),Mercury.config.localization.enabled?this.paneElement.localize(Mercury.locale()):void 0},i.prototype.makeDraggable=function(){var t;return t=this.element.width(),this.element.draggable({handle:"h1 span",axis:"x",opacity:.7,scroll:!1,addClasses:!1,iframeFix:!0,containment:[8,0,Mercury.displayRect.width-t-20,0],stop:function(e){return function(){var i;return i=e.element.offset().left,e.moved=!0,e.pinned=i>Mercury.displayRect.width-t-30?!0:!1,!0}}(this)})},i}(Mercury.Dialog)}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};this.Mercury.modal=function(t,e){var i;return null==e&&(e={}),i=new Mercury.Modal(t,e),i.show(),i},this.Mercury.Modal=function(){function e(e,i){this.url=e,this.options=null!=i?i:{},this.hide=t(this.hide,this)}return e.prototype.show=function(t,e){var i;return null==t&&(t=null),null==e&&(e=null),this.url=t||this.url,this.options=e||this.options,(i=this.options).minWidth||(i.minWidth=400),this.options.ujsHandling!==!1&&(this.options.ujsHandling=!0),Mercury.trigger("focus:window"),this.initializeModal(),this.visible?this.update():this.appear(),this.options.content?setTimeout(function(t){return function(){return t.loadContent(t.options.content)}}(this),500):void 0},e.prototype.initializeModal=function(){return this.initialized?void 0:(this.build(),this.bindEvents(),this.initialized=!0)},e.prototype.build=function(){var t,e;return this.element=jQuery(".mercury-modal"),this.overlay=jQuery(".mercury-modal-overlay"),this.element.get(0)&&this.overlay.get(0)||(this.element=jQuery("<div>",{"class":"mercury-modal loading"}),this.element.html('<h1 class="mercury-modal-title"><span></span><a>&times;</a></h1>'),this.element.append('<div class="mercury-modal-content-container"><div class="mercury-modal-content"></div></div>'),this.overlay=jQuery("<div>",{"class":"mercury-modal-overlay"}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body"),this.overlay.appendTo(null!=(e=jQuery(this.options.appendTo).get(0))?e:"body")),this.titleElement=this.element.find(".mercury-modal-title"),this.contentContainerElement=this.element.find(".mercury-modal-content-container"),this.contentElement=this.element.find(".mercury-modal-content")},e.prototype.bindEvents=function(){return Mercury.on("refresh",function(t){return function(){return t.resize(!0)}}(this)),Mercury.on("resize",function(t){return function(){return t.position()}}(this)),this.overlay.on("click",function(t){return function(){return t.options.allowHideUsingOverlay?t.hide():void 0}}(this)),this.titleElement.find("a").on("click",function(t){return function(){return t.hide()}}(this)),this.options.ujsHandling&&this.element.on("ajax:beforeSend",function(t){return function(e,i,n){return n.success=function(e){return t.loadContent(e)}}}(this)),jQuery(document).on("keydown",function(t){return function(e){return 27===e.keyCode&&t.visible?t.hide():void 0}}(this))},e.prototype.appear=function(){return this.showing=!0,this.position(),this.overlay.show(),this.overlay.animate({opacity:1},200,"easeInOutSine",function(t){return function(){return t.element.css({top:-t.element.height()}),t.setTitle(),t.element.show(),t.element.animate({top:0},200,"easeInOutSine",function(){return t.visible=!0,t.showing=!1,t.load()})}}(this))},e.prototype.resize=function(t){var e,i,n,r;return n=t?"visible":"hidden",i=this.titleElement.outerHeight(),r=this.contentElement.outerWidth(),this.contentPane&&this.contentPane.css({height:"auto"}),this.contentElement.css({height:"auto",visibility:n,display:"block"}),e=this.contentElement.outerHeight()+i,r<this.options.minWidth&&(r=this.options.minWidth),(e>Mercury.displayRect.fullHeight||this.options.fullHeight)&&(e=Mercury.displayRect.fullHeight),this.element.stop().animate({left:(Mercury.displayRect.width-r)/2,width:r,height:e},200,"easeInOutSine",function(t){return function(){var n;return t.contentElement.css({visibility:"visible",display:"block"}),t.contentPane.length?(t.contentElement.css({height:e-i,overflow:"visible"}),n=t.contentControl.length?t.contentControl.outerHeight()+10:0,t.contentPane.css({height:e-i-n-20}),t.contentPane.find(".mercury-display-pane").css({width:r-20})):t.contentElement.css({height:e-i,overflow:"auto"})}}(this))},e.prototype.position=function(){var t,e,i,n,r;return n=Mercury.displayRect.width,this.contentPane&&this.contentPane.css({height:"auto"}),this.contentElement.css({height:"auto"}),this.element.css({width:"auto",height:"auto",display:"block",visibility:"hidden"}),r=this.element.width(),e=this.element.height(),r<this.options.minWidth&&(r=this.options.minWidth),(e>Mercury.displayRect.fullHeight||this.options.fullHeight)&&(e=Mercury.displayRect.fullHeight),i=this.titleElement.outerHeight(),this.contentPane&&this.contentPane.length?(this.contentElement.css({height:e-i,overflow:"visible"}),t=this.contentControl.length?this.contentControl.outerHeight()+10:0,this.contentPane.css({height:e-i-t-20}),this.contentPane.find(".mercury-display-pane").css({width:r-20})):this.contentElement.css({height:e-i,overflow:"auto"}),this.element.css({left:(n-r)/2,width:r,height:e,display:this.visible?"block":"none",visibility:"visible"})},e.prototype.update=function(){return this.reset(),this.resize(),this.load()},e.prototype.load=function(){return this.setTitle(),this.url?(this.element.addClass("loading"),Mercury.preloadedViews[this.url]?setTimeout(function(t){return function(){return t.loadContent(Mercury.preloadedViews[t.url])}}(this),10):jQuery.ajax(this.url,{headers:Mercury.ajaxHeaders(),type:this.options.loadType||"GET",data:this.options.loadData,success:function(t){return function(e){return t.loadContent(e)}}(this),error:function(t){return function(){return t.hide(),Mercury.notify("Mercury was unable to load %s for the modal.",t.url)}}(this)})):void 0},e.prototype.loadContent=function(t,e){return null==e&&(e=null),this.initializeModal(),this.options=e||this.options,this.setTitle(),this.loaded=!0,this.element.removeClass("loading"),this.contentElement.html(t),this.contentElement.css({display:"none",visibility:"hidden"}),this.contentPane=this.element.find(".mercury-display-pane-container"),this.contentControl=this.element.find(".mercury-display-controls"),this.options.afterLoad&&this.options.afterLoad.call(this),this.options.handler&&(Mercury.modalHandlers[this.options.handler]?"function"==typeof Mercury.modalHandlers[this.options.handler]?Mercury.modalHandlers[this.options.handler].call(this):(jQuery.extend(this,Mercury.modalHandlers[this.options.handler]),this.initialize()):Mercury.lightviewHandlers[this.options.handler]&&("function"==typeof Mercury.lightviewHandlers[this.options.handler]?Mercury.lightviewHandlers[this.options.handler].call(this):(jQuery.extend(this,Mercury.lightviewHandlers[this.options.handler]),this.initialize()))),Mercury.config.localization.enabled&&this.element.localize(Mercury.locale()),this.element.find(".modal-close").on("click",this.hide),this.resize()},e.prototype.setTitle=function(){var t;return this.titleElement.find("span").html(Mercury.I18n(this.options.title)),t=this.titleElement.find("a"),this.options.closeButton===!1?t.hide():t.show()},e.prototype.serializeForm=function(){return this.element.find("form").serializeObject()||{}},e.prototype.reset=function(){return this.titleElement.find("span").html(""),this.contentElement.html("")},e.prototype.hide=function(){return this.showing?void 0:(this.options={},Mercury.trigger("focus:frame"),this.element.hide(),this.overlay.hide(),this.reset(),this.visible=!1)},e}()}.call(this),function(){var t=function(t,e){return function(){return t.apply(e,arguments)}};this.Mercury.lightview=function(t,e){var i;return null==e&&(e={}),(i=Mercury.lightview).instance||(i.instance=new Mercury.Lightview(t,e)),Mercury.lightview.instance.show(t,e),Mercury.lightview.instance},this.Mercury.Lightview=function(){function e(e,i){this.url=e,this.options=null!=i?i:{},this.hide=t(this.hide,this)}return e.prototype.show=function(t,e){return this.url=t||this.url,this.options=e||this.options,this.options.ujsHandling!==!1&&(this.options.ujsHandling=!0),Mercury.trigger("focus:window"),this.initializeLightview(),this.visible?this.update():this.appear(),this.options.content?setTimeout(function(t){return function(){return t.loadContent(t.options.content)}}(this),500):void 0},e.prototype.initializeLightview=function(){return this.initialized?void 0:(this.build(),this.bindEvents(),this.initialized=!0)},e.prototype.build=function(){var t,e;return this.element=jQuery("<div>",{"class":"mercury-lightview loading"}),this.element.html('<h1 class="mercury-lightview-title"><span></span></h1>'),this.element.append('<div class="mercury-lightview-content"></div>'),this.overlay=jQuery("<div>",{"class":"mercury-lightview-overlay"}),this.titleElement=this.element.find(".mercury-lightview-title"),this.options.closeButton&&this.titleElement.append('<a class="mercury-lightview-close"></a>'),this.contentElement=this.element.find(".mercury-lightview-content"),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body"),this.overlay.appendTo(null!=(e=jQuery(this.options.appendTo).get(0))?e:"body")},e.prototype.bindEvents=function(){return Mercury.on("refresh",function(t){return function(){return t.resize(!0)}}(this)),Mercury.on("resize",function(t){return function(){return t.visible?t.position():void 0}}(this)),this.overlay.on("click",function(t){return function(){return t.options.closeButton?void 0:t.hide()}}(this)),this.titleElement.find(".mercury-lightview-close").on("click",function(t){return function(){return t.hide()}}(this)),this.options.ujsHandling&&this.element.on("ajax:beforeSend",function(t){return function(e,i,n){return n.success=function(e){return t.loadContent(e)}}}(this)),jQuery(document).on("keydown",function(t){return function(e){return 27===e.keyCode&&t.visible?t.hide():void 0}}(this))},e.prototype.appear=function(){return this.showing=!0,this.position(),this.overlay.show().css({opacity:0}),this.overlay.animate({opacity:1},200,"easeInOutSine",function(t){return function(){return t.setTitle(),t.element.show().css({opacity:0}),t.element.stop().animate({opacity:1},200,"easeInOutSine",function(){return t.visible=!0,t.showing=!1,t.load()})}}(this))},e.prototype.resize=function(t){var e,i,n,r,o,s;return o=t?"visible":"hidden",r=Mercury.displayRect.width,n=Mercury.displayRect.fullHeight,i=this.titleElement.outerHeight(),s=this.contentElement.outerWidth(),(s>r-40||this.options.fullSize)&&(s=r-40),this.contentPane&&this.contentPane.css({height:"auto"}),this.contentElement.css({height:"auto",visibility:o,display:"block"}),e=this.contentElement.outerHeight()+i,(e>n-20||this.options.fullSize)&&(e=n-20),300>s&&(s=300),150>e&&(e=150),this.element.stop().animate({top:(n-e)/2+10,left:(Mercury.displayRect.width-s)/2,width:s,height:e},200,"easeInOutSine",function(t){return function(){var n;return t.contentElement.css({visibility:"visible",display:"block"}),t.contentPane.length?(t.contentElement.css({height:e-i,overflow:"visible"}),n=t.contentControl.length?t.contentControl.outerHeight():0,t.contentPane.css({height:e-i-n-40}),t.contentPane.find(".mercury-display-pane").css({width:s-40})):t.contentElement.css({height:e-i-30,overflow:"auto"})}}(this))},e.prototype.position=function(){var t,e,i,n,r,o;return r=Mercury.displayRect.width,n=Mercury.displayRect.fullHeight,this.contentPane&&this.contentPane.css({height:"auto"}),this.contentElement.css({height:"auto"}),this.element.css({width:"auto",height:"auto",display:"block",visibility:"hidden"}),o=this.contentElement.width()+40,e=this.contentElement.height()+this.titleElement.outerHeight()+30,(o>r-40||this.options.fullSize)&&(o=r-40),(e>n-20||this.options.fullSize)&&(e=n-20),300>o&&(o=300),150>e&&(e=150),i=this.titleElement.outerHeight(),this.contentPane&&this.contentPane.length?(this.contentElement.css({height:e-i,overflow:"visible"}),t=this.contentControl.length?this.contentControl.outerHeight():0,this.contentPane.css({height:e-i-t-40}),this.contentPane.find(".mercury-display-pane").css({width:o-40})):this.contentElement.css({height:e-i-30,overflow:"auto"}),this.element.css({top:(n-e)/2+10,left:(r-o)/2,width:o,height:e,display:this.visible?"block":"none",visibility:"visible"})},e.prototype.update=function(){return this.reset(),this.resize(),this.load()},e.prototype.load=function(){return this.setTitle(),this.url?(this.element.addClass("loading"),Mercury.preloadedViews[this.url]?setTimeout(function(t){return function(){return t.loadContent(Mercury.preloadedViews[t.url])}}(this),10):jQuery.ajax(this.url,{headers:Mercury.ajaxHeaders(),type:this.options.loadType||"GET",data:this.options.loadData,success:function(t){return function(e){return t.loadContent(e)}}(this),error:function(t){return function(){return t.hide(),Mercury.notify("Mercury was unable to load %s for the lightview.",t.url)}}(this)})):void 0},e.prototype.loadContent=function(t,e){return null==e&&(e=null),this.initializeLightview(),this.options=e||this.options,this.setTitle(),this.loaded=!0,this.element.removeClass("loading"),this.contentElement.html(t),this.contentElement.css({display:"none",visibility:"hidden"}),this.contentPane=this.element.find(".mercury-display-pane-container"),this.contentControl=this.element.find(".mercury-display-controls"),this.options.afterLoad&&this.options.afterLoad.call(this),this.options.handler&&(Mercury.modalHandlers[this.options.handler]?"function"==typeof Mercury.modalHandlers[this.options.handler]?Mercury.modalHandlers[this.options.handler].call(this):(jQuery.extend(this,Mercury.modalHandlers[this.options.handler]),this.initialize()):Mercury.lightviewHandlers[this.options.handler]&&("function"==typeof Mercury.lightviewHandlers[this.options.handler]?Mercury.lightviewHandlers[this.options.handler].call(this):(jQuery.extend(this,Mercury.lightviewHandlers[this.options.handler]),this.initialize()))),Mercury.config.localization.enabled&&this.element.localize(Mercury.locale()),this.element.find(".lightview-close").on("click",this.hide),this.resize()},e.prototype.setTitle=function(){return this.titleElement.find("span").html(Mercury.I18n(this.options.title))},e.prototype.serializeForm=function(){return this.element.find("form").serializeObject()||{}},e.prototype.reset=function(){return this.titleElement.find("span").html(""),this.contentElement.html("")},e.prototype.hide=function(){return this.showing?void 0:(this.options={},Mercury.trigger("focus:frame"),this.element.hide(),this.overlay.hide(),this.reset(),this.visible=!1)},e}()}.call(this),function(){this.Mercury.Statusbar=function(){function t(t){this.options=null!=t?t:{},this.visible=this.options.visible,this.build(),this.bindEvents()}return t.prototype.build=function(){var t;return this.element=jQuery("<div>",{"class":"mercury-statusbar"}),this.aboutElement=jQuery("<a>",{"class":"mercury-statusbar-about"}).appendTo(this.element).html("Mercury Editor v"+Mercury.version),this.pathElement=jQuery("<div>",{"class":"mercury-statusbar-path"}).appendTo(this.element),this.visible||this.element.css({visibility:"hidden"}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body")},t.prototype.bindEvents=function(){return Mercury.on("region:update",function(t){return function(e,i){return i.region&&"function"===jQuery.type(i.region.path)?t.setPath(i.region.path()):void 0}}(this)),this.aboutElement.on("click",function(t){return function(){return Mercury.lightview("/mercury/lightviews/about.html",{title:"Mercury Editor v"+Mercury.version})}}(this))},t.prototype.height=function(){return this.element.outerHeight()},t.prototype.top=function(){var t,e;return e=this.element.offset().top,t=parseInt(this.element.css("bottom"))<0?e-this.element.outerHeight():e,this.visible?t:e+this.element.outerHeight()},t.prototype.setPath=function(t){var e,i,n,r;for(r=[],i=0,n=t.length;n>i;i++)e=t[i],r.push("<a>"+e.tagName.toLowerCase()+"</a>");return this.pathElement.html("<span><strong>"+Mercury.I18n("Path:")+" </strong>"+r.reverse().join(" &raquo; ")+"</span>")},t.prototype.show=function(){return this.visible=!0,this.element.css({opacity:0,visibility:"visible"}),this.element.animate({opacity:1},200,"easeInOutSine")},t.prototype.hide=function(){return this.visible=!1,this.element.css({visibility:"hidden"})},t}()}.call(this),function(){var t={}.hasOwnProperty;this.Mercury.Toolbar=function(){function e(t){this.options=null!=t?t:{},this.visible=this.options.visible,this.build(),this.bindEvents()}return e.prototype.build=function(){var e,i,n,r,o,s,a,l,u,c;this.element=jQuery("<div>",{"class":"mercury-toolbar-container",style:"width:10000px"}),this.element.css({width:"100%"}),this.element.appendTo(null!=(a=jQuery(this.options.appendTo).get(0))?a:"body"),l=Mercury.config.toolbars;for(c in l)if(t.call(l,c)&&(n=l[c],!n._custom)){u=jQuery("<div>",{"class":"mercury-toolbar mercury-"+c+"-toolbar"}).appendTo(this.element),n._regions&&u.attr("data-regions",n._regions),r=jQuery("<div>",{"class":"mercury-toolbar-button-container"}).appendTo(u);for(i in n)t.call(n,i)&&(s=n[i],"_regions"!==i&&(e=this.buildButton(i,s),e&&e.appendTo(r)));"nowrap"===r.css("white-space")&&(o=new Mercury.Toolbar.Expander(c,{appendTo:u,"for":r}),o.appendTo(this.element)),Mercury.config.toolbars.primary&&"primary"!==c&&u.addClass("disabled")}return this.visible?void 0:this.element.css({display:"none"})},e.prototype.buildButton=function(e,i){var n,r,o,s,a,l,u;if("_"===e[0])return!1;switch(jQuery.type(i)){case"array":return u=i[0],l=i[1],s=i[2],new Mercury.Toolbar.Button(e,u,l,s,{appendDialogsTo:this.element});case"object":o=new Mercury.Toolbar.ButtonGroup(e,i);for(n in i)t.call(i,n)&&(a=i[n],r=this.buildButton(n,a),r&&r.appendTo(o));return o;case"string":return jQuery("<hr>",{"class":"mercury-"+("-"===i?"line-separator":"separator")});default:throw Mercury.I18n('Unknown button structure -- please provide an array, object, or string for "%s".',e)}},e.prototype.bindEvents=function(){return Mercury.on("region:focused",function(t){return function(e,i){var n,r,o,s,a,l;for(o=t.element.find(".mercury-toolbar"),a=[],n=0,r=o.length;r>n;n++)l=o[n],l=jQuery(l),(s=l.data("regions"))&&s.split(",").indexOf(i.region.type())>-1?a.push(l.removeClass("disabled")):a.push(void 0);return a}}(this)),Mercury.on("region:blurred",function(t){return function(e,i){var n,r,o,s,a,l;for(o=t.element.find(".mercury-toolbar"),a=[],n=0,r=o.length;r>n;n++)l=o[n],l=jQuery(l),(s=l.data("regions"))&&s.split(",").indexOf(i.region.type())>-1?a.push(l.addClass("disabled")):a.push(void 0);return a}}(this)),this.element.on("click",function(){return Mercury.trigger("hide:dialogs")}),this.element.on("mousedown",function(t){return t.preventDefault()})},e.prototype.height=function(t){return null==t&&(t=!1),this.visible||t?this.element.outerHeight():0},e.prototype.top=function(){return this.visible?this.element.offset().top:0},e.prototype.show=function(){return this.visible=!0,this.element.css({top:-this.element.outerHeight(),display:"block"}),this.element.animate({top:0},200,"easeInOutSine")},e.prototype.hide=function(){return this.visible=!1,this.element.hide()},e}()}.call(this),function(){var t={}.hasOwnProperty;this.Mercury.Toolbar.Button=function(){function e(t,e,i,n,r){return this.name=t,this.title=e,this.summary=null!=i?i:null,this.types=null!=n?n:{},this.options=null!=r?r:{},this.title&&(this.title=Mercury.I18n(this.title)),this.summary&&(this.summary=Mercury.I18n(this.summary)),this.build(),this.bindEvents(),this.element}return e.prototype.build=function(){var e,i,n,r,o,s;this.element=jQuery("<div>",{title:null!=(i=this.summary)?i:this.title,"class":"mercury-button mercury-"+this.name+"-button"}).html("<em>"+this.title+"</em>"),this.element.data("expander",'<div class="mercury-expander-button" data-button="'+this.name+'"><em></em><span>'+this.title+"</span></div>"),this.handled={},n=this.types,o=[];for(s in n)if(t.call(n,s))switch(e=n[s],s){case"preload":o.push(!0);break;case"regions":this.element.addClass("disabled"),o.push(this.handled[s]=jQuery.isFunction(e)?e.call(this,this.name):e);break;case"toggle":o.push(this.handled[s]=!0);break;case"mode":o.push(this.handled[s]=e===!0?this.name:e);break;case"context":o.push(this.handled[s]=jQuery.isFunction(e)?e:Mercury.Toolbar.Button.contexts[this.name]);break;case"palette":this.element.addClass("mercury-button-palette"),r=jQuery.isFunction(e)?e.call(this,this.name):e,o.push(this.handled[s]="string"==typeof r?new Mercury.Palette(r,this.name,this.defaultDialogOptions()):r);break;case"select":this.element.addClass("mercury-button-select").find("em").html(this.title),r=jQuery.isFunction(e)?e.call(this,this.name):e,o.push(this.handled[s]="string"==typeof r?new Mercury.Select(r,this.name,this.defaultDialogOptions()):r);break;case"panel":this.element.addClass("mercury-button-panel"),this.handled.toggle=!0,r=jQuery.isFunction(e)?e.call(this,this.name):e,o.push(this.handled[s]="string"==typeof r?new Mercury.Panel(r,this.name,this.defaultDialogOptions()):r);break;case"modal":o.push(this.handled[s]=jQuery.isFunction(e)?e.call(this,this.name):e);break;case"lightview":o.push(this.handled[s]=jQuery.isFunction(e)?e.call(this,this.name):e);break;default:throw Mercury.I18n('Unknown button type "%s" used for the "%s" button.',s,this.name)}return o},e.prototype.bindEvents=function(){return Mercury.on("button",function(t){return function(e,i){return i.action===t.name?t.element.click():void 0}}(this)),Mercury.on("mode",function(t){return function(e,i){return t.handled.mode===i.mode&&t.handled.toggle?t.togglePressed():void 0}}(this)),Mercury.on("region:update",function(t){return function(e,i){var n;return t.handled.context&&i.region&&"function"===jQuery.type(i.region.currentElement)?(n=i.region.currentElement(),n.length&&t.handled.context.call(t,n,i.region.element)?t.element.addClass("active"):t.element.removeClass("active")):t.element.removeClass("active")}}(this)),Mercury.on("region:focused",function(t){return function(e,i){return t.handled.regions&&i.region&&i.region.type()?t.handled.regions.indexOf(i.region.type())>-1?t.element.removeClass("disabled"):t.element.addClass("disabled"):void 0}}(this)),Mercury.on("region:blurred",function(t){return function(){return t.handled.regions?t.element.addClass("disabled"):void 0}}(this)),this.element.on("mousedown",function(t){return function(){return t.element.addClass("active")}}(this)),this.element.on("mouseup",function(t){return function(){return t.element.removeClass("active")}}(this)),this.element.on("click",function(t){return function(e){return t.element.closest(".disabled").length?void 0:t.handleClick(e)}}(this))},e.prototype.handleClick=function(e){var i,n,r,o;i=!1,r=this.handled;for(o in r)if(t.call(r,o))switch(n=r[o],o){case"toggle":this.handled.mode||this.togglePressed();break;case"mode":i=!0,Mercury.trigger("mode",{mode:n});break;case"modal":i=this.handleModal(e);break;case"lightview":i=this.handleLightview(e);break;case"palette":case"select":case"panel":i=this.handleDialog(e,o)}return i||Mercury.trigger("action",{action:this.name}),this.options.regions&&this.options.regions.length?Mercury.trigger("focus:frame"):void 0},e.prototype.handleModal=function(t){return Mercury.modal(this.handled.modal,{title:this.summary||this.title,handler:this.name}),!0},e.prototype.handleLightview=function(t){return Mercury.lightview(this.handled.lightview,{title:this.summary||this.title,handler:this.name,closeButton:!0}),!0},e.prototype.handleDialog=function(t,e){return t.stopPropagation(),this.handled[e].toggle(),!0},e.prototype.defaultDialogOptions=function(){return{title:this.summary||this.title,preload:this.types.preload,appendTo:this.options.appendDialogsTo||"body",closeButton:!0,"for":this.element}},e.prototype.togglePressed=function(){return this.element.toggleClass("pressed")},e}(),this.Mercury.Toolbar.Button.contexts={backColor:function(t){return this.element.css("background-color",t.css("background-color"))},foreColor:function(t){return this.element.css("background-color",t.css("color"))},bold:function(t){var e;return e=t.css("font-weight"),"bold"===e||e>400},italic:function(t){return"italic"===t.css("font-style")},overline:function(t){var e,i,n,r;if("overline"===t.css("text-decoration"))return!0;for(r=t.parentsUntil(this.element),e=0,i=r.length;i>e;e++)if(n=r[e],"overline"===jQuery(n).css("text-decoration"))return!0;return!1},strikethrough:function(t,e){return"line-through"===t.css("text-decoration")||!!t.closest("strike",e).length},underline:function(t,e){return"underline"===t.css("text-decoration")||!!t.closest("u",e).length},subscript:function(t,e){return!!t.closest("sub",e).length},superscript:function(t,e){return!!t.closest("sup",e).length},justifyLeft:function(t){return t.css("text-align").indexOf("left")>-1},justifyCenter:function(t){return t.css("text-align").indexOf("center")>-1},justifyRight:function(t){
  return t.css("text-align").indexOf("right")>-1},justifyFull:function(t){return t.css("text-align").indexOf("justify")>-1},insertOrderedList:function(t,e){return!!t.closest("ol",e.element).length},insertUnorderedList:function(t,e){return!!t.closest("ul",e.element).length}}}.call(this),function(){this.Mercury.Toolbar.ButtonGroup=function(){function t(t,e){return this.name=t,this.options=null!=e?e:{},this.build(),this.bindEvents(),this.regions=this.options._regions,this.element}return t.prototype.build=function(){return this.element=jQuery("<div>",{"class":"mercury-button-group mercury-"+this.name+"-group"}),this.options._context||this.options._regions?this.element.addClass("disabled"):void 0},t.prototype.bindEvents=function(){return Mercury.on("region:update",function(t){return function(e,i){var n,r;return n=Mercury.Toolbar.ButtonGroup.contexts[t.name],n&&i.region&&"function"===jQuery.type(i.region.currentElement)?(r=i.region.currentElement(),r.length&&n.call(t,r,i.region.element)?t.element.removeClass("disabled"):t.element.addClass("disabled")):void 0}}(this)),Mercury.on("region:focused",function(t){return function(e,i){if(t.regions&&i.region&&i.region.type()){if(!(t.regions.indexOf(i.region.type())>-1))return t.element.addClass("disabled");if(!t.options._context)return t.element.removeClass("disabled")}}}(this)),Mercury.on("region:blurred",function(t){return function(e,i){return t.options.regions?t.element.addClass("disabled"):void 0}}(this))},t}(),this.Mercury.Toolbar.ButtonGroup.contexts={table:function(t,e){return!!t.closest("table",e).length}}}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Toolbar.Expander=function(e){function i(t,e){return this.name=t,this.options=e,this.container=this.options["for"],i.__super__.constructor.call(this,null,this.name,this.options),this.element}return t(i,e),i.prototype.build=function(){var t;return this.container.css({whiteSpace:"normal",visibility:"hidden",display:"block"}),this.container.css({visibility:"visible"}),this.trigger=jQuery("<div>",{"class":"mercury-toolbar-expander"}).appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body"),this.element=jQuery("<div>",{"class":"mercury-palette mercury-expander mercury-"+this.name+"-expander",style:"display:none"}),this.windowResize()},i.prototype.bindEvents=function(){return Mercury.on("hide:dialogs",function(t){return function(e,i){return i!==t?t.hide():void 0}}(this)),Mercury.on("resize",function(t){return function(){return t.windowResize()}}(this)),i.__super__.bindEvents.apply(this,arguments),this.trigger.click(function(t){return function(e){var i,n,r,o,s;for(e.stopPropagation(),n=[],s=t.container.find(".mercury-button"),r=0,o=s.length;o>r;r++)i=s[r],i=jQuery(i),i.position().top>5&&n.push(i.data("expander"));return t.loadContent(n.join("")),t.toggle()}}(this)),this.element.click(function(t){return function(e){var i,n;return n=jQuery(e.target).closest("[data-button]").data("button"),i=t.container.find(".mercury-"+n+"-button"),i.click()}}(this))},i.prototype.windowResize=function(){return jQuery(window).width()===this.container.outerWidth()?this.trigger.show():this.trigger.hide(),this.hide()},i.prototype.position=function(t){var e,i;return this.element.css({top:0,left:0,display:"block",visibility:"hidden"}),e=this.trigger.position(),i=this.element.width(),e.left+i>jQuery(window).width()&&(e.left=e.left-i+this.trigger.width()),this.element.css({top:e.top+this.trigger.height(),left:e.left,display:t?"block":"none",visibility:"visible"})},i}(Mercury.Palette)}.call(this),function(){this.Mercury.tooltip=function(t,e,i){return null==i&&(i={}),Mercury.tooltip.show(t,e,i),Mercury.tooltip},jQuery.extend(Mercury.tooltip,{show:function(t,e,i){return this.forElement=t,this.content=e,this.options=null!=i?i:{},this.document=this.forElement.get(0).ownerDocument,this.initialize(),this.visible?this.update():this.appear()},initialize:function(){return this.initialized?void 0:(this.build(),this.bindEvents(),this.initialized=!0)},build:function(){var t;return this.element=jQuery("<div>",{"class":"mercury-tooltip"}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body")},bindEvents:function(){var t,e,i,n;for(Mercury.on("resize",function(t){return function(){return t.visible?t.position():void 0}}(this)),this.element.on("mousedown",function(t){return t.preventDefault(),t.stopPropagation()}),n=this.forElement.parentsUntil(jQuery("body",this.document)),t=0,e=n.length;e>t;t++)i=n[t],i.scrollHeight>i.clientHeight&&jQuery(i).on("scroll",function(t){return function(){return t.visible?t.position():void 0}}(this));return jQuery(this.document).on("scroll",function(t){return function(){return t.visible?t.position():void 0}}(this))},appear:function(){return this.update(),this.element.show(),this.element.animate({opacity:1},200,"easeInOutSine",function(t){return function(){return t.visible=!0}}(this))},update:function(){return this.element.html(this.content),this.position()},position:function(){var t,e,i,n;return e=this.forElement.offset(),n=this.element.width(),i=e.top+(Mercury.displayRect.top-jQuery(this.document).scrollTop())+this.forElement.outerHeight(),t=e.left-jQuery(this.document).scrollLeft(),t+n+25>Mercury.displayRect.width&&(t=t-(t+n+25)-Mercury.displayRect.width),t=0>=t?0:t,this.element.css({top:i,left:t})},hide:function(){return this.initialized?(this.element.hide(),this.visible=!1):void 0}})}.call(this),function(){var t={}.hasOwnProperty;this.Mercury.Snippet=function(){function e(t,e,i){this.name=t,this.identity=e,null==i&&(i={}),this.version=0,this.data="",this.wrapperTag="div",this.wrapperClass="",this.history=new Mercury.HistoryBuffer,this.setOptions(i)}return e.all=[],e.displayOptionsFor=function(t,e,i){var n;return null==e&&(e={}),null==i&&(i=!0),i?Mercury.modal(this.optionsUrl(t),jQuery.extend({title:"Snippet Options",handler:"insertSnippet",snippetName:t,loadType:Mercury.config.snippets.method},e)):(n=Mercury.Snippet.create(t),Mercury.trigger("action",{action:"insertSnippet",value:n})),Mercury.snippet=null},e.optionsUrl=function(t){var e;return e=Mercury.config.snippets.optionsUrl,"function"==typeof e&&(e=e()),e.replace(":name",t)},e.previewUrl=function(t){var e;return e=Mercury.config.snippets.previewUrl,"function"==typeof e&&(e=e()),e.replace(":name",t)},e.create=function(t,e){var i;return i=new Mercury.Snippet(t,this.uniqueId(),e),this.all.push(i),i},e.uniqueId=function(){var t,e,i,n,r;for(n=[0,"snippet_0"],t=n[0],i=n[1],e=function(){var t,e,i,n;for(i=this.all,n=[],t=0,e=i.length;e>t;t++)r=i[t],n.push(r.identity);return n}.call(this);-1!==e.indexOf(i);)t+=1,i="snippet_"+t;return i},e.find=function(t){var e,i,n,r;for(n=this.all,e=0,i=n.length;i>e;e++)if(r=n[e],r.identity===t)return r;return null},e.load=function(e){var i,n,r,o;o=[];for(n in e)t.call(e,n)&&(i=e[n],r=new Mercury.Snippet(i.name,n,i),o.push(this.all.push(r)));return o},e.clearAll=function(){return delete this.all,this.all=[]},e.prototype.getHTML=function(t,e){var i,n;return null==e&&(e=null),n=this.name+"-snippet",this.wrapperClass&&(n+=" "+this.wrapperClass),i=jQuery("<"+this.wrapperTag+">",{"class":n,contenteditable:"false","data-snippet":this.identity,"data-version":this.version},t),i.html("["+this.identity+"]"),this.loadPreview(i,e),i},e.prototype.getText=function(t){return"[--"+this.identity+"--]"},e.prototype.loadPreview=function(t,i){return null==i&&(i=null),jQuery.ajax(e.previewUrl(this.name),{headers:Mercury.ajaxHeaders(),type:Mercury.config.snippets.method,data:this.options,success:function(e){return function(n){return e.data=n,t.html(n),i?i():void 0}}(this),error:function(t){return function(){return Mercury.notify('Error loading the preview for the "%s" snippet.',t.name)}}(this)})},e.prototype.displayOptions=function(){return Mercury.snippet=this,Mercury.modal(e.optionsUrl(this.name),{title:"Snippet Options",handler:"insertSnippet",loadType:Mercury.config.snippets.method,loadData:this.options})},e.prototype.setOptions=function(t){return this.options=t,delete this.options.authenticity_token,delete this.options.utf8,this.options.wrapperTag&&(this.wrapperTag=this.options.wrapperTag),this.options.wrapperClass&&(this.wrapperClass=this.options.wrapperClass),this.version+=1,this.history.push(this.options)},e.prototype.setVersion=function(t){return null==t&&(t=null),t=parseInt(t),t&&this.history.stack[t-1]?(this.version=t,this.options=this.history.stack[t-1],!0):!1},e.prototype.serialize=function(){return $.extend({name:this.name},this.options)},e}()}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.SnippetToolbar=function(i){function n(t,e){this.document=t,this.options=null!=e?e:{},this._boundEvents=[],n.__super__.constructor.call(this,this.options)}return t(n,i),n.prototype.build=function(){var t,i,n,r,o,s;this.element=jQuery("<div>",{"class":"mercury-toolbar mercury-snippet-toolbar",style:"display:none"}),this.element.appendTo(null!=(r=jQuery(this.options.appendTo).get(0))?r:"body"),o=Mercury.config.toolbars.snippets,s=[];for(i in o)e.call(o,i)&&(n=o[i],t=this.buildButton(i,n),t?s.push(t.appendTo(this.element)):s.push(void 0));return s},n.prototype.bindEvents=function(){return this.bindReleasableEvent(Mercury,"show:toolbar",function(t){return function(e,i){return i.snippet?(i.snippet.mouseout(function(){return t.hide()}),t.show(i.snippet)):void 0}}(this)),this.bindReleasableEvent(Mercury,"hide:toolbar",function(t){return function(e,i){return i.type&&"snippet"===i.type?t.hide(i.immediately):void 0}}(this)),this.bindReleasableEvent(jQuery(this.document),"scroll",function(t){return function(){return t.visible?t.position():void 0}}(this)),this.element.mousemove(function(t){return function(){return clearTimeout(t.hideTimeout)}}(this)),this.element.mouseout(function(t){return function(){return t.hide()}}(this))},n.prototype.bindReleasableEvent=function(t,e,i){return t.on(e,i),this._boundEvents.push([t,e,i])},n.prototype.show=function(t){return this.snippet=t,Mercury.tooltip.hide(),this.position(),this.appear()},n.prototype.position=function(){var t,e,i;return e=this.snippet.offset(),i=e.top+Mercury.displayRect.top-jQuery(this.document).scrollTop()-this.height()+10,t=e.left-jQuery(this.document).scrollLeft(),this.element.css({top:i,left:t})},n.prototype.appear=function(){return clearTimeout(this.hideTimeout),this.visible?void 0:(this.visible=!0,this.element.css({display:"block",opacity:0}),this.element.stop().animate({opacity:1},200,"easeInOutSine"))},n.prototype.hide=function(t){return null==t&&(t=!1),clearTimeout(this.hideTimeout),t?(this.element.hide(),this.visible=!1):this.hideTimeout=setTimeout(function(t){return function(){return t.element.stop().animate({opacity:0},300,"easeInOutSine",function(){return t.element.hide()}),t.visible=!1}}(this),500)},n.prototype.release=function(){var t,e,i,n,r,o,s;for(this.element.off(),this.element.remove(),r=this._boundEvents,i=0,n=r.length;n>i;i++)o=r[i],s=o[0],t=o[1],e=o[2],s.off(t,e);return this._boundEvents=[]},n}(Mercury.Toolbar)}.call(this),function(){this.Mercury.Region=function(){function t(t,e,i){this.element=t,this.window=e,this.options=null!=i?i:{},Mercury.log("building "+this.type(),this.element,this.options),this.document=this.window.document,this.name=this.element.attr(Mercury.config.regions.identifier),this.history=new Mercury.HistoryBuffer,this.build(),this.bindEvents(),this.pushHistory(),this.element.data("region",this)}return t.prototype.type=function(){return"unknown"},t.prototype.build=function(){},t.prototype.focus=function(){},t.prototype.bindEvents=function(){return Mercury.on("mode",function(t){return function(e,i){return"preview"===i.mode?t.togglePreview():void 0}}(this)),Mercury.on("focus:frame",function(t){return function(){return t.previewing||Mercury.region!==t?void 0:t.focus()}}(this)),Mercury.on("action",function(t){return function(e,i){return t.previewing||Mercury.region!==t||e.isDefaultPrevented()?void 0:i.action?t.execCommand(i.action,i):void 0}}(this)),this.element.on("mousemove",function(t){return function(e){var i;if(!t.previewing&&Mercury.region===t)return i=jQuery(e.target).closest("[data-snippet]"),i.length&&(t.snippet=i,t.snippet.data("snippet"))?Mercury.trigger("show:toolbar",{type:"snippet",snippet:t.snippet}):void 0}}(this)),this.element.on("mouseout",function(t){return function(){return t.previewing?void 0:Mercury.trigger("hide:toolbar",{type:"snippet",immediately:!1})}}(this))},t.prototype.content=function(t,e){var i,n,r,o,s;if(null==t&&(t=null),null==e&&(e=!1),null!==t)return this.element.html(t);if(i=document.createElement("div"),i.innerHTML=this.element.html().replace(/^\s+|\s+$/g,""),i=$(i),e)for(o=i.find("[data-snippet]"),n=0,r=o.length;r>n;n++)s=o[n],s=jQuery(s),s.attr({contenteditable:null,"data-version":null}),s.html("["+s.data("snippet")+"]");return i.html()},t.prototype.togglePreview=function(){return this.previewing?(this.previewing=!1,this.element.attr(Mercury.config.regions.attribute,this.type()),Mercury.region===this?this.focus():void 0):(this.previewing=!0,this.element.removeAttr(Mercury.config.regions.attribute),Mercury.trigger("region:blurred",{region:this}))},t.prototype.execCommand=function(t,e){return null==e&&(e={}),this.focus(),"redo"!==t&&this.pushHistory(),Mercury.log("execCommand",t,e.value),Mercury.changes=!0},t.prototype.pushHistory=function(){return this.history.push(this.content())},t.prototype.snippets=function(){var t,e,i,n,r,o;for(o={},n=this.element.find("[data-snippet]"),e=0,i=n.length;i>e;e++)t=n[e],r=Mercury.Snippet.find(jQuery(t).data("snippet")),r&&(o[r.identity]=r.serialize());return o},t.prototype.dataAttributes=function(){var t,e,i,n,r;for(e={},r=Mercury.config.regions.dataAttributes,i=0,n=r.length;n>i;i++)t=r[i],e[t]=(this.container||this.element).attr("data-"+t);return e},t.prototype.serialize=function(){return{type:this.type(),data:this.dataAttributes(),value:this.content(null,!0),snippets:this.snippets()}},t}()}.call(this),function(){var t={}.hasOwnProperty;this.Mercury.uploader=function(t,e){return Mercury.config.uploading.enabled&&Mercury.uploader.show(t,e),Mercury.uploader},jQuery.extend(Mercury.uploader,{show:function(t,e){return this.options=null!=e?e:{},this.file=new Mercury.uploader.File(t),this.file.errors?void alert("Error: "+this.file.errors):this.supported()?(Mercury.trigger("focus:window"),this.initialize(),this.appear()):void 0},initialize:function(){return this.initialized?void 0:(this.build(),this.bindEvents(),this.initialized=!0)},supported:function(){var t;return t=new XMLHttpRequest,window.Uint8Array&&window.ArrayBuffer&&!XMLHttpRequest.prototype.sendAsBinary&&(XMLHttpRequest.prototype.sendAsBinary=function(t){var e,i,n,r,o;for(o=new Uint8Array(t.length),n=i=0,r=t.length;r>i;n=++i)e=t[n],o[n]=255&t.charCodeAt(n);return this.send(o.buffer)}),!(!t.upload||!t.sendAsBinary||!Mercury.uploader.fileReaderSupported()&&!Mercury.uploader.formDataSupported())},fileReaderSupported:function(){return!!window.FileReader},formDataSupported:function(){return!!window.FormData},build:function(){var t,e;return this.element=jQuery("<div>",{"class":"mercury-uploader",style:"display:none"}),this.element.append('<div class="mercury-uploader-preview"><b><img/></b></div>'),this.element.append('<div class="mercury-uploader-details"></div>'),this.element.append('<div class="mercury-uploader-progress"><span></span><div class="mercury-uploader-indicator"><div><b>0%</b></div></div></div>'),this.updateStatus("Processing..."),this.overlay=jQuery("<div>",{"class":"mercury-uploader-overlay",style:"display:none"}),this.element.appendTo(null!=(t=jQuery(this.options.appendTo).get(0))?t:"body"),this.overlay.appendTo(null!=(e=jQuery(this.options.appendTo).get(0))?e:"body")},bindEvents:function(){return Mercury.on("resize",function(t){return function(){return t.position()}}(this))},appear:function(){return this.fillDisplay(),this.position(),this.overlay.show(),this.overlay.animate({opacity:1},200,"easeInOutSine",function(t){return function(){return t.element.show(),t.element.animate({opacity:1},200,"easeInOutSine",function(){return t.visible=!0,t.loadImage()})}}(this))},position:function(){var t,e;return e=this.element.outerWidth(),t=this.element.outerHeight(),this.element.css({top:(Mercury.displayRect.height-t)/2,left:(Mercury.displayRect.width-e)/2})},fillDisplay:function(){var t;return t=[Mercury.I18n("Name: %s",this.file.name),Mercury.I18n("Size: %s",this.file.readableSize),Mercury.I18n("Type: %s",this.file.type)],this.element.find(".mercury-uploader-details").html(t.join("<br/>"))},loadImage:function(){return Mercury.uploader.fileReaderSupported()?this.file.readAsDataURL(function(t){return function(e){return t.element.find(".mercury-uploader-preview b").html(jQuery("<img>",{src:e})),t.upload()}}(this)):this.upload()},upload:function(){var t,e;return e=new XMLHttpRequest,jQuery.each(["onloadstart","onprogress","onload","onabort","onerror"],function(t){return function(i,n){return e.upload[n]=function(e){return t.uploaderEvents[n].call(t,e)}}}(this)),e.onload=function(t){return function(e){var i,n,r,o;if(e.currentTarget.status>=400)return t.updateStatus("Error: Unable to upload the file"),Mercury.notify("Unable to process response: %s",e.currentTarget.status),t.hide();try{if(r=Mercury.config.uploading.handler?Mercury.config.uploading.handler(e.target.responseText):jQuery.parseJSON(e.target.responseText),o=r.url||r.image.url,!o)throw"Malformed response from server.";return Mercury.trigger("action",{action:"insertImage",value:{src:o}}),t.hide()}catch(n){return i=n,t.updateStatus("Error: Unable to upload the file"),Mercury.notify("Unable to process response: %s",i),t.hide()}}}(this),e.open("post",Mercury.config.uploading.url,!0),e.setRequestHeader("Accept","application/json, text/javascript, text/html, application/xml, text/xml, */*"),e.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.setRequestHeader(Mercury.config.csrfHeader,Mercury.csrfToken),Mercury.uploader.fileReaderSupported()?this.file.readAsBinaryString(function(t){return function(i){var n;return n=new Mercury.uploader.MultiPartPost(Mercury.config.uploading.inputName,t.file,i),t.file.updateSize(n.delta),e.setRequestHeader("Content-Type","multipart/form-data; boundary="+n.boundary),e.sendAsBinary(n.body)}}(this)):(t=new FormData,t.append(Mercury.config.uploading.inputName,this.file.file,this.file.file.name),e.send(t))},updateStatus:function(t,e){var i;return this.element.find(".mercury-uploader-progress span").html(Mercury.I18n(t).toString()),e?(i=Math.floor(100*e/this.file.size)+"%",this.element.find(".mercury-uploader-indicator div").css({width:i}),this.element.find(".mercury-uploader-indicator b").html(i).show()):void 0},hide:function(t){return null==t&&(t=0),setTimeout(function(t){return function(){return t.element.animate({opacity:0},200,"easeInOutSine",function(){return t.overlay.animate({opacity:0},200,"easeInOutSine",function(){return t.overlay.hide(),t.element.hide(),t.reset(),t.visible=!1,Mercury.trigger("focus:frame")})})}}(this),1e3*t)},reset:function(){return this.element.find(".mercury-uploader-preview b").html(""),this.element.find(".mercury-uploader-indicator div").css({width:0}),this.element.find(".mercury-uploader-indicator b").html("0%").hide(),this.updateStatus("Processing...")},uploaderEvents:{onloadstart:function(){return this.updateStatus("Uploading...")},onprogress:function(t){return this.updateStatus("Uploading...",t.loaded)},onabort:function(){return this.updateStatus("Aborted"),this.hide(1)},onload:function(){return this.updateStatus("Successfully uploaded...",this.file.size)},onerror:function(){return this.updateStatus("Error: Unable to upload the file"),this.hide(3)}}}),Mercury.uploader.File=function(){function t(t){var e;this.file=t,this.fullSize=this.size=this.file.size||this.file.fileSize,this.readableSize=this.size.toBytes(),this.name=this.file.name||this.file.fileName,this.type=this.file.type||this.file.fileType,e=[],this.size>=Mercury.config.uploading.maxFileSize&&e.push(Mercury.I18n("Too large")),Mercury.config.uploading.allowedMimeTypes.indexOf(this.type)>-1||e.push(Mercury.I18n("Unsupported format")),e.length&&(this.errors=e.join(" / "))}return t.prototype.readAsDataURL=function(t){var e;return null==t&&(t=null),e=new FileReader,e.readAsDataURL(this.file),e.onload=function(i){return function(){return t?t(e.result):void 0}}(this)},t.prototype.readAsBinaryString=function(t){var e;return null==t&&(t=null),e=new FileReader,e.readAsBinaryString(this.file),e.onload=function(i){return function(){return t?t(e.result):void 0}}(this)},t.prototype.updateSize=function(t){return this.fullSize=this.size+t},t}(),Mercury.uploader.MultiPartPost=function(){function e(t,e,i,n){this.inputName=t,this.file=e,this.contents=i,this.formInputs=null!=n?n:{},this.boundary="Boundaryx20072377098235644401115438165x",this.body="",this.buildBody(),this.delta=this.body.length-this.file.size}return e.prototype.buildBody=function(){var e,i,n,r;e="--"+this.boundary,n=this.formInputs;for(i in n)t.call(n,i)&&(r=n[i],this.body+=e+'\r\nContent-Disposition: form-data; name="'+i+'"\r\n\r\n'+unescape(encodeURIComponent(r))+"\r\n");return this.body+=e+'\r\nContent-Disposition: form-data; name="'+this.inputName+'"; filename="'+this.file.name+'"\r\nContent-Type: '+this.file.type+"\r\nContent-Transfer-Encoding: binary\r\n\r\n"+this.contents+"\r\n"+e+"--"},e}()}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty,i=[].indexOf||function(t){for(var e=0,i=this.length;i>e;e++)if(e in this&&this[e]===t)return e;return-1};this.Mercury.Regions.Full=function(e){function n(t,e,i){this.element=t,this.window=e,this.options=null!=i?i:{},n.__super__.constructor.apply(this,arguments)}var r;return t(n,e),n.supported=document.designMode&&!jQuery.browser.konqueror&&(!jQuery.browser.msie||jQuery.browser.msie&&parseFloat(jQuery.browser.version,10)>=10),n.supportedText="Chrome 10+, Firefox 4+, Safari 5+, Opera 11.64+",r="full",n.prototype.type=function(){return r},n.prototype.build=function(){var t,e,i,n,r,o;for(jQuery.browser.mozilla&&""===this.content()&&this.content("&nbsp;"),this.element.data({originalOverflow:this.element.css("overflow")}),this.element.css({overflow:"auto"}),this.specialContainer=jQuery.browser.mozilla&&"DIV"!==this.element.get(0).tagName,this.element.get(0).contentEditable=!0,o=this.element.find("[data-snippet]"),n=0,r=o.length;r>n;n++)e=o[n],e.contentEditable=!1,jQuery(e).attr("data-version","1");if(!this.document.mercuryEditing){this.document.mercuryEditing=!0;try{return this.document.execCommand("styleWithCSS",!1,!1),this.document.execCommand("insertBROnReturn",!1,!0),this.document.execCommand("enableInlineTableEditing",!1,!1),this.document.execCommand("enableObjectResizing",!1,!1)}catch(i){t=i}}},n.prototype.bindEvents=function(){return n.__super__.bindEvents.apply(this,arguments),Mercury.on("region:update",function(t){return function(){var e,i,n;if(!t.previewing&&Mercury.region===t)return setTimeout(function(){return t.selection().forceSelection(t.element.get(0))},1),i=t.currentElement(),i.length?(n=i.closest("table",t.element),n.length&&Mercury.tableEditor(n,i.closest("tr, td"),"<br/>"),e=i.closest("a",t.element),e.length&&e.attr("href")?Mercury.tooltip(e,'<a href="'+e.attr("href")+'" target="_blank">'+e.attr("href")+"</a>",{position:"below"}):Mercury.tooltip.hide()):void 0}}(this)),this.element.on("dragenter",function(t){return function(e){return t.previewing?void 0:(Mercury.snippet||e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy")}}(this)),this.element.on("dragover",function(t){return function(e){return t.previewing?void 0:(Mercury.snippet||e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy")}}(this)),this.element.on("drop",function(t){return function(e){return!t.previewing&&(clearTimeout(t.dropTimeout),t.dropTimeout=setTimeout(function(){return t.element.trigger("possible:drop")},1),e.originalEvent.dataTransfer.files.length)?(e.preventDefault(),t.focus(),Mercury.uploader(e.originalEvent.dataTransfer.files[0])):void 0}}(this)),this.element.on("possible:drop",function(t){return function(){return t.previewing?void 0:Mercury.snippet?(t.focus(),Mercury.Snippet.displayOptionsFor(Mercury.snippet.name,{},Mercury.snippet.hasOptions),t.document.execCommand("undo",!1,null)):void 0}}(this)),this.element.on("paste",function(t){return function(e){if(!t.previewing&&Mercury.region===t){if(t.specialContainer)return void e.preventDefault();if(!t.pasting)return Mercury.changes=!0,t.handlePaste(e.originalEvent)}}}(this)),this.element.on("focus",function(t){return function(){return t.previewing?void 0:(Mercury.region=t,setTimeout(function(){return t.selection().forceSelection(t.element.get(0))},1),Mercury.trigger("region:focused",{region:t}))}}(this)),this.element.on("blur",function(t){return function(){return t.previewing?void 0:(Mercury.trigger("region:blurred",{region:t}),Mercury.tooltip.hide())}}(this)),this.element.on("click",function(t){return function(e){return t.previewing?jQuery(e.target).closest("a").attr("target","_parent"):void 0}}(this)),this.element.on("dblclick",function(t){return function(e){var i;if(!t.previewing)return i=jQuery(e.target).closest("img",t.element),i.length?(t.selection().selectNode(i.get(0),!0),Mercury.trigger("button",{action:"insertMedia"})):void 0}}(this)),this.element.on("mouseup",function(t){return function(){return t.previewing?void 0:(t.pushHistory(),Mercury.trigger("region:update",{region:t}))}}(this)),this.element.on("keydown",function(t){return function(e){var i;if(!t.previewing){switch(e.keyCode){case 90:if(!e.metaKey)return;return e.preventDefault(),void(e.shiftKey?t.execCommand("redo"):t.execCommand("undo"));case 13:jQuery.browser.webkit&&0===t.selection().commonAncestor().closest("li, ul, ol",t.element).length?(e.preventDefault(),t.document.execCommand("insertParagraph",!1,null)):(t.specialContainer||jQuery.browser.opera)&&(e.preventDefault(),t.document.execCommand("insertHTML",!1,"<br/>"));break;case 9:e.preventDefault(),i=t.selection().commonAncestor(),i.closest("li",t.element).length?e.shiftKey?i.parents("ul, ol").length>1&&t.execCommand("outdent"):t.execCommand("indent"):t.execCommand("insertHTML",{value:"&nbsp;&nbsp;"})}if(e.metaKey)switch(e.keyCode){case 66:t.execCommand("bold"),e.preventDefault();break;case 73:t.execCommand("italic"),e.preventDefault();break;case 85:t.execCommand("underline"),e.preventDefault()}return t.pushHistory(e.keyCode)}}}(this)),this.element.on("keyup",function(t){return function(){return t.previewing?void 0:(Mercury.trigger("region:update",{region:t}),Mercury.changes=!0)}}(this))},n.prototype.focus=function(){var t,e;if(Mercury.region!==this){setTimeout(function(t){return function(){return t.element.focus()}}(this),10);try{this.selection().selection.collapseToStart()}catch(e){t=e}}else setTimeout(function(t){return function(){return t.element.focus()}}(this),10);return Mercury.trigger("region:focused",{region:this}),Mercury.trigger("region:update",{region:this})},n.prototype.content=function(t,e,i){var n,r,o,s,a,l,u,c,h,p,d,f,m,g,y;if(null==t&&(t=null),null==e&&(e=!0),null==i&&(i=!1),null!==t){for(n=jQuery("<div>").appendTo(this.document.createDocumentFragment()),n.html(t),d=n.find("[data-snippet]"),l=0,h=d.length;h>l;l++)if(o=d[l],o.contentEditable=!1,o=jQuery(o),g=Mercury.Snippet.find(o.data("snippet")))if(o.data("version"))g.setVersion(o.data("version"));else try{y=parseInt(o.html().match(/\/(\d+)\]/)[1]),y&&(g.setVersion(y),o.attr({"data-version":y}),o.html(g.data))}catch(a){s=a}return this.element.html(n.html()),this.selection().selectMarker(this.element)}if(this.element.find("meta").remove(),i&&(m=this.selection(),m.placeMarker()),n=jQuery("<div>").appendTo(this.document.createDocumentFragment()),n.html(this.element.html().replace(/^\s+|\s+$/g,"")),e)for(f=n.find("[data-snippet]"),u=c=0,p=f.length;p>c;u=++c)o=f[u],o=jQuery(o),(g=Mercury.Snippet.find(o.data("snippet")))&&(g.data=o.html()),o.html("["+o.data("snippet")+"/"+o.data("version")+"]"),o.attr({contenteditable:null,"data-version":null});return r=n.html(),i&&m.removeMarker(),r},n.prototype.togglePreview=function(){return this.previewing?(this.element.get(0).contentEditable=!0,this.element.css({overflow:"auto"})):(this.content(this.content()),this.element.get(0).contentEditable=!1,this.element.css({overflow:this.element.data("originalOverflow")}),this.element.blur()),n.__super__.togglePreview.apply(this,arguments)},n.prototype.execCommand=function(t,e){var i,r,o,s;if(null==e&&(e={}),n.__super__.execCommand.apply(this,arguments),o=Mercury.config.behaviors[t]||Mercury.Regions.Full.actions[t])o.call(this,this.selection(),e);else{"indent"===t&&(s=this.element.get(0).previousSibling),"insertHTML"===t&&e.value&&e.value.get&&(e.value=jQuery("<div>").html(e.value).html());try{this.document.execCommand(t,!1,e.value)}catch(r){i=r,"indent"===t&&this.element.prev()!==s&&this.element.prev().remove()}}return this.element.find("img").one("error",function(){return jQuery(this).attr({src:"/assets/mercury/missing-image.png",title:"Image not found"})})},n.prototype.pushHistory=function(t){var e,i,n;return e=[13,46,8],n=2.5,t&&(i=e.indexOf(t)),clearTimeout(this.historyTimeout),i>=0&&i!==this.lastKnownKeyCode?this.history.push(this.content(null,!1,!0)):t?this.historyTimeout=setTimeout(function(t){return function(){return t.history.push(t.content(null,!1,!0))}}(this),1e3*n):this.history.push(this.content(null,!1,!0)),this.lastKnownKeyCode=i},n.prototype.selection=function(){return new Mercury.Regions.Full.Selection(this.window.getSelection(),this.document)},n.prototype.path=function(){var t;return t=this.selection().commonAncestor(),t?t.get(0)===this.element.get(0)?[]:t.parentsUntil(this.element):[]},n.prototype.currentElement=function(){var t,e;return t=[],e=this.selection(),e.range&&(t=e.commonAncestor(),3===t.get(0).nodeType&&(t=t.parent())),t},n.prototype.handlePaste=function(t){var e,i;return"text"===Mercury.config.pasting.sanitize&&t.clipboardData?(this.execCommand("insertHTML",{value:t.clipboardData.getData("text/plain")}),void t.preventDefault()):(i=this.selection(),i.placeMarker(),e=jQuery("#mercury_sanitizer",this.document).focus(),setTimeout(function(t){return function(){var n;return n=t.sanitize(e),i.selectMarker(t.element),i.removeMarker(),t.element.focus(),t.execCommand("insertHTML",{value:n})}}(this),1))},n.prototype.sanitize=function(t){var e,n,r,o,s,a,l,u,c,h,p,d,f,m;if(t.find("["+Mercury.config.regions.attribute+"]").remove(),t.find('[src*="webkit-fake-url://"]').remove(),Mercury.config.pasting.sanitize)switch(Mercury.config.pasting.sanitize){case"blacklist":t.find("[style]").removeAttr("style"),t.find('[class="Apple-style-span"]').removeClass("Apple-style-span"),s=t.html();break;case"whitelist":for(p=t.find("*"),l=0,c=p.length;c>l;l++){a=p[l],e=!1,d=Mercury.config.pasting.whitelist;for(r in d)if(n=d[r],a.tagName.toLowerCase()===r.toLowerCase()){for(e=!0,f=jQuery(a.attributes),u=0,h=f.length;h>u;u++)o=f[u],m=o.name,i.call(n,m)<0&&jQuery(a).removeAttr(o.name);break}e||jQuery(a).replaceWith(jQuery(a).contents())}s=t.html();break;default:s=t.text()}else s=t.html(),(s.indexOf("<!--StartFragment-->")>-1||s.indexOf('="mso-')>-1||s.indexOf("<o:")>-1||s.indexOf('="Mso')>-1)&&(s=t.text());return t.html(""),s},n.actions={insertRowBefore:function(){return Mercury.tableEditor.addRow("before")},insertRowAfter:function(){return Mercury.tableEditor.addRow("after")},insertColumnBefore:function(){return Mercury.tableEditor.addColumn("before")},insertColumnAfter:function(){return Mercury.tableEditor.addColumn("after")},deleteColumn:function(){return Mercury.tableEditor.removeColumn()},deleteRow:function(){return Mercury.tableEditor.removeRow()},increaseColspan:function(){return Mercury.tableEditor.increaseColspan()},decreaseColspan:function(){return Mercury.tableEditor.decreaseColspan()},increaseRowspan:function(){return Mercury.tableEditor.increaseRowspan()},decreaseRowspan:function(){return Mercury.tableEditor.decreaseRowspan()},undo:function(){return this.content(this.history.undo())},redo:function(){return this.content(this.history.redo())},horizontalRule:function(){return this.execCommand("insertHTML",{value:"<hr/>"})},removeFormatting:function(t){return t.insertTextNode(t.textContent())},backColor:function(t,e){return t.wrap('<span style="background-color:'+e.value.toHex()+'">',!0);
  },overline:function(t){return t.wrap('<span style="text-decoration:overline">',!0)},style:function(t,e){return t.wrap('<span class="'+e.value+'">',!0)},replaceHTML:function(t,e){return this.content(e.value)},insertImage:function(t,e){return this.execCommand("insertHTML",{value:jQuery("<img/>",e.value)})},insertTable:function(t,e){return this.execCommand("insertHTML",{value:e.value})},insertLink:function(t,e){var i;return i=jQuery("<"+e.value.tagName+">",this.document).attr(e.value.attrs).html(e.value.content),t.insertNode(i)},replaceLink:function(t,e){var i,n;return i=jQuery("<"+e.value.tagName+">",this.document).attr(e.value.attrs).html(e.value.content),t.selectNode(e.node),n=jQuery("<div>").html(t.content()).find("a").html(),t.replace(jQuery(i,t.context).html(n))},insertSnippet:function(t,e){var i,n;return n=e.value,(i=this.element.find("[data-snippet="+n.identity+"]")).length&&t.selectNode(i.get(0)),t.insertNode(n.getHTML(this.document))},editSnippet:function(){var t;if(this.snippet)return t=Mercury.Snippet.find(this.snippet.data("snippet")),t.displayOptions()},removeSnippet:function(){return this.snippet&&this.snippet.remove(),Mercury.trigger("hide:toolbar",{type:"snippet",immediately:!0})}},n}(Mercury.Region),Mercury.Regions.Full.Selection=function(){function t(t,e){this.selection=t,this.context=e,this.selection.rangeCount>=1&&(this.range=this.selection.getRangeAt(0),this.fragment=this.range.cloneContents(),this.clone=this.range.cloneRange(),this.collapsed=this.selection.isCollapsed)}return t.prototype.commonAncestor=function(t){var e;return null==t&&(t=!1),this.range?(e=this.range.commonAncestorContainer,3===e.nodeType&&t&&(e=e.parentNode),jQuery(e)):null},t.prototype.wrap=function(t,e){return null==e&&(e=!1),t=jQuery(t,this.context).html(this.fragment),e&&this.replace(t),t},t.prototype.textContent=function(){return this.content().textContent},t.prototype.htmlContent=function(){var t;return t=this.content(),jQuery("<div>").html(t).html()},t.prototype.content=function(){return this.range.cloneContents()},t.prototype.is=function(t){var e;return e=this.content(),1===jQuery(e).length&&jQuery(e.firstChild).is(t)?jQuery(e.firstChild):!1},t.prototype.forceSelection=function(t){var e,i;if(jQuery.browser.webkit)return i=this.context.createRange(),this.range?this.commonAncestor(!0).closest("[data-snippet]").length&&(e=this.context.createTextNode("\x00"),t.appendChild(e)):t.lastChild&&3===t.lastChild.nodeType&&""===t.lastChild.textContent.replace(/^[\s+|\n+]|[\s+|\n+]$/,"")?(e=t.lastChild,t.lastChild.textContent="\x00"):(e=this.context.createTextNode("\x00"),t.appendChild(e)),e?(i.setStartBefore(e),i.setEndBefore(e),this.selection.addRange(i)):void 0},t.prototype.selectMarker=function(t){var e,i;return e=t.find("em.mercury-marker"),e.length?(i=this.context.createRange(),i.setStartBefore(e.get(0)),e.length>=2&&i.setEndBefore(e.get(1)),e.remove(),this.selection.removeAllRanges(),this.selection.addRange(i)):void 0},t.prototype.placeMarker=function(){var t,e;if(this.range)return this.startMarker=jQuery('<em class="mercury-marker"/>',this.context).get(0),this.endMarker=jQuery('<em class="mercury-marker"/>',this.context).get(0),t=this.range.cloneRange(),t.collapse(!1),t.insertNode(this.endMarker),this.range.collapsed||(e=this.range.cloneRange(),e.collapse(!0),e.insertNode(this.startMarker)),this.selection.removeAllRanges(),this.selection.addRange(this.range)},t.prototype.removeMarker=function(){return jQuery(this.startMarker).remove(),jQuery(this.endMarker).remove()},t.prototype.insertTextNode=function(t){var e;return e=this.context.createTextNode(t),this.range.extractContents(),this.range.insertNode(e),this.range.selectNodeContents(e),this.selection.addRange(this.range)},t.prototype.insertNode=function(t){return t.get&&(t=t.get(0)),"string"===jQuery.type(t)&&(t=jQuery(t,this.context).get(0)),this.range.deleteContents(),this.range.insertNode(t),this.range.selectNodeContents(t),this.selection.addRange(this.range)},t.prototype.selectNode=function(t,e){return null==e&&(e=!1),this.range.selectNode(t),e&&this.selection.removeAllRanges(),this.selection.addRange(this.range)},t.prototype.replace=function(t,e){return t.get&&(t=t.get(0)),"string"===jQuery.type(t)&&(t=jQuery(t,this.context).get(0)),this.range.deleteContents(),this.range.insertNode(t),this.range.selectNodeContents(t),this.selection.addRange(this.range),e?this.range.collapse(!1):void 0},t}()}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Regions.Image=function(e){function i(t,e,n){this.element=t,this.window=e,this.options=null!=n?n:{},i.__super__.constructor.apply(this,arguments)}var n;return t(i,e),i.supported=document.getElementById,i.supportedText="Chrome 10+, Firefox 4+, IE 7+, Safari 5+, Opera 8+",n="image",i.prototype.type=function(){return n},i.prototype.bindEvents=function(){return Mercury.on("mode",function(t){return function(e,i){return"preview"===i.mode?t.togglePreview():void 0}}(this)),Mercury.on("focus:frame",function(t){return function(){return t.previewing||Mercury.region!==t?void 0:t.focus()}}(this)),Mercury.on("action",function(t){return function(e,i){return t.previewing||Mercury.region!==t?void 0:i.action?t.execCommand(i.action,i):void 0}}(this)),this.element.on("dragenter",function(t){return function(e){return t.previewing?void 0:(e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy")}}(this)),this.element.on("dragover",function(t){return function(e){return t.previewing?void 0:(e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy")}}(this)),this.element.on("drop",function(t){return function(e){return t.previewing?void 0:e.originalEvent.dataTransfer.files.length?(e.preventDefault(),t.focus(),Mercury.uploader(e.originalEvent.dataTransfer.files[0])):void 0}}(this)),this.element.on("focus",function(t){return function(){return t.focus()}}(this))},i.prototype.togglePreview=function(){return this.previewing?(this.previewing=!1,this.element.attr(Mercury.config.regions.attribute,n),this.build()):(this.previewing=!0,this.element.removeAttr(Mercury.config.regions.attribute),Mercury.trigger("region:blurred",{region:this}))},i.prototype.focus=function(){return this.previewing?void 0:(Mercury.region=this,Mercury.trigger("region:focused",{region:this}),Mercury.trigger("region:update",{region:this}))},i.prototype.execCommand=function(t,e){var n;return null==e&&(e={}),i.__super__.execCommand.apply(this,arguments),(n=Mercury.Regions.Image.actions[t])?n.call(this,e):void 0},i.prototype.pushHistory=function(){return this.history.push({src:this.element.attr("src")})},i.prototype.updateSrc=function(t){return this.element.attr("src",t)},i.prototype.serialize=function(){return{type:n,data:this.dataAttributes(),attributes:{src:this.element.attr("src")}}},i.actions={undo:function(){var t;return(t=this.history.undo())?this.updateSrc(t.src):void 0},redo:function(){var t;return(t=this.history.redo())?this.updateSrc(t.src):void 0},insertImage:function(t){return this.updateSrc(t.value.src)}},i}(Mercury.Region)}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Regions.Markdown=function(e){function i(t,e,n){this.element=t,this.window=e,this.options=null!=n?n:{},i.__super__.constructor.apply(this,arguments),this.converter=new Showdown.converter}var n;return t(i,e),i.supported=document.getElementById,i.supportedText="Chrome 10+, Firefox 4+, IE 7+, Safari 5+, Opera 8+",n="markdown",i.prototype.type=function(){return n},i.prototype.build=function(){var t,e,i;return i="100%",t=this.element.height(),e=this.element.html().replace(/^\s+|\s+$/g,"").replace("&gt;",">"),this.textarea=jQuery("<textarea>",this.document).val(e).addClass("mercury-textarea"),this.textarea.css({border:0,background:"transparent",display:"block","overflow-y":"hidden",width:i,height:t,fontFamily:'"Courier New", Courier, monospace'}),this.element.empty().append(this.textarea),this.previewElement=jQuery("<div>",this.document),this.element.append(this.previewElement),this.container=this.element,this.container.data("region",this),this.element=this.textarea,this.resize()},i.prototype.dataAttributes=function(){var t,e,i,n,r;for(e={},r=Mercury.config.regions.dataAttributes,i=0,n=r.length;n>i;i++)t=r[i],e[t]=this.container.attr("data-"+t);return e},i.prototype.bindEvents=function(){return Mercury.on("mode",function(t){return function(e,i){return"preview"===i.mode?t.togglePreview():void 0}}(this)),Mercury.on("focus:frame",function(t){return function(){return t.previewing||Mercury.region!==t?void 0:t.focus()}}(this)),Mercury.on("action",function(t){return function(e,i){return t.previewing||Mercury.region!==t?void 0:i.action?t.execCommand(i.action,i):void 0}}(this)),Mercury.on("unfocus:regions",function(t){return function(){return t.previewing||Mercury.region!==t?void 0:(t.element.blur(),t.container.removeClass("focus"),Mercury.trigger("region:blurred",{region:t}))}}(this)),this.element.on("dragenter",function(t){return function(e){return t.previewing?void 0:(e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy")}}(this)),this.element.on("dragover",function(t){return function(e){return t.previewing?void 0:(e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy")}}(this)),this.element.on("drop",function(t){return function(e){return t.previewing?void 0:(Mercury.snippet&&(e.preventDefault(),t.focus(),Mercury.Snippet.displayOptionsFor(Mercury.snippet.name,{},Mercury.snippet.hasOptions)),e.originalEvent.dataTransfer.files.length?(e.preventDefault(),t.focus(),Mercury.uploader(e.originalEvent.dataTransfer.files[0])):void 0)}}(this)),this.element.on("focus",function(t){return function(){return t.previewing?void 0:(Mercury.region=t,t.container.addClass("focus"),Mercury.trigger("region:focused",{region:t}))}}(this)),this.element.on("keydown",function(t){return function(e){var i,n,r,o,s,a;if(!t.previewing){switch(t.resize(),e.keyCode){case 90:if(!e.metaKey)return;return e.preventDefault(),void(e.shiftKey?t.execCommand("redo"):t.execCommand("undo"));case 13:o=t.selection(),a=t.element.val(),s=a.lastIndexOf("\n",o.start),i=a.indexOf("\n",o.end),s>i&&(i=a.length),"\n"===a[s]&&(s=a.lastIndexOf("\n",o.start-1)),"-"===a[s+1]&&(o.replace("\n- ",!1,!0),e.preventDefault()),/\d/.test(a[s+1])&&(n=a.substring(s,i),/(\d+)\./.test(n)&&(r=parseInt(RegExp.$1),o.replace("\n"+(r+=1)+". ",!1,!0),e.preventDefault()));break;case 9:e.preventDefault(),t.execCommand("insertHTML",{value:"  "})}if(e.metaKey)switch(e.keyCode){case 66:t.execCommand("bold"),e.preventDefault();break;case 73:t.execCommand("italic"),e.preventDefault();break;case 85:t.execCommand("underline"),e.preventDefault()}return t.pushHistory(e.keyCode)}}}(this)),this.element.on("keyup",function(t){return function(){return t.previewing?void 0:(Mercury.changes=!0,t.resize(),Mercury.trigger("region:update",{region:t}))}}(this)),this.element.on("mouseup",function(t){return function(){return t.previewing?void 0:(t.focus(),Mercury.trigger("region:focused",{region:t}))}}(this)),this.previewElement.on("click",function(t){return function(e){return t.previewing?$(e.target).closest("a").attr("target","_parent"):void 0}}(this))},i.prototype.focus=function(){return this.element.focus()},i.prototype.content=function(t,e){return null==t&&(t=null),null==e&&(e=!0),null!==t?"string"===jQuery.type(t)?this.element.val(t):(this.element.val(t.html),this.selection().select(t.selection.start,t.selection.end)):this.element.val()},i.prototype.contentAndSelection=function(){return{html:this.content(null,!1),selection:this.selection().serialize()}},i.prototype.togglePreview=function(){var t;return this.previewing?(this.previewing=!1,this.container.attr(Mercury.config.regions.attribute,n),this.previewElement.hide(),this.element.show(),Mercury.region===this?this.focus():void 0):(this.previewing=!0,this.container.removeAttr(Mercury.config.regions.attribute),t=this.converter.makeHtml(this.element.val()),this.previewElement.html(t),this.previewElement.show(),this.element.hide(),Mercury.trigger("region:blurred",{region:this}))},i.prototype.execCommand=function(t,e){var n;return null==e&&(e={}),i.__super__.execCommand.apply(this,arguments),(n=Mercury.Regions.Markdown.actions[t])&&n.call(this,this.selection(),e),this.resize()},i.prototype.pushHistory=function(t){var e,i,n;return e=[13,46,8],n=2.5,t&&(i=e.indexOf(t)),clearTimeout(this.historyTimeout),i>=0&&i!==this.lastKnownKeyCode?this.history.push(this.contentAndSelection()):t?this.historyTimeout=setTimeout(function(t){return function(){return t.history.push(t.contentAndSelection())}}(this),1e3*n):this.history.push(this.contentAndSelection()),this.lastKnownKeyCode=i},i.prototype.selection=function(){return new Mercury.Regions.Markdown.Selection(this.element)},i.prototype.resize=function(){return this.element.css({height:this.element.get(0).scrollHeight-100}),this.element.css({height:this.element.get(0).scrollHeight})},i.prototype.snippets=function(){},i.actions={undo:function(){return this.content(this.history.undo())},redo:function(){return this.content(this.history.redo())},insertHTML:function(t,e){var i;return e.value.get&&(i=e.value.get(0))&&(e.value=jQuery("<div>").html(i).html()),t.replace(e.value,!1,!0)},insertImage:function(t,e){return t.replace("![add alt text]("+encodeURI(e.value.src)+")",!0)},insertTable:function(t,e){return t.replace(e.value.replace(/<br>|<br\/>/gi,""),!1,!0)},insertLink:function(t,e){return t.replace("["+e.value.content+"]("+e.value.attrs.href+" 'optional title')",!0)},insertUnorderedList:function(t){return t.addList("unordered")},insertOrderedList:function(t){return t.addList("ordered")},style:function(t,e){return t.wrap('<span class="'+e.value+'">',"</span>")},formatblock:function(t,e){var i,n,r;r={h1:["# "," #"],h2:["## "," ##"],h3:["### "," ###"],h4:["#### "," ####"],h5:["##### "," #####"],h6:["###### "," ######"],pre:["    ",""],blockquote:["> ",""],p:["\n","\n"]};for(n in r)i=r[n],t.unWrapLine(""+i[0],""+i[1]);return"blockquote"===e.value?void Mercury.Regions.Markdown.actions.indent.call(this,t,e):t.wrapLine(""+r[e.value][0],""+r[e.value][1])},bold:function(t){return t.wrap("**","**")},italic:function(t){return t.wrap("_","_")},subscript:function(t){return t.wrap("<sub>","</sub>")},superscript:function(t){return t.wrap("<sup>","</sup>")},indent:function(t){return t.wrapLine("> ","",!1,!0)},outdent:function(t){return t.unWrapLine("> ","",!1,!0)},horizontalRule:function(t){return t.replace("\n- - -\n")},insertSnippet:function(t,e){var i;return i=e.value,t.replace(i.getText())}},i}(Mercury.Region),Mercury.Regions.Markdown.Selection=function(){function t(t){this.element=t,this.el=this.element.get(0),this.getDetails()}return t.prototype.serialize=function(){return{start:this.start,end:this.end}},t.prototype.getDetails=function(){return this.length=this.el.selectionEnd-this.el.selectionStart,this.start=this.el.selectionStart,this.end=this.el.selectionEnd,this.text=this.element.val().substr(this.start,this.length)},t.prototype.replace=function(t,e,i){var n,r,o;return null==e&&(e=!1),null==i&&(i=!1),this.getDetails(),o=this.element.val(),r=this.element.val(),this.element.val(o.substr(0,this.start)+t+o.substr(this.end,o.length)),n=this.element.val()!==r,e&&this.select(this.start,this.start+t.length),i&&this.select(this.start+t.length,this.start+t.length),n},t.prototype.select=function(t,e){return this.start=t,this.end=e,this.element.focus(),this.el.selectionStart=this.start,this.el.selectionEnd=this.end,this.getDetails()},t.prototype.wrap=function(t,e){return this.getDetails(),this.deselectNewLines(),this.replace(t+this.text+e,""!==this.text),""===this.text?this.select(this.start+t.length,this.start+t.length):void 0},t.prototype.wrapLine=function(t,e,i,n){var r,o,s,a;return null==i&&(i=!0),null==n&&(n=!1),this.getDetails(),o=this.serialize(),a=this.element.val(),s=a.lastIndexOf("\n",this.start),r=a.indexOf("\n",this.end),s>r&&(r=a.length),"\n"===a[s]&&(s=a.lastIndexOf("\n",this.start-1)),this.select(s+1,r),this.replace(t+this.text+e,i),n?this.select(o.start+t.length,o.end+t.length):void 0},t.prototype.unWrapLine=function(t,e,i,n){var r,o,s,a,l,u,c;return null==i&&(i=!0),null==n&&(n=!1),this.getDetails(),l=this.serialize(),c=this.element.val(),u=c.lastIndexOf("\n",this.start),o=c.indexOf("\n",this.end),u>o&&(o=c.length),"\n"===c[u]&&(u=c.lastIndexOf("\n",this.start-1)),this.select(u+1,o),window.something=this.text,s=new RegExp("^"+t.regExpEscape()),a=new RegExp(e.regExpEscape()+"$"),r=this.replace(this.text.replace(s,"").replace(a,""),i),n&&r?this.select(l.start-t.length,l.end-t.length):void 0},t.prototype.addList=function(t){var e,i,n,r,o,s;return s=this.element.val(),o=s.lastIndexOf("\n",this.start),e=s.indexOf("\n",this.end),o>e&&(e=s.length),"\n"===s[o]&&(o=s.lastIndexOf("\n",this.start-1)),this.select(o+1,e),r=this.text.split("\n"),"unordered"===t?this.replace("- "+r.join("\n- "),!0):this.replace(function(){var t,e,o;for(o=[],i=t=0,e=r.length;e>t;i=++t)n=r[i],o.push(i+1+". "+n);return o}().join("\n"),!0)},t.prototype.deselectNewLines=function(){var t,e;return e=this.text,t=e.replace(/\n+$/g,"").length,this.select(this.start,this.start+t)},t.prototype.placeMarker=function(){return this.wrap("[mercury-marker]","[mercury-marker]")},t.prototype.removeMarker=function(){var t,e,i;return i=this.element.val(),e=i.indexOf("[mercury-marker]"),e>-1?(t=i.indexOf("[mercury-marker]",e+1)-"[mercury-marker]".length,this.element.val(this.element.val().replace(/\[mercury-marker\]/g,"")),this.select(e,t)):void 0},t.prototype.textContent=function(){return this.text},t}()}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Regions.Simple=function(e){function i(t,e,r){this.element=t,this.window=e,this.options=null!=r?r:{},Mercury.log("building "+n,this.element,this.options),i.__super__.constructor.apply(this,arguments)}var n;return t(i,e),i.supported=document.getElementById,i.supportedText="Chrome 10+, Firefox 4+, IE 7+, Safari 5+, Opera 8+",n="simple",i.prototype.type=function(){return n},i.prototype.build=function(){var t,e,i;return"block"===this.element.css("display")?(i="100%",t=this.element.height()):(i=this.element.width(),t=this.element.height()),e=this.element.text(),this.textarea=jQuery("<textarea>",this.document).val(e).addClass("mercury-textarea"),this.textarea.css({border:0,background:"transparent","overflow-y":"hidden",width:i,height:t,fontFamily:"inherit",fontSize:"inherit",fontWeight:"inherit",fontStyle:"inherit",color:"inherit","min-height":0,padding:"0",margin:0,"border-radius":0,display:"inherit",lineHeight:"inherit",textAlign:"inherit"}),this.element.empty().append(this.textarea),this.container=this.element,this.container.data("region",this),this.element=this.textarea,this.resize()},i.prototype.bindEvents=function(){return Mercury.on("mode",function(t){return function(e,i){return"preview"===i.mode?t.togglePreview():void 0}}(this)),Mercury.on("focus:frame",function(t){return function(){return t.previewing||Mercury.region!==t?void 0:t.focus()}}(this)),Mercury.on("action",function(t){return function(e,i){return t.previewing||Mercury.region!==t?void 0:i.action?t.execCommand(i.action,i):void 0}}(this)),Mercury.on("unfocus:regions",function(t){return function(){return t.previewing||Mercury.region!==t?void 0:(t.element.blur(),t.container.removeClass("focus"),Mercury.trigger("region:blurred",{region:t}))}}(this)),this.bindElementEvents()},i.prototype.bindElementEvents=function(){return this.element.on("focus",function(t){return function(){return t.previewing?void 0:(Mercury.region=t,t.container.addClass("focus"),Mercury.trigger("region:focused",{region:t}))}}(this)),this.element.on("keydown",function(t){return function(e){var i,n,r,o,s,a;if(!t.previewing){switch(t.resize(),e.keyCode){case 90:if(!e.metaKey)return;return e.preventDefault(),void(e.shiftKey?t.execCommand("redo"):t.execCommand("undo"));case 13:o=t.selection(),a=t.element.val(),s=a.lastIndexOf("\n",o.start),i=a.indexOf("\n",o.end),s>i&&(i=a.length),"\n"===a[s]&&(s=a.lastIndexOf("\n",o.start-1)),"-"===a[s+1]&&o.replace("\n- ",!1,!0),/\d/.test(a[s+1])&&(n=a.substring(s,i),/(\d+)\./.test(n)&&(r=parseInt(RegExp.$1),o.replace("\n"+(r+=1)+". ",!1,!0))),e.preventDefault();break;case 9:e.preventDefault(),t.execCommand("insertHTML",{value:"  "})}return t.pushHistory(e.keyCode)}}}(this)),this.element.on("keyup",function(t){return function(){return t.previewing?void 0:(Mercury.changes=!0,t.resize(),Mercury.trigger("region:update",{region:t}))}}(this)),this.element.on("mouseup",function(t){return function(){return t.previewing?void 0:(t.focus(),Mercury.trigger("region:focused",{region:t}))}}(this)),this.element.on("paste",function(t){return function(e){if(!t.previewing&&Mercury.region===t){if(t.specialContainer)return void e.preventDefault();if(!t.pasting)return Mercury.changes=!0,t.handlePaste(e.originalEvent)}}}(this))},i.prototype.handlePaste=function(t){this.execCommand("insertHTML",{value:t.clipboardData.getData("text/plain").replace(/\n/g," ")}),t.preventDefault()},i.prototype.path=function(){return[this.container.get(0)]},i.prototype.focus=function(){return this.element.focus()},i.prototype.content=function(t,e){return null==t&&(t=null),null==e&&(e=!0),null!==t?"string"===jQuery.type(t)?this.element.val(t):(this.element.val(t.html),this.selection().select(t.selection.start,t.selection.end)):this.element.val()},i.prototype.contentAndSelection=function(){return{html:this.content(null,!1),selection:this.selection().serialize()}},i.prototype.togglePreview=function(){var t;return this.previewing?(this.previewing=!1,this.element=this.container,this.container.attr(Mercury.config.regions.attribute,n),this.build(),this.bindElementEvents(),Mercury.region===this?this.focus():void 0):(this.previewing=!0,t=jQuery("<div></div>").text(this.element.val()).html(),this.container.removeAttr(Mercury.config.regions.attribute),this.container.html(t),Mercury.trigger("region:blurred",{region:this}))},i.prototype.execCommand=function(t,e){var n;return null==e&&(e={}),i.__super__.execCommand.apply(this,arguments),(n=Mercury.Regions.Simple.actions[t])&&n.call(this,this.selection(),e),this.resize()},i.prototype.pushHistory=function(t){var e,i,n;return e=[13,46,8],n=2.5,t&&(i=e.indexOf(t)),clearTimeout(this.historyTimeout),i>=0&&i!==this.lastKnownKeyCode?this.history.push(this.contentAndSelection()):t?this.historyTimeout=setTimeout(function(t){return function(){return t.history.push(t.contentAndSelection())}}(this),1e3*n):this.history.push(this.contentAndSelection()),this.lastKnownKeyCode=i},i.prototype.selection=function(){return new Mercury.Regions.Simple.Selection(this.element)},i.prototype.resize=function(){return this.element.css({height:this.element.get(0).scrollHeight-100}),this.element.css({height:this.element.get(0).scrollHeight})},i.prototype.snippets=function(){},i.actions={undo:function(){return this.content(this.history.undo())},redo:function(){return this.content(this.history.redo())},insertHTML:function(t,e){var i;return e.value.get&&(i=e.value.get(0))&&(e.value=jQuery("<div>").html(i).html()),t.replace(e.value,!1,!0)}},i}(Mercury.Region),Mercury.Regions.Simple.Selection=function(){function t(t){this.element=t,this.el=this.element.get(0),this.getDetails()}return t.prototype.serialize=function(){return{start:this.start,end:this.end}},t.prototype.getDetails=function(){return this.length=this.el.selectionEnd-this.el.selectionStart,this.start=this.el.selectionStart,this.end=this.el.selectionEnd,this.text=this.element.val().substr(this.start,this.length)},t.prototype.replace=function(t,e,i){var n,r,o;return null==e&&(e=!1),null==i&&(i=!1),this.getDetails(),o=this.element.val(),r=this.element.val(),this.element.val(o.substr(0,this.start)+t+o.substr(this.end,o.length)),n=this.element.val()!==r,e&&this.select(this.start,this.start+t.length),i&&this.select(this.start+t.length,this.start+t.length),n},t.prototype.select=function(t,e){return this.start=t,this.end=e,this.element.focus(),this.el.selectionStart=this.start,this.el.selectionEnd=this.end,this.getDetails()},t.prototype.wrap=function(t,e){return this.getDetails(),this.deselectNewLines(),this.replace(t+this.text+e,""!==this.text),""===this.text?this.select(this.start+t.length,this.start+t.length):void 0},t.prototype.deselectNewLines=function(){var t,e;return e=this.text,t=e.replace(/\n+$/g,"").length,this.select(this.start,this.start+t)},t.prototype.placeMarker=function(){return this.wrap("[mercury-marker]","[mercury-marker]")},t.prototype.removeMarker=function(){var t,e,i;return i=this.element.val(),e=i.indexOf("[mercury-marker]"),e>-1?(t=i.indexOf("[mercury-marker]",e+1)-"[mercury-marker]".length,this.element.val(this.element.val().replace(/\[mercury-marker\]/g,"")),this.select(e,t)):void 0},t.prototype.textContent=function(){return this.text},t}()}.call(this),function(){var t=function(t,i){function n(){this.constructor=t}for(var r in i)e.call(i,r)&&(t[r]=i[r]);return n.prototype=i.prototype,t.prototype=new n,t.__super__=i.prototype,t},e={}.hasOwnProperty;this.Mercury.Regions.Snippets=function(e){function i(t,e,r){this.element=t,this.window=e,this.options=null!=r?r:{},Mercury.log("building "+n,this.element,this.options),i.__super__.constructor.apply(this,arguments),this.makeSortable()}var n;return t(i,e),i.supported=document.getElementById,i.supportedText="Chrome 10+, Firefox 4+, IE 7+, Safari 5+, Opera 8+",n="snippets",i.prototype.type=function(){return n},i.prototype.build=function(){var t,e,i,n;for(i=this.element.find("[data-snippet]"),t=0,e=i.length;e>t;t++)n=i[t],jQuery(n).attr("data-version",0);return"0px"===this.element.css("minHeight")?this.element.css({minHeight:20}):void 0},i.prototype.bindEvents=function(){return i.__super__.bindEvents.apply(this,arguments),Mercury.on("unfocus:regions",function(t){return function(e){return t.previewing?void 0:Mercury.region===t?(t.element.removeClass("focus"),t.element.sortable("destroy"),Mercury.trigger("region:blurred",{region:t})):void 0}}(this)),Mercury.on("focus:window",function(t){return function(e){return t.previewing?void 0:Mercury.region===t?(t.element.removeClass("focus"),t.element.sortable("destroy"),Mercury.trigger("region:blurred",{region:t})):void 0}}(this)),this.element.on("mouseup",function(t){return function(){return t.previewing?void 0:(t.focus(),Mercury.trigger("region:focused",{region:t}))}}(this)),this.element.on("dragover",function(t){return function(e){return t.previewing?void 0:(e.preventDefault(),e.originalEvent.dataTransfer.dropEffect="copy")}}(this)),this.element.on("drop",function(t){return function(e){return!t.previewing&&Mercury.snippet?(t.focus(),e.preventDefault(),Mercury.Snippet.displayOptionsFor(Mercury.snippet.name,{},Mercury.snippet.hasOptions)):void 0}}(this)),jQuery(this.document).on("keydown",function(t){return function(e){if(!t.previewing&&Mercury.region===t)switch(e.keyCode){case 90:if(!e.metaKey)return;return e.preventDefault(),e.shiftKey?t.execCommand("redo"):t.execCommand("undo")}}}(this)),jQuery(this.document).on("keyup",function(t){return function(){return t.previewing||Mercury.region!==t?void 0:Mercury.changes=!0}}(this))},i.prototype.focus=function(){return Mercury.region=this,this.makeSortable(),this.element.addClass("focus")},i.prototype.togglePreview=function(){return this.previewing?this.makeSortable():(this.element.sortable("destroy"),this.element.removeClass("focus")),i.__super__.togglePreview.apply(this,arguments)},i.prototype.execCommand=function(t,e){var n;return null==e&&(e={}),i.__super__.execCommand.apply(this,arguments),(n=Mercury.Regions.Snippets.actions[t])?n.call(this,e):void 0},i.prototype.makeSortable=function(){return this.element.sortable("destroy").sortable({document:this.document,scroll:!1,containment:"parent",items:"[data-snippet]",opacity:.4,revert:100,tolerance:"pointer",beforeStop:function(t){return function(){return Mercury.trigger("hide:toolbar",{type:"snippet",immediately:!0}),!0}}(this),stop:function(t){return function(){return setTimeout(function(){return t.pushHistory()},100),!0}}(this)})},i.actions={undo:function(){return this.content(this.history.undo())},redo:function(){return this.content(this.history.redo())},insertSnippet:function(t){var e,i;return i=t.value,(e=this.element.find("[data-snippet="+i.identity+"]")).length?e.replaceWith(i.getHTML(this.document,function(t){return function(){return t.pushHistory()}}(this))):this.element.append(i.getHTML(this.document,function(t){return function(){return t.pushHistory()}}(this)))},editSnippet:function(){var t;if(this.snippet)return t=Mercury.Snippet.find(this.snippet.data("snippet")),t.displayOptions()},removeSnippet:function(){return this.snippet&&this.snippet.remove(),Mercury.trigger("hide:toolbar",{type:"snippet",immediately:!0})}},i}(Mercury.Region)}.call(this),function(){this.Mercury.dialogHandlers.backColor=function(){return this.element.find(".picker, .last-picked").on("click",function(t){return function(e){var i;return i=jQuery(e.target).css("background-color"),t.element.find(".last-picked").css({background:i}),t.button.css({backgroundColor:i}),Mercury.trigger("action",{action:"backColor",value:i})}}(this))}}.call(this),function(){this.Mercury.dialogHandlers.foreColor=function(){return this.element.find(".picker, .last-picked").on("click",function(t){return function(e){var i;return i=jQuery(e.target).css("background-color").toHex(),t.element.find(".last-picked").css({background:i}),t.button.css({backgroundColor:i}),Mercury.trigger("action",{action:"foreColor",value:i})}}(this))}}.call(this),function(){this.Mercury.dialogHandlers.formatblock=function(){return this.element.find("[data-tag]").on("click",function(t){return function(t){var e;return e=jQuery(t.target).data("tag"),Mercury.trigger("action",{action:"formatblock",value:e})}}(this))}}.call(this),function(){this.Mercury.dialogHandlers.snippetPanel=function(){return this.element.find("input.filter").on("keyup",function(t){return function(){var e,i,n,r,o,s;for(s=t.element.find("input.filter").val(),n=t.element.find("li[data-filter]"),r=[],e=0,i=n.length;i>e;e++)o=n[e],0===LiquidMetal.score(jQuery(o).data("filter"),s)?r.push(jQuery(o).hide()):r.push(jQuery(o).show());return r}}(this)),this.element.find("img[data-snippet]").on("dragstart",function(){return Mercury.snippet={name:jQuery(this).data("snippet"),hasOptions:!(jQuery(this).data("options")===!1)}})}}.call(this),function(){this.Mercury.dialogHandlers.style=function(){return this.element.find("[data-class]").on("click",function(t){return function(t){var e;return e=jQuery(t.target).data("class"),Mercury.trigger("action",{action:"style",value:e})}}(this))}}.call(this),function(){this.Mercury.modalHandlers.htmlEditor=function(){var t;return t=Mercury.region.content(null,!0,!1),this.element.find("textarea").val(t),this.element.find("form").on("submit",function(t){return function(e){var i;return e.preventDefault(),i=t.element.find("textarea").val(),Mercury.trigger("action",{action:"replaceHTML",value:i}),t.hide()}}(this))}}.call(this),function(){this.Mercury.modalHandlers.insertCharacter=function(){return this.element.find(".character").on("click",function(t){return function(e){return Mercury.trigger("action",{action:"insertHTML",value:"&"+jQuery(e.target).attr("data-entity")+";"}),t.hide()}}(this))}}.call(this),function(){this.Mercury.modalHandlers.insertLink={initialize:function(){return this.editing=!1,this.content=null,this.element.find(".control-label input").on("click",this.onLabelChecked),this.element.find(".controls .optional, .controls .required").on("focus",this.onInputFocused),this.element.find("#link_target").on("change",function(t){return function(){return t.onChangeTarget()}}(this)),this.initializeForm(),this.element.find("form").on("submit",function(t){return function(e){return e.preventDefault(),t.validateForm(),t.valid?(t.submitForm(),t.hide()):void t.resize()}}(this))},initializeForm:function(){var t,e,i,n,r,o;return this.fillExistingBookmarks(),Mercury.region&&Mercury.region.selection?(o=Mercury.region.selection(),o.textContent&&this.element.find("#link_text").val(o.textContent()),o&&o.commonAncestor&&(t=o.commonAncestor(!0).closest("a")),o.htmlContent&&(n=/<img/.test(o.htmlContent())),n||t&&t.length?(this.element.find("#link_text_container").hide(),n&&(this.content=o.htmlContent()),t&&t.length?(this.editing=t,t.attr("href")&&0===t.attr("href").indexOf("#")?(e=this.element.find("#link_existing_bookmark"),
  e.val(t.attr("href").replace(/[^#]*#/,"")),e.closest(".control-group").find("input[type=radio]").prop("checked",!0)):this.element.find("#link_external_url").val(t.attr("href")),t.attr("name")&&(r=this.element.find("#link_new_bookmark"),r.val(t.attr("name")),r.closest(".control-group").find("input[type=radio]").prop("checked",!0)),t.attr("target")&&this.element.find("#link_target").val(t.attr("target")),t.attr("href")&&0===t.attr("href").indexOf("javascript:void")?(i=t.attr("href"),this.element.find("#link_external_url").val(i.match(/window.open\('([^']+)',/)[1]),this.element.find("#link_target").val("popup"),this.element.find("#link_popup_width").val(i.match(/width=(\d+),/)[1]),this.element.find("#link_popup_height").val(i.match(/height=(\d+),/)[1]),this.element.find("#popup_options").show()):void 0):!1):!1):void 0},fillExistingBookmarks:function(){var t,e,i,n,r,o;for(t=this.element.find("#link_existing_bookmark"),n=jQuery("a[name]",window.mercuryInstance.document),r=[],e=0,i=n.length;i>e;e++)o=n[e],r.push(t.append(jQuery("<option>",{value:jQuery(o).attr("name")}).text(jQuery(o).text())));return r},onLabelChecked:function(){var t;return t=jQuery(this).closest(".control-label").attr("for"),jQuery(this).closest(".control-group").find("#"+t).focus()},onInputFocused:function(){return jQuery(this).closest(".control-group").find("input[type=radio]").prop("checked",!0)},onChangeTarget:function(){return this.element.find(".link-target-options").hide(),this.element.find("#"+this.element.find("#link_target").val()+"_options").show(),this.resize(!0)},addInputError:function(t,e){return t.after('<span class="help-inline error-message">'+Mercury.I18n(e)+"</span>").closest(".control-group").addClass("error"),this.valid=!1},clearInputErrors:function(){return this.element.find(".control-group.error").removeClass("error").find(".error-message").remove(),this.valid=!0},validateForm:function(){var t,e;return this.clearInputErrors(),e=this.element.find("input[name=link_type]:checked").val(),t=this.element.find("#link_"+e),t.val()||this.addInputError(t,"can't be blank"),this.editing||this.content||(t=this.element.find("#link_text"),t.val())?void 0:this.addInputError(t,"can't be blank")},submitForm:function(){var t,e,i,n,r,o;switch(i=this.element.find("#link_text").val(),n=this.element.find("#link_target").val(),r=this.element.find("input[name=link_type]:checked").val()){case"existing_bookmark":e={href:"#"+this.element.find("#link_existing_bookmark").val()};break;case"new_bookmark":e={name:""+this.element.find("#link_new_bookmark").val()};break;default:e={href:this.element.find("#link_"+r).val()}}switch(n){case"popup":t={width:parseInt(this.element.find("#link_popup_width").val())||500,height:parseInt(this.element.find("#link_popup_height").val())||500,menubar:"no",toolbar:"no"},e.href="javascript:void(window.open('"+e.href+"', 'popup_window', '"+jQuery.param(t).replace(/&/g,",")+"'))";break;default:n&&(e.target=n)}return o={tagName:"a",attrs:e,content:this.content||i},this.editing?Mercury.trigger("action",{action:"replaceLink",value:o,node:this.editing.get(0)}):Mercury.trigger("action",{action:"insertLink",value:o})}}}.call(this),function(){this.Mercury.modalHandlers.insertMedia={initialize:function(){return this.element.find(".control-label input").on("click",this.onLabelChecked),this.element.find(".controls .optional, .controls .required").on("focus",function(t){return function(e){return t.onInputFocused($(e.target))}}(this)),this.focus("#media_image_url"),this.initializeForm(),this.element.find("form").on("submit",function(t){return function(e){return e.preventDefault(),t.validateForm(),t.valid?(t.submitForm(),t.hide()):void t.resize()}}(this))},initializeForm:function(){var t,e,i,n;if(Mercury.region&&Mercury.region.selection&&(i=Mercury.region.selection(),(e="function"==typeof i.is?i.is("img"):void 0)&&(this.element.find("#media_image_url").val(e.attr("src")),this.element.find("#media_image_alignment").val(e.attr("align")),this.element.find("#media_image_float").val(null!=e.attr("style")?e.css("float"):""),this.element.find("#media_image_width").val(e.width()||""),this.element.find("#media_image_height").val(e.height()||""),this.focus("#media_image_url")),t="function"==typeof i.is?i.is("iframe"):void 0)){if(n=t.attr("src"),/^https?:\/\/www.youtube.com\//i.test(n))return this.element.find("#media_youtube_url").val(n.match(/^https?/)[0]+"://youtu.be/"+n.match(/\/embed\/(\w+)/)[1]),this.element.find("#media_youtube_width").val(t.width()),this.element.find("#media_youtube_height").val(t.height()),this.focus("#media_youtube_url");if(/^https?:\/\/player.vimeo.com\//i.test(n))return this.element.find("#media_vimeo_url").val(n.match(/^https?/)[0]+"://vimeo.com/"+n.match(/\/video\/(\w+)/)[1]),this.element.find("#media_vimeo_width").val(t.width()),this.element.find("#media_vimeo_height").val(t.height()),this.focus("#media_vimeo_url")}},focus:function(t){return setTimeout(function(e){return function(){return e.element.find(t).focus()}}(this),300)},onLabelChecked:function(){var t;return t=jQuery(this).closest(".control-label").attr("for"),jQuery(this).closest(".control-group").find("#"+t).focus()},onInputFocused:function(t){return t.closest(".control-group").find("input[type=radio]").prop("checked",!0),t.closest(".media-options").length?void 0:(this.element.find(".media-options").hide(),this.element.find("#"+t.attr("id").replace("media_","")+"_options").show(),this.resize(!0))},addInputError:function(t,e){return t.after('<span class="help-inline error-message">'+Mercury.I18n(e)+"</span>").closest(".control-group").addClass("error"),this.valid=!1},clearInputErrors:function(){return this.element.find(".control-group.error").removeClass("error").find(".error-message").remove(),this.valid=!0},validateForm:function(){var t,e,i;switch(this.clearInputErrors(),e=this.element.find("input[name=media_type]:checked").val(),t=this.element.find("#media_"+e),e){case"youtube_url":if(i=this.element.find("#media_youtube_url").val(),!/^https?:\/\/youtu.be\//.test(i))return this.addInputError(t,"is invalid");break;case"vimeo_url":if(i=this.element.find("#media_vimeo_url").val(),!/^https?:\/\/vimeo.com\//.test(i))return this.addInputError(t,"is invalid");break;default:if(!t.val())return this.addInputError(t,"can't be blank")}},submitForm:function(){var t,e,i,n,r,o,s,a,l,u;switch(s=this.element.find("input[name=media_type]:checked").val()){case"image_url":return e={src:this.element.find("#media_image_url").val()},(t=this.element.find("#media_image_alignment").val())&&(e.align=t),e.style="",(n=this.element.find("#media_image_float").val())&&(e.style+="float: "+n+"; "),(u=this.element.find("#media_image_width").val())&&(e.style+="width: "+u+"px; "),(r=this.element.find("#media_image_height").val())&&(e.style+="height: "+r+"px;"),Mercury.trigger("action",{action:"insertImage",value:e});case"youtube_url":return a=this.element.find("#media_youtube_url").val(),i=a.replace(/https?:\/\/youtu.be\//,""),o="http",/^https:/.test(a)&&(o="https"),l=jQuery("<iframe>",{width:parseInt(this.element.find("#media_youtube_width").val(),10)||560,height:parseInt(this.element.find("#media_youtube_height").val(),10)||349,src:o+"://www.youtube.com/embed/"+i+"?wmode=transparent",frameborder:0,allowfullscreen:"true"}),Mercury.trigger("action",{action:"insertHTML",value:l});case"vimeo_url":return a=this.element.find("#media_vimeo_url").val(),i=a.replace(/^https?:\/\/vimeo.com\//,""),o="http",/^https:/.test(a)&&(o="https"),l=jQuery("<iframe>",{width:parseInt(this.element.find("#media_vimeo_width").val(),10)||400,height:parseInt(this.element.find("#media_vimeo_height").val(),10)||225,src:o+"://player.vimeo.com/video/"+i+"?title=1&byline=1&portrait=0&color=ffffff",frameborder:0}),Mercury.trigger("action",{action:"insertHTML",value:l})}}}}.call(this),function(){this.Mercury.modalHandlers.insertSnippet=function(){return this.element.find("form").on("submit",function(t){return function(e){var i,n;return e.preventDefault(),i=t.element.find("form").serializeObject(),Mercury.snippet?(n=Mercury.snippet,n.setOptions(i),Mercury.snippet=null):n=Mercury.Snippet.create(t.options.snippetName,i),Mercury.trigger("action",{action:"insertSnippet",value:n}),t.hide()}}(this))}}.call(this),function(){this.Mercury.modalHandlers.insertTable={initialize:function(){return this.table=this.element.find("#table_display table"),this.table.on("click",function(t){return function(e){return t.onCellClick($(e.target))}}(this)),this.element.find("#table_alignment").on("change",function(t){return function(){return t.setTableAlignment()}}(this)),this.element.find("#table_border").on("keyup",function(t){return function(){return t.setTableBorder()}}(this)),this.element.find("#table_spacing").on("keyup",function(t){return function(){return t.setTableCellSpacing()}}(this)),this.element.find("[data-action]").on("click",function(t){return function(e){return e.preventDefault(),t.onActionClick(jQuery(e.target).data("action"))}}(this)),this.selectFirstCell(),this.element.find("form").on("submit",function(t){return function(e){return e.preventDefault(),t.submitForm(),t.hide()}}(this))},selectFirstCell:function(){var t;return t=this.table.find("td, th").first(),t.addClass("selected"),Mercury.tableEditor(this.table,t,"&nbsp;")},onCellClick:function(t){return this.cell=t,this.table=this.cell.closest("table"),this.table.find(".selected").removeAttr("class"),this.cell.addClass("selected"),Mercury.tableEditor(this.table,this.cell,"&nbsp;")},onActionClick:function(t){return t?Mercury.tableEditor[t]():void 0},setTableAlignment:function(){return this.table.attr({align:this.element.find("#table_alignment").val()})},setTableBorder:function(){var t;return t=parseInt(this.element.find("#table_border").val(),10),isNaN(t)?this.table.removeAttr("border"):this.table.attr({border:t})},setTableCellSpacing:function(){var t;return t=parseInt(this.element.find("#table_spacing").val(),10),isNaN(t)?this.table.removeAttr("cellspacing"):this.table.attr({cellspacing:t})},submitForm:function(){var t,e;return this.table.find(".selected").removeAttr("class"),this.table.find("td, th").html("<br/>"),t=jQuery("<div>").html(this.table).html(),e=t.replace(/^\s+|\n/gm,"").replace(/(<\/.*?>|<table.*?>|<tbody>|<tr>)/g,"$1\n"),Mercury.trigger("action",{action:"insertTable",value:e})}}}.call(this),function(){Mercury.onload&&Mercury.onload(),jQuery(window).trigger("mercury:loaded")}.call(this);