/*

 Redactor v8.2.6
 Updated: April 6, 2013

 http://redactorjs.com/

 Copyright (c) 2009-2013, Imperavi Inc.
 License: http://redactorjs.com/license/

 Usage: $('#content').redactor();
*/
var rwindow,rdocument;if("undefined"===typeof RELANG)var RELANG={};
var RLANG={html:"HTML",video:"Insert Video",image:"Insert Image",table:"Table",link:"Link",link_insert:"Insert link",unlink:"Unlink",formatting:"Formatting",paragraph:"Paragraph",quote:"Quote",code:"Code",header1:"Header 1",header2:"Header 2",header3:"Header 3",header4:"Header 4",bold:"Bold",italic:"Italic",fontcolor:"Font Color",backcolor:"Back Color",unorderedlist:"Unordered List",orderedlist:"Ordered List",outdent:"Outdent",indent:"Indent",cancel:"Cancel",insert:"Insert",save:"Save",_delete:"Delete",
insert_table:"Insert Table",insert_row_above:"Add Row Above",insert_row_below:"Add Row Below",insert_column_left:"Add Column Left",insert_column_right:"Add Column Right",delete_column:"Delete Column",delete_row:"Delete Row",delete_table:"Delete Table",rows:"Rows",columns:"Columns",add_head:"Add Head",delete_head:"Delete Head",title:"Title",image_position:"Position",none:"None",left:"Left",right:"Right",image_web_link:"Image Web Link",text:"Text",mailto:"Email",web:"URL",video_html_code:"Video Embed Code",
file:"Insert File",upload:"Upload",download:"Download",choose:"Choose",or_choose:"Or choose",drop_file_here:"Drop file here",align_left:"Align text to the left",align_center:"Center text",align_right:"Align text to the right",align_justify:"Justify text",horizontalrule:"Insert Horizontal Rule",deleted:"Deleted",anchor:"Anchor",link_new_tab:"Open link in new tab",underline:"Underline",alignment:"Alignment"};
(function(b){jQuery.fn.redactor=function(a){return this.each(function(){var c=b(this);c.data("redactor")||c.data("redactor",new l(this,a))})};var l=function(a,c){this.$el=b(a);"undefined"!==typeof c&&"undefined"!==typeof c.lang&&"en"!==c.lang&&"undefined"!==typeof RELANG[c.lang]&&(RLANG=RELANG[c.lang]);this.opts=b.extend({iframe:!1,css:!1,iframeBase:!1,lang:"en",direction:"ltr",callback:!1,keyupCallback:!1,keydownCallback:!1,execCommandCallback:!1,insertHtmlCallback:!1,pastePreventCallback:!1,pasteManipulateCallback:!1,
pasteCleanUpCallback:!1,modalCreateCallback:!1,modalLoadCallback:!1,execCommandHandler:{},plugins:!1,cleanup:!0,focus:!1,tabindex:!1,autoresize:!0,minHeight:!1,fixed:!1,fixedTop:0,fixedBox:!1,source:!0,shortcuts:!0,insertTab:!1,undoSize:30,mobile:!0,air:!1,wym:!1,convertLinks:!0,convertDivs:!0,protocol:"http://",autosave:!1,autosaveCallback:!1,interval:60,imageGetJson:!1,imageUpload:!1,imageUploadCallback:!1,imageUploadErrorCallback:!1,fileUpload:!1,fileUploadCallback:!1,fileUploadErrorCallback:!1,
uploadCrossDomain:!1,uploadFields:!1,observeImages:!0,overlay:!0,allowedTags:"form input button select option datalist output textarea fieldset legend section header hgroup aside footer article details nav progress time canvas code span div label a br p b i del strike u font img video source track audio iframe object embed param blockquote mark cite small ul ol li hr dl dt dd sup sub big pre code figure figcaption strong em table tr td th tbody thead tfoot h1 h2 h3 h4 h5 h6".split(" "),toolbarExternal:!1,
buttonsCustom:{},buttonsAdd:[],buttons:"html | formatting | bold italic deleted | unorderedlist orderedlist outdent indent | image video file table link | fontcolor backcolor | alignment | horizontalrule".split(" "),airButtons:"formatting | bold italic deleted | unorderedlist orderedlist outdent indent | fontcolor backcolor".split(" "),formattingTags:"p blockquote pre h1 h2 h3 h4".split(" "),activeButtons:"deleted italic bold underline unorderedlist orderedlist".split(" "),activeButtonsStates:{b:"bold",
strong:"bold",i:"italic",em:"italic",del:"deleted",strike:"deleted",s:"deleted",ul:"unorderedlist",ol:"orderedlist",u:"underline"},activeButtonStateMap:{bold:"bold",italic:"italic",underline:"underline",deleted:"strikethrough"},allowJustify:!0,cleanupFontTags:!0,colors:"#ffffff #ff9999 #ffcc99 #ffff99 #ccff99 #99ff99 #99ffcc #99ffff #99ccff #9999ff #cc99ff #ff99ff #ff99cc #bfbfbf #ff4d4d #ffa64d #ffff4d #a6ff4d #4dff4d #4dffa6 #4dffff #4da6ff #4d4dff #a64dff #ff4dff #ff4da6 #808080 #ff0000 #ff8000 #ffff00 #80ff00 #00ff00 #00ff80 #00ffff #0080ff #0000ff #8000ff #ff00ff #ff0080 #404040 #b30000 #b35900 #b3b300 #59b300 #00b300 #00b359 #00b3b3 #0059b3 #0000b3 #5900b3 #b300b3 #b30059 #000000 #660000 #663300 #666600 #336600 #006600 #006633 #006666 #003366 #000066 #330066 #660066 #660033".split(" "),
colorWidth:247,emptyHtml:"<p>"+(this.browser("msie")?"":"<br />")+"</p>",buffer:!1,visual:!0,modal_file:String()+'<div id="redactor_modal_content"><form id="redactorUploadFileForm" method="post" action="" enctype="multipart/form-data"><label>Name (optional)</label><input type="text" id="redactor_filename" class="redactor_input" /><div style="margin-top: 7px;"><input type="file" id="redactor_file" name="file" /></div></form><br></div>',modal_image_edit:String()+'<div id="redactor_modal_content"><label>'+
RLANG.title+'</label><input id="redactor_file_alt" class="redactor_input" /><label>'+RLANG.link+'</label><input id="redactor_file_link" class="redactor_input" /><label>'+RLANG.image_position+'</label><select id="redactor_form_image_align"><option value="none">'+RLANG.none+'</option><option value="left">'+RLANG.left+'</option><option value="right">'+RLANG.right+'</option></select></div><div id="redactor_modal_footer"><a href="javascript:void(null);" id="redactor_image_delete_btn" class="redactor_modal_btn">'+
RLANG._delete+'</a>&nbsp;&nbsp;&nbsp;<a href="javascript:void(null);" class="redactor_modal_btn redactor_btn_modal_close">'+RLANG.cancel+'</a><input type="button" name="save" class="redactor_modal_btn" id="redactorSaveBtn" value="'+RLANG.save+'" /></div>',modal_image:String()+'<div id="redactor_modal_content"><div id="redactor_tabs"><a href="javascript:void(null);" class="redactor_tabs_act">'+RLANG.upload+'</a><a href="javascript:void(null);">'+RLANG.choose+'</a><a href="javascript:void(null);">'+
RLANG.link+'</a></div><form id="redactorInsertImageForm" method="post" action="" enctype="multipart/form-data"><div id="redactor_tab1" class="redactor_tab"><input type="file" id="redactor_file" name="file" /></div><div id="redactor_tab2" class="redactor_tab" style="display: none;"><div id="redactor_image_box"></div></div></form><div id="redactor_tab3" class="redactor_tab" style="display: none;"><label>'+RLANG.image_web_link+'</label><input type="text" name="redactor_file_link" id="redactor_file_link" class="redactor_input"  /></div></div><div id="redactor_modal_footer"><a href="javascript:void(null);" class="redactor_modal_btn redactor_btn_modal_close">'+
RLANG.cancel+'</a><input type="button" name="upload" class="redactor_modal_btn" id="redactor_upload_btn" value="'+RLANG.insert+'" /></div>',modal_link:String()+'<div id="redactor_modal_content"><form id="redactorInsertLinkForm" method="post" action=""><div id="redactor_tabs"><a href="javascript:void(null);" class="redactor_tabs_act">URL</a><a href="javascript:void(null);">Email</a><a href="javascript:void(null);">'+RLANG.anchor+'</a></div><input type="hidden" id="redactor_tab_selected" value="1" /><div class="redactor_tab" id="redactor_tab1"><label>URL</label><input type="text" id="redactor_link_url" class="redactor_input"  /><label>'+
RLANG.text+'</label><input type="text" class="redactor_input redactor_link_text" id="redactor_link_url_text" /><label><input type="checkbox" id="redactor_link_blank"> '+RLANG.link_new_tab+'</label></div><div class="redactor_tab" id="redactor_tab2" style="display: none;"><label>Email</label><input type="text" id="redactor_link_mailto" class="redactor_input" /><label>'+RLANG.text+'</label><input type="text" class="redactor_input redactor_link_text" id="redactor_link_mailto_text" /></div><div class="redactor_tab" id="redactor_tab3" style="display: none;"><label>'+
RLANG.anchor+'</label><input type="text" class="redactor_input" id="redactor_link_anchor"  /><label>'+RLANG.text+'</label><input type="text" class="redactor_input redactor_link_text" id="redactor_link_anchor_text" /></div></form></div><div id="redactor_modal_footer"><a href="javascript:void(null);" class="redactor_modal_btn redactor_btn_modal_close">'+RLANG.cancel+'</a><input type="button" class="redactor_modal_btn" id="redactor_insert_link_btn" value="'+RLANG.insert+'" /></div>',modal_table:String()+
'<div id="redactor_modal_content"><label>'+RLANG.rows+'</label><input type="text" size="5" value="2" id="redactor_table_rows" /><label>'+RLANG.columns+'</label><input type="text" size="5" value="3" id="redactor_table_columns" /></div><div id="redactor_modal_footer"><a href="javascript:void(null);" class="redactor_modal_btn redactor_btn_modal_close">'+RLANG.cancel+'</a><input type="button" name="upload" class="redactor_modal_btn" id="redactor_insert_table_btn" value="'+RLANG.insert+'" /></div>',modal_video:String()+
'<div id="redactor_modal_content"><form id="redactorInsertVideoForm"><label>'+RLANG.video_html_code+'</label><textarea id="redactor_insert_video_area" style="width: 99%; height: 160px;"></textarea></form></div><div id="redactor_modal_footer"><a href="javascript:void(null);" class="redactor_modal_btn redactor_btn_modal_close">'+RLANG.cancel+'</a><input type="button" class="redactor_modal_btn" id="redactor_insert_video_btn" value="'+RLANG.insert+'" /></div>',toolbar:{html:{title:RLANG.html,func:"toggle"},
formatting:{title:RLANG.formatting,func:"show",dropdown:{p:{title:RLANG.paragraph,exec:"formatblock"},blockquote:{title:RLANG.quote,exec:"formatblock",className:"redactor_format_blockquote"},pre:{title:RLANG.code,exec:"formatblock",className:"redactor_format_pre"},h1:{title:RLANG.header1,exec:"formatblock",className:"redactor_format_h1"},h2:{title:RLANG.header2,exec:"formatblock",className:"redactor_format_h2"},h3:{title:RLANG.header3,exec:"formatblock",className:"redactor_format_h3"},h4:{title:RLANG.header4,
exec:"formatblock",className:"redactor_format_h4"}}},bold:{title:RLANG.bold,exec:"bold"},italic:{title:RLANG.italic,exec:"italic"},deleted:{title:RLANG.deleted,exec:"strikethrough"},underline:{title:RLANG.underline,exec:"underline"},unorderedlist:{title:"&bull; "+RLANG.unorderedlist,exec:"insertunorderedlist"},orderedlist:{title:"1. "+RLANG.orderedlist,exec:"insertorderedlist"},outdent:{title:"< "+RLANG.outdent,exec:"outdent"},indent:{title:"> "+RLANG.indent,exec:"indent"},image:{title:RLANG.image,
func:"showImage"},video:{title:RLANG.video,func:"showVideo"},file:{title:RLANG.file,func:"showFile"},table:{title:RLANG.table,func:"show",dropdown:{insert_table:{title:RLANG.insert_table,func:"showTable"},separator_drop1:{name:"separator"},insert_row_above:{title:RLANG.insert_row_above,func:"insertRowAbove"},insert_row_below:{title:RLANG.insert_row_below,func:"insertRowBelow"},insert_column_left:{title:RLANG.insert_column_left,func:"insertColumnLeft"},insert_column_right:{title:RLANG.insert_column_right,
func:"insertColumnRight"},separator_drop2:{name:"separator"},add_head:{title:RLANG.add_head,func:"addHead"},delete_head:{title:RLANG.delete_head,func:"deleteHead"},separator_drop3:{name:"separator"},delete_column:{title:RLANG.delete_column,func:"deleteColumn"},delete_row:{title:RLANG.delete_row,func:"deleteRow"},delete_table:{title:RLANG.delete_table,func:"deleteTable"}}},link:{title:RLANG.link,func:"show",dropdown:{link:{title:RLANG.link_insert,func:"showLink"},unlink:{title:RLANG.unlink,exec:"unlink"}}},
fontcolor:{title:RLANG.fontcolor,func:"show"},backcolor:{title:RLANG.backcolor,func:"show"},alignment:{title:RLANG.alignment,func:"show",dropdown:{alignleft:{title:RLANG.align_left,exec:"JustifyLeft"},aligncenter:{title:RLANG.align_center,exec:"JustifyCenter"},alignright:{title:RLANG.align_right,exec:"JustifyRight"},justify:{title:RLANG.align_justify,exec:"JustifyFull"}}},alignleft:{exec:"JustifyLeft",title:RLANG.align_left},aligncenter:{exec:"JustifyCenter",title:RLANG.align_center},alignright:{exec:"JustifyRight",
title:RLANG.align_right},justify:{exec:"JustifyFull",title:RLANG.align_justify},horizontalrule:{exec:"inserthorizontalrule",title:RLANG.horizontalrule}}},c,this.$el.data());this.dropdowns=[];this.deferredModal={};this.undoStack=[];this.redoStack=[];this.typingType=null;this.typingCount=0;this.init()};l.prototype={init:function(){this.height=this.$el.css("height");this.width=this.$el.css("width");rdocument=this.document=document;rwindow=this.window=window;if(!1===this.opts.mobile&&this.isMobile())return this.build(!0),
!1;this.opts.iframe&&(this.opts.autoresize=!1);if(this.opts.air)b.extend(this.opts.toolbar,this.opts.buttonsCustom),this.opts.buttons=this.opts.airButtons;else if(!1!==this.opts.toolbar){if(!1===this.opts.source){var a=b.inArray("html",this.opts.buttons);if(-1!=a){var c=this.opts.buttons[a+1];this.opts.buttons.splice(a,1);"undefined"!==typeof c&&"|"===c&&this.opts.buttons.splice(a,1)}}b.extend(this.opts.toolbar,this.opts.buttonsCustom);b.each(this.opts.buttonsAdd,b.proxy(function(a,b){this.opts.buttons.push(b)},
this))}!1!==this.opts.toolbar&&(b.each(this.opts.toolbar.formatting.dropdown,b.proxy(function(a,c){"-1"==b.inArray(a,this.opts.formattingTags)&&delete this.opts.toolbar.formatting.dropdown[a]},this)),this.opts.allowJustify||delete this.opts.toolbar.alignment.dropdown.justify);this.build(!1,function(){this.enableAir();this.buildToolbar();this.pushUndoStack(!1);"object"===typeof this.opts.plugins&&b.each(this.opts.plugins,b.proxy(function(a,c){"undefined"!==typeof RedactorPlugins[c]&&(b.extend(this,
RedactorPlugins[c]),"undefined"!==typeof RedactorPlugins[c].init&&this.init())},this));if(!1!==this.opts.activeButtons&&!1!==this.opts.toolbar&&!this.isMobile(!0)){var a;this.$editor.click(b.proxy(function(){this.observeFormatting()},this)).keyup(b.proxy(function(c){c=c.keyCode||c.which;switch(c){case 17:case 91:case 92:case 93:case 224:break;case 13:case 8:this.observeFormatting(c);break;default:a||(a=setTimeout(b.proxy(function(){a=null;this.observeFormatting()},this),100))}},this))}this.$editor.bind("paste",
b.proxy(function(a){if(this.pasteRunning)return!1;this.pushUndoStack();if(!1===this.opts.cleanup)return!0;if(this.opts.pastePreventCallback){var c=new b.Event;this.opts.pastePreventCallback(c,this,a);if(c.isDefaultPrevented())return!0}this.setBuffer();this.saveScroll=!0===this.opts.autoresize?this.document.body.scrollTop:this.$editor.scrollTop();var d=null,e;if(this.browser("msie")||this.isMobile(!0))this.$editor.css("height",this.$editor.height()+"px"),d=this.extractContent();else{var c=this.document.createTextNode("\u200b\u200b"),
f=this.getFocus()[0],f=f?3==f.nodeType?b(f).parent().offset().top:b(f).offset().top:0;this.$editor.find(".redactorPaste").removeClass("redactorPaste");e=b("<div />",this.document).append(c).css({overflow:"hidden",width:"1px",height:"1px",position:"absolute",left:"-1000px",top:f+"px"}).addClass("redactorPaste");this.$editor.append(e);this.setSelection(c,0,c,2)}this.pasteRunning=!0;setTimeout(b.proxy(function(){this.pasteRunning=!1;var c;if(e){var f=this.$editor.find("> .redactorPaste");f.each(function(a){0<
a&&e.append(b(this).contents())});c=this.extractContent(e[0]);f.remove()}else c=this.extractContent(),this.$editor.css("height","").append(d);this.restoreSelection();this.opts.pasteManipulateCallback&&this.opts.pasteManipulateCallback(this,c,a);c=this.getFragmentHtml(c);this.pasteCleanUp(c)},this),1)},this));this.keyup();this.keydown();this.$editor.keypress(b.proxy(function(a){a.stopPropagation();if(!a.ctrlKey&&!a.metaKey)this.onTyping("key")},this));this.$editor.mousedown(b.proxy(function(a){this.onTyping("move")},
this));!1!==this.opts.autosave&&this.autoSave();setTimeout(b.proxy(function(){this.observeImages();this.observeTables()},this),1);if(this.browser("mozilla")){this.$editor.click(b.proxy(function(){this.saveSelection()},this));try{this.document.execCommand("enableObjectResizing",!1,!1),this.document.execCommand("enableInlineTableEditing",!1,!1)}catch(c){}}this.opts.focus&&setTimeout(b.proxy(function(){this.focus()},this),1);this.opts.fixed&&(this.observeScroll(),b(document).scroll(b.proxy(this.observeScroll,
this)));"function"===typeof this.opts.callback&&this.opts.callback(this);!1!==this.opts.toolbar&&this.$toolbar.find("a").attr("tabindex","-1");if(this.browser("msie")){this.$editor.one("click",b.proxy(function(){this.focus()},this));try{this.document.execCommand("AutoUrlDetect",!1,!1)}catch(f){}}})},shortcuts:function(a,c){a.preventDefault();var d=!1;b.each(this.opts.activeButtonStateMap,function(a,b){if(b==c)return d=a,!1});d&&(this.skipFormatObserveOnce=!0,this.toggleBtnActive(d));this.execCommand(c,
!1)},keyup:function(){this.$editor.keyup(b.proxy(function(a){var c=a.keyCode||a.which;this.browser("mozilla")&&!this.pasteRunning&&this.saveSelection();"function"===typeof this.opts.keyupCallback&&this.opts.keyupCallback(this,a);if(8===c||46===c)return this.observeImages(),this.formatEmpty(a);if(13===c&&!a.shiftKey&&!a.ctrlKey&&!a.metaKey){if(this.browser("mozilla")){try{this.document.execCommand("unlink",!1,null)}catch(b){}var c=this.window.getSelection(),e=c.anchorNode;if(c.isCollapsed&&0==c.anchorOffset&&
e&&"A"===e.tagName&&"<br>"==e.innerHTML){var f=e.parentNode;c.selectAllChildren(e.parentNode);f.innerHTML="<br>"}}this.browser("webkit")&&this.formatNewLine(a);this.opts.convertLinks&&this.$editor.linkify()}this.syncCode()},this))},keydown:function(){this.$editor.keydown(b.proxy(function(a){var c=a.keyCode||a.which;if(c){var d=this.getParentNode(),e=this.getCurrentNode(),f=!1,g=(a.ctrlKey||a.metaKey)&&!a.altKey,h=!a.ctrlKey&&a.metaKey;if(d&&"PRE"===b(d).get(0).tagName||e&&"PRE"===b(e).get(0).tagName)f=
!0;"function"===typeof this.opts.keydownCallback&&this.opts.keydownCallback(this,a);if(13==c)this.pushUndoStack();else if(8==c||46==c)this.onTyping("delete");else if(33<=c&&40>=c)this.onTyping("move");if(h&&this.opts.shortcuts){var k;if(this.window.getSelection&&(k=this.window.getSelection())&&k.modify)switch(d=a.shiftKey?"extend":"move",c){case 39:k.modify(d,"right","lineboundary");a.preventDefault();break;case 37:k.modify(d,"left","lineboundary"),a.preventDefault()}}g&&this.opts.shortcuts&&(90===
c?a.shiftKey?this.shortcuts(a,"redo"):this.shortcuts(a,"undo"):89==c?this.shortcuts(a,"redo"):77===c?this.shortcuts(a,"removeformat"):66===c?this.shortcuts(a,"bold"):73===c?this.shortcuts(a,"italic"):85===c?this.shortcuts(a,"underline"):74===c?this.shortcuts(a,"insertunorderedlist"):75===c?this.shortcuts(a,"insertorderedlist"):76===c?this.shortcuts(a,"superscript"):72===c&&this.shortcuts(a,"subscript"));g||90===c||(this.opts.buffer=!1);if(!0===f&&13===c)return a.preventDefault(),a=b(e).parent().text(),
this.insertNodeAtCaret(this.document.createTextNode("\r\n")),-1==a.search(/\s$/)&&this.insertNodeAtCaret(this.document.createTextNode("\r\n")),this.syncCode(),!1;if(this.opts.shortcuts&&!a.shiftKey&&9===c&&this.opts.insertTab)if(!1===f)this.shortcuts(a,"indent");else return a.preventDefault(),this.insertNodeAtCaret(this.document.createTextNode("\t")),this.syncCode(),!1;else this.opts.shortcuts&&a.shiftKey&&9===c&&this.opts.insertTab&&this.shortcuts(a,"outdent");if(this.browser("webkit")&&-1===navigator.userAgent.indexOf("Chrome"))return this.safariShiftKeyEnter(a,
c)}},this))},build:function(a,c){if(!0!==a){var d=function(){var a=this.$content.contents(),d=a.find("head");this.$editor=a.find("body").attr("contenteditable",!0).attr("dir",this.opts.direction);rdocument=this.document=this.$editor[0].ownerDocument;rwindow=this.window=this.document.defaultView||window;b(rdocument).on("touchend",function(a){setTimeout(function(){rwindow.focus()},100)});!1!==this.opts.iframeBase&&d.append('<base href="'+this.opts.iframeBase+'" />');!1!==this.opts.css&&d.append('<link rel="stylesheet" href="'+
this.opts.css+'" />');this.$editor.html(g);c&&(c.call(this),c=null)};this.$box=b('<div class="redactor_box"></div>');this.opts.air&&(this.air=b('<div class="redactor_air" style="display: none;"></div>'));this.$content=null;this.textareamode=!0;if("TEXTAREA"===this.$el.get(0).tagName){if(this.opts.iframe){var e=this;this.$content=b('<iframe style="width: 100%;" frameborder="0"></iframe>').load(function(){d.call(e)})}else this.$content=this.$editor=b("<div></div>");var f=this.$el.get(0).className.split(/\s+/);
b.each(f,b.proxy(function(a,c){this.$content.addClass("redactor_"+c)},this))}else this.textareamode=!1,this.$content=this.$editor=this.$el,this.$el=b('<textarea name="'+this.$editor.attr("id")+'"></textarea>').css("height",this.height);this.$editor&&this.$editor.addClass("redactor_editor").attr("contenteditable",!0).attr("dir",this.opts.direction);!1!==this.opts.tabindex&&this.$content.attr("tabindex",this.opts.tabindex);!1!==this.opts.minHeight&&this.$content.css("min-height",this.opts.minHeight+
"px");!0===this.opts.wym&&this.$content.addClass("redactor_editor_wym");!1===this.opts.autoresize&&this.$content.css("height",this.height);this.$el.hide();var g="";this.textareamode?(g=this.$el.val(),g=this.savePreCode(g),this.$box.insertAfter(this.$el).append(this.$content).append(this.$el)):(g=this.$editor.html(),g=this.savePreCode(g),this.$box.insertAfter(this.$content).append(this.$el).append(this.$editor));g=this.paragraphy(g);this.$editor&&this.$editor.html(g);!1===this.textareamode&&this.syncCode()}else"TEXTAREA"!==
this.$el.get(0).tagName&&(g=this.$el.val(),f=b('<textarea name="'+this.$editor.attr("id")+'"></textarea>').css("height",this.height).val(g),this.$el.hide(),this.$el.after(f));c&&this.$editor&&c.call(this)},enableAir:function(){if(!1===this.opts.air)return!1;this.air.hide();this.$editor.bind("textselect",b.proxy(function(a){this.showAir(a)},this));this.$editor.bind("textunselect",b.proxy(function(){this.air.hide()},this))},showAir:function(a){b(".redactor_air").hide();var c=this.air.innerWidth(),d=
a.clientX;b(this.document).width()<d+c&&(d-=c);a=a.clientY+b(document).scrollTop()+14;!0===this.opts.iframe&&(a+=this.$box.position().top,d+=this.$box.position().left);this.air.css({left:d+"px",top:a+"px"}).show()},pushUndoStack:function(a){var c=this.getState();this.undoStack.length&&this.compareStates(this.undoStack[this.undoStack.length-1],c)||(void 0===a&&(a=!0),this.undoStack.length==this.opts.undoSize&&this.undoStack.shift(),this.undoStack.push(c),this.redoStack=[],a&&this.resetTyping())},popUndoStack:function(){var a=
this.undoStack.pop(),c;a&&(c=this.getState(),this.compareStates(a,c)||(this.redoStack.push(c),this.restoreState(a)))},popRedoStack:function(){var a=this.redoStack.pop();a&&(this.undoStack.push(this.getState()),this.restoreState(a))},restoreState:function(a){this.$editor.html(a.html);this.focus();if(!this.oldIE()){if(a.origin){var c=function(a){if(!a)return[null,null];for(var c=b.$editor.get(0),e=0,k=0;k<a.length;k++)switch(a[k][0]){case "node":c=c.childNodes[a[k][1]];break;case "text":e=a[k][1]}return[c,
e]},b=this,e=c(a.origin);a=c(a.focus);this.setSelection(e[0],e[1],a[0],a[1]);this.focus()}else this.selectLast();this.resetTyping()}},getState:function(){function a(a){var c=[],b=e.$editor.get(0);3==a[0].nodeType&&c.unshift(["text",a[1]]);for(var d=a[0],m;d&&d!=b;){a=0;for(m=d;m=m.previousSibling;)a++;c.unshift(["node",a]);d=d.parentNode}return c}var c=this.getOrigin(),b=this.getFocus(),e=this;return{html:this.$editor.html(),origin:c?a(c):null,focus:b?a(b):null}},compareStates:function(a,c){if(a.html!=
c.html)return!1;if(!a.origin&&!a.focus)return!0;if(!a.origin&&c.origin||a.origin&&!c.origin||a.origin.length!=c.origin.length||!a.focus&&c.focus||a.focus&&!c.focus||a.focus.length!=c.focus.length)return!1;var b=function(a,c){for(var b=0;b<a.length;b++)if(a[b][0]!=c[b][0]||a[b][1]!=c[b][1])return!1;return!0};return a.origin&&!b(a.origin,c.origin)||a.focus&&!b(a.focus,c.focus)?!1:!0},onTyping:function(a){var c=this;this.typingType&&this.typingType!=a&&0<this.typingCount&&("move"!=a&&c.pushUndoStack(!1),
this.typingCount=0);this.typingType=a;this.typingCount++;25<this.typingCount&&"move"!=this.typingType&&(setTimeout(function(){c.pushUndoStack(!1)},0),this.typingCount=0)},resetTyping:function(){this.typingType=null;this.typingCount=0},syncCode:function(){this.$el.val(this.$editor.html())},focus:function(a){var c=this.getFocus(),d=this.getOrigin();a?(c&&c[0]==d[0]&&c[1]==d[1]&&b(c[0]).is("body, .redactor_editor")&&(c=null),c||this.selectLast()):(!c||!d||c[0]==d[0]&&0==c[1]&&0==d[1]&&b(c[0]).is("body, .redactor_editor"))&&
(a=this.$editor[0].firstChild)&&"BR"!==a.tagName&&"IMG"!==a.tagName&&this.setSelection(a,0,a,0);this.opts.iframe&&this.$editor[0]&&(a=this.$editor[0].ownerDocument)&&(a.defaultView||a.parentWindow).focus();this.$editor.focus();if(this.browser("webkit")){var e=this.$editor;setTimeout(function(){e.focus()},50)}},setCode:function(a,c){c="undefined"==typeof c?!0:c;a=this.stripTags(a);this.$editor.html(a);c&&this.focus();this.syncCode()},getCode:function(){var a="",a=this.opts.visual?this.$editor.html():
this.$el.val();return this.stripTags(a)},insertHtml:function(a,c){this.focus();this.pasteHtmlAtCaret(a,c);this.observeImages();this.syncCode()},pasteHtmlAtCaret:function(a,c){c||this.pushUndoStack();var d=!1,e,f;if(this.document.getSelection){if(e=this.window.getSelection(),e.getRangeAt&&e.rangeCount){d=this.analyzeSelection();d.isCollapsed||b(d.selectedEls).filter("body").length||(d.selectPartials(),f=d.bookmarkSelection(),b(d.selectedEls).remove(),f[0].after("\u200b\u200b"),d.restoreBookmark());
d=[];f=e.getRangeAt(0);f.deleteContents();"BODY"==f.startContainer.tagName&&(a.match(/<(p|div|h\d|ul|ol|blockquote|pre)(\s|\/|>)/i)||(a="<p>"+a+"</p>"));if(a.match(/<(p|div|h\d|ul|ol|blockquote|pre)(\s|\/|>)/i)){var g=b(f.startContainer).closest("p, div, h1, h2, h3, h4, h5, h6, ul, ol, blockquote, pre");if(g.length){var h=f.cloneRange();h.setEnd(g[0],g[0].childNodes.length);var k=this.document.createElement("div");k.appendChild(h.cloneContents());if(""===b.trim(k.innerHTML)||k.innerHTML.match(/^<br\s*\/?>$/i))f.setStartAfter(g[0]),
f.setEndAfter(g[0]),h=b.trim(g.html()),(""===h||h.match(/^<br\s*\/?>$/i))&&g.remove()}}g=this.document.createElement("div");g.innerHTML=a;for(var h=this.document.createDocumentFragment(),m;k=g.firstChild;)m=h.appendChild(k),d.push(m);f.insertNode(h);m&&(f=f.cloneRange(),1==m.nodeType&&m.childNodes.length?(m=m.childNodes[m.childNodes.length-1],"BR"==m.tagName?m.previousSibling?f.setStartAfter(m.previousSibling):f.setStartBefore(m):f.setStartAfter(m)):f.setStartAfter(m),f.collapse(!0),e.removeAllRanges(),
e.addRange(f))}}else this.document.selection&&"Control"!=this.document.selection.type&&this.document.selection.createRange().pasteHTML(a);this.opts.insertHtmlCallback&&this.opts.insertHtmlCallback(d,this)},destroy:function(){var a=this.getCode();this.textareamode?(this.$box.after(this.$el),this.$box.remove(),this.$el.height(this.height).val(a).show()):(this.$box.after(this.$editor),this.$box.remove(),this.$editor.removeClass("redactor_editor").removeClass("redactor_editor_wym").attr("contenteditable",
!1).html(a).show());this.opts.toolbarExternal&&b(this.opts.toolbarExternal).empty();b(".redactor_air").remove();for(a=0;a<this.dropdowns.length;a++)this.dropdowns[a].remove(),delete this.dropdowns[a];this.undoStack=[];this.redoStack=[];!1!==this.opts.autosave&&clearInterval(this.autosaveInterval)},observeFormatting:function(a){if(this.skipFormatObserveOnce)this.skipFormatObserveOnce=!1;else{var c=this.getCurrentNode(),d=b(c),e=this.$editor.get(0);this.inactiveAllButtons();b.each(this.opts.activeButtonsStates,
b.proxy(function(a,c){0!=d.closest(a,e).length&&this.setBtnActive(c)},this));if(a&&(13==a||8==a)){var f=this;b.each(this.opts.activeButtonStateMap,function(a,c){try{f.document.queryCommandState(c)?f.setBtnActive(a):f.setBtnInactive(a)}catch(b){}})}a=d.closest("p div h1 h2 h3 h4 h5 h6 blockquote td".split(" "));if("undefined"!==typeof a[0]&&"undefined"!==typeof a[0].elem&&0!=b(a[0].elem).size())switch(b(a[0].elem).css("text-align")){case "right":this.setBtnActive("alignright");break;case "center":this.setBtnActive("aligncenter");
break;case "justify":this.setBtnActive("justify");break;default:this.setBtnActive("alignleft")}}},observeImages:function(){if(!1===this.opts.observeImages)return!1;this.$editor.find("img").each(b.proxy(function(a,c){this.browser("msie")&&b(c).attr("unselectable","on");this.resizeImage(c)},this))},observeTables:function(){this.$editor.find("table").click(b.proxy(this.tableObserver,this))},observeScroll:function(){var a=b(this.document).scrollTop(),c=this.$box.offset().top,d=0;a>c?(a="100%",this.opts.fixedBox&&
(d=this.$box.offset().left,a=this.$box.innerWidth()),this.fixed=!0,this.$toolbar.css({position:"fixed",width:a,zIndex:1005,top:this.opts.fixedTop+"px",left:d})):(this.fixed=!1,this.$toolbar.css({position:"relative",width:"auto",zIndex:1,top:0,left:d}))},setBuffer:function(){this.saveSelection();this.opts.buffer=this.$editor.html()},getBuffer:function(){if(!1===this.opts.buffer)return!1;this.$editor.html(this.opts.buffer);this.browser("msie")||this.restoreSelection();this.opts.buffer=!1},execCommand:function(a,
c,d){if(0==this.opts.visual)return this.$el.focus(),!1;"undefined"==typeof d&&(d=!0);d&&"undo"!=a&&"redo"!=a&&this.pushUndoStack();try{var e;if("inserthtml"===a)this.focus(),this.pasteHtmlAtCaret(c,!0),this.observeImages();else if("removeformat"===a)this.removeSelectedFormatting("b, strong, i, em, u, s, span, strike, font",!0);else if("unlink"===a)this.removeSelectedFormatting("a",!1);else if("JustifyLeft"===a||"JustifyCenter"===a||"JustifyRight"===a||"JustifyFull"===a){var f=this.getOrigin(),g=this.getFocus();
if(!g||!1===this.opts.iframe&&0==b(g[0]).closest(".redactor_editor").size())return!1;var h;g[0]==f[0]&&(h=b(g[0]).closest("p, div, h1, h2, h3, h4, h5, h6, blockquote, td, li",this.$editor.get(0)));h&&h.length?(c=!1,"JustifyCenter"===a?c="center":"JustifyLeft"===a?c="left":"JustifyRight"===a?c="right":"JustifyFull"===a&&(c="justify"),c&&c==("rtl"==this.opts.direction.toLowerCase()?"right":"left")&&(c=!1),!1===c?h.css("text-align","").removeAttr("align"):h.css("text-align",c).removeAttr("align"),this.focus()):
this.execRun(a,c)}else if("formatblock"===a&&"blockquote"===c)if(e=this.getCurrentNode(),"BLOCKQUOTE"===b(e).get(0).tagName)if(this.browser("msie")){var k=b("<p>"+b(e).html()+"</p>");b(e).replaceWith(k)}else this.execRun(a,"p");else if("P"===b(e).get(0).tagName){var m=b(e).parent();"BLOCKQUOTE"===b(m).get(0).tagName?(k=b("<p>"+b(e).html()+"</p>"),b(m).replaceWith(k),this.setSelection(k[0],0,k[0],0)):this.browser("msie")?(k=b("<blockquote>"+b(e).html()+"</blockquote>"),b(e).replaceWith(k)):this.execRun(a,
c)}else this.execRun(a,c);else"formatblock"!==a||"pre"!==c&&"p"!==c?"undo"==a?this.popUndoStack():"redo"==a?this.popRedoStack():this.opts.execCommandHandler[a]?this.opts.execCommandHandler[a].call(this,a,c,this):("inserthorizontalrule"===a&&this.browser("msie")&&this.focus(),"formatblock"===a&&this.browser("mozilla")&&this.focus(),this.execRun(a,c)):(e=this.getParentNode(),"PRE"===b(e).get(0).tagName?b(e).replaceWith("<p>"+this.encodeEntities(b(e).text())+"</p>"):this.execRun(a,c));"inserthorizontalrule"===
a&&this.$editor.find("hr").removeAttr("id");this.syncCode();this.oldIE()&&this.focus();"function"===typeof this.opts.execCommandCallback&&this.opts.execCommandCallback(this,a);this.opts.air&&this.air.hide()}catch(l){}},execRun:function(a,c){"formatblock"===a&&this.browser("msie")&&(c="<"+c+">");this.document.execCommand(a,!1,c)},formatNewLine:function(a){var c=this.getParentNode();a="DIV"===c.nodeName&&(0==this.opts.iframe&&c.className.match(/(\s|^)redactor_editor(\s|$)/)||1==this.opts.iframe&&"BODY"==
c.tagName);c="P"===c.nodeName;if(a||c)if(a=this.getCurrentNode(),c=a.innerHTML||"",c=""===c||"<br>"==c,"DIV"===a.tagName){if("P"===a.parentNode.tagName){for(var d=a.parentNode;d.parentNode&&"P"===d.parentNode.tagName;)d=d.parentNode;d.parentNode.insertBefore(a,d.nextSibling);this.setSelection(a,0,a,0)}c&&(a=b(a),c=b("<p>").append(a.clone().get(0).childNodes),a.replaceWith(c),c.html("<br />"),this.setSelection(c[0],0,c[0],0))}else"P"!==a.tagName||c||(a.parentNode.insertBefore(this.document.createElement("p"),
a),this.setSelection(a,0,a,0))},safariShiftKeyEnter:function(a,c){return a.shiftKey&&13===c?(a.preventDefault(),this.insertNodeAtCaret(b("<span><br /></span>").get(0)),this.syncCode(),!1):!0},formatEmpty:function(a){var c=b.trim(this.$editor.html()),c=c.replace(/<br\s?\/?>/i,""),d=c.replace(/<p>\s?<\/p>/gi,"");if(""===c||""===d)return a&&a.preventDefault(),a=b(this.opts.emptyHtml).get(0),this.$editor.html(a),this.setSelection(a,0,a,0),this.syncCode(),!1;this.syncCode()},paragraphy:function(a){a=b.trim(a);
if(""===a||"<p></p>"===a||"<p><br></p>"===a)return this.opts.emptyHtml;this.opts.convertDivs&&(a=a.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p>$2</p>"));var c=function(a,c,b){return a.replace(new RegExp(c,"g"),b)},d=function(b,d){return c(a,b,d)};a+="\n";d("<br />\\s*<br />","\n\n");d("(<(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])[^>]*>)","\n$1");d("(</(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])>)",
"$1\n\n");d("\r\n|\r","\n");d("\n\n+","\n\n");d("\n?((.|\n)+?)$","<p>$1</p>\n");d("<p>\\s*?</p>","");d("<p>(<div[^>]*>\\s*)","$1<p>");d("<p>([^<]+)\\s*?(</(div|address|form)[^>]*>)","<p>$1</p>$2");d("<p>\\s*(</?(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])[^>]*>)\\s*</p>","$1");d("<p>(<li.+?)</p>","$1");d("<p>\\s*(</?(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])[^>]*>)",
"$1");d("(</?(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])[^>]*>)\\s*</p>","$1");d("(</?(table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|style|script|object|input|param|p|h[1-6])[^>]*>)\\s*<br />","$1");d("<br />(\\s*</?(p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)","$1");-1!=a.indexOf("<pre")&&d("(<pre(.|\n)*?>)((.|\n)*?)</pre>",
function(a,b,d,h){return c(b,"\\\\(['\"\\\\])","$1")+c(c(c(h,"<p>","\n"),"</p>|<br />",""),"\\\\(['\"\\\\])","$1")+"</pre>"});return d("\n</p>$","</p>")},stripTags:function(a){var c=this.opts.allowedTags;return a.replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,function(a,e){return"-1"<b.inArray(e.toLowerCase(),c)?a:""})},removeSelectedFormatting:function(a,c){var d=this.analyzeSelection(),e;if(c){if(d.isCollapsed)return;d.selectPartials();e=d.selectedEls}else e=d.selectedEls,e.push(d.origin[0]),d.focus[0]!=
d.origin[0]&&e.push(d.focus[0]);d.bookmarkSelection();var f=function(){b(this).after(this.childNodes);b(this).remove()},g=this.$editor;b(e).each(function(){for(var d=b(this),e=d.parent().closest(a,g),m=0;e.length;){m++;if(1E3<m){console.error("infinite loop when removing formatting");break}var l=e[0];if(1!=l.childNodes.length&&c){var t=d.parentsUntil(e);if(t.length){for(var A=b(this),p,u=b('<span class="__bogus" />');this.nextSibling;)p||(p=u),p.append(this.nextSibling);t.each(function(){for(p&&(p=
b(this.cloneNode(!1)).append(p));this.nextSibling;)p||(p=u),p.append(this.nextSibling);A=b(this.cloneNode(!1)).append(A)});p&&(p.is(u)?e.after(b(l.cloneNode(!1)).append(p[0].childNodes)):(f.call(u[0]),e.after(b(l.cloneNode(!1)).append(p))));e.after(A)}else if(this.previousSibling)if(this.nextSibling){for(e=b(l.cloneNode(!1));this.nextSibling;)e.append(this.nextSibling);b(l).after(e).after(this)}else b(l).after(this);else b(l).before(this)}else f.call(l);e=d.parent().closest(a,g)}d.find(a).each(f);
d.is(a)&&f.call(this)});d.restoreBookmark();this.observeFormatting()},savePreCode:function(a){var c=a.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi);null!==c&&b.each(c,b.proxy(function(b,c){var f=c.match(/<pre(.*?)>([\w\W]*?)<\/pre>/i);f[2]=this.encodeEntities(f[2]);a=a.replace(c,"<pre"+f[1]+">"+f[2]+"</pre>")},this));return a},encodeEntities:function(a){a=String(a).replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"');return String(a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,
"&gt;").replace(/"/g,"&quot;")},cleanupPre:function(a){a=a.replace(/<br>/gi,"\n");a=a.replace(/<\/p>/gi,"\n");a=a.replace(/<\/div>/gi,"\n");var c=this.document.createElement("div");c.innerHTML=a;return c.textContent||c.innerText},pasteCleanUp:function(a){var c=this.getParentNode();if(b(c).get(0)&&"PRE"===b(c).get(0).tagName)return a=this.cleanupPre(a),this.pasteCleanUpInsert(a),!0;c=new b.Event;this.opts.pasteCleanUpCallback&&(a=this.opts.pasteCleanUpCallback(c,this,a));c.isDefaultPrevented()||(a=
a.replace(/\x3c!--[\s\S]*?--\x3e|<\?(?:php)?[\s\S]*?\?>/gi,""),a=a.replace(/(&nbsp;){2,}/gi,"&nbsp;"),a=a.replace(/<b\sid="internal-source-marker(.*?)">([\w\W]*?)<\/b>/gi,"$2"),a=this.stripTags(a),a=a.replace(/\[/g,"&#91;"),a=a.replace(/\]/g,"&#93;"),a=a.replace(/<td><\/td>/gi,"[td]"),a=a.replace(/<td>&nbsp;<\/td>/gi,"[td]"),a=a.replace(/<td><br><\/td>/gi,"[td]"),a=a.replace(/<a(.*?)href="(.*?)"(.*?)>([\w\W]*?)<\/a>/gi,'[a href="$2"]$4[/a]'),a=a.replace(/<iframe(.*?)>([\w\W]*?)<\/iframe>/gi,"[iframe$1]$2[/iframe]"),
a=a.replace(/<video(.*?)>([\w\W]*?)<\/video>/gi,"[video$1]$2[/video]"),a=a.replace(/<audio(.*?)>([\w\W]*?)<\/audio>/gi,"[audio$1]$2[/audio]"),a=a.replace(/<embed(.*?)>([\w\W]*?)<\/embed>/gi,"[embed$1]$2[/embed]"),a=a.replace(/<object(.*?)>([\w\W]*?)<\/object>/gi,"[object$1]$2[/object]"),a=a.replace(/<param(.*?)>/gi,"[param$1]"),a=a.replace(/<img(.*?)style="(.*?)"(.*?)>/gi,"[img$1$3]"),a=a.replace(/<(\w+)([\w\W]*?)>/gi,"<$1>"),a=a.replace(/<[^\/>][^>]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,""),a=a.replace(/<[^\/>][^>]*>(\s*|\t*|\n*|&nbsp;|<br>)<\/[^>]+>/gi,
""),a=a.replace(/\[td\]/gi,"<td>&nbsp;</td>"),a=a.replace(/\[a href="(.*?)"\]([\w\W]*?)\[\/a\]/gi,'<a href="$1">$2</a>'),a=a.replace(/\[iframe(.*?)\]([\w\W]*?)\[\/iframe\]/gi,"<iframe$1>$2</iframe>"),a=a.replace(/\[video(.*?)\]([\w\W]*?)\[\/video\]/gi,"<video$1>$2</video>"),a=a.replace(/\[audio(.*?)\]([\w\W]*?)\[\/audio\]/gi,"<audio$1>$2</audio>"),a=a.replace(/\[embed(.*?)\]([\w\W]*?)\[\/embed\]/gi,"<embed$1>$2</embed>"),a=a.replace(/\[object(.*?)\]([\w\W]*?)\[\/object\]/gi,"<object$1>$2</object>"),
a=a.replace(/\[param(.*?)\]/gi,"<param$1>"),a=a.replace(/\[img(.*?)\]/gi,"<img$1>"),a=a.replace(/&#91;paste:([a-zA-Z0-9]+)(.*?)&#93;([\w\W]*?)&#91;\/paste:\1&#93;/gi,"<$1$2>$3</$1>"),a=a.replace(/&#91;/g,"["),a=a.replace(/&#93;/g,"]"),this.opts.convertDivs&&(a=a.replace(/<div(.*?)>([\w\W]*?)<\/div>/gi,"<p>$2</p>")),a=a.replace(/<span>([\w\W]*?)<\/span>/gi,"$1"),a=a.replace(/\n{3,}/gi,"\n"),a=a.replace(/<p><p>/gi,"<p>"),a=a.replace(/<\/p><\/p>/gi,"</p>"),this.browser("mozilla")&&(a=a.replace(/<br>$/gi,
"")));this.pasteCleanUpInsert(a)},pasteCleanUpInsert:function(a){this.execCommand("inserthtml",a);!0===this.opts.autoresize?b(this.document.body).scrollTop(this.saveScroll):this.$editor.scrollTop(this.saveScroll)},formattingRemove:function(a){var c=[],d=a.match(/<pre(.*?)>([\w\W]*?)<\/pre>/gi);null!==d&&b.each(d,function(b,d){a=a.replace(d,"prebuffer_"+b);c.push(d)});a=a.replace(/\s{2,}/g," ");a=a.replace(/\n/g," ");a=a.replace(/[\t]*/g,"");a=a.replace(/\n\s*\n/g,"\n");a=a.replace(/^[\s\n]*/g,"");
a=a.replace(/[\s\n]*$/g,"");a=a.replace(/>\s+</g,"><");c&&(b.each(c,function(b,c){a=a.replace("prebuffer_"+b,c)}),c=[]);return a},formattingIndenting:function(a){a=a.replace(/<li/g,"\t<li");a=a.replace(/<tr/g,"\t<tr");a=a.replace(/<td/g,"\t\t<td");return a=a.replace(/<\/tr>/g,"\t</tr>")},formattingEmptyTags:function(a){var b="<pre></pre> <blockquote>\\s*</blockquote> <em>\\s*</em> <ul></ul> <ol></ol> <li></li> <table></table> <tr></tr> <span>\\s*<span> <span>&nbsp;<span> <b>\\s*</b> <b>&nbsp;</b>".split(" ");
this.browser("msie")&&(b.push("<p>\\s*</p>"),b.push("<p>&nbsp;</p>"),b.push("<p>&#8203;</p>"),b.push("<div>\\s*</div>"));for(var d=0;d<b.length;++d)a=a.replace(new RegExp(b[d],"gi"),"");return a},formattingAddBefore:function(a){for(var b="<p <form </ul> </ol> <fieldset <legend <object <embed <select <option <input <textarea <pre <blockquote <ul <ol <li <dl <dt <dd <table <thead <tbody <caption </caption> <th <tr <td <figure".split(" "),d=0;d<b.length;++d){var e=b[d];a=a.replace(new RegExp(e,"gi"),
"\r\n"+e)}return a},formattingAddAfter:function(a){for(var b="</p>;</div>;</h1>;</h2>;</h3>;</h4>;</h5>;</h6>;<br>;<br />;</dl>;</dt>;</dd>;</form>;</blockquote>;</pre>;</legend>;</fieldset>;</object>;</embed>;</textarea>;</select>;</option>;</table>;</thead>;</tbody>;</tr>;</td>;</th>;</figure>".split(";"),d=0;d<b.length;++d){var e=b[d];a=a.replace(new RegExp(e,"gi"),e+"\r\n")}return a},formatting:function(a){a=this.formattingRemove(a);a=this.formattingEmptyTags(a);a=this.formattingAddBefore(a);
a=this.formattingAddAfter(a);return a=this.formattingIndenting(a)},toggle:function(){var a;if(this.opts.visual){var b=this.$editor.innerHeight();this.$editor.hide();this.$content.hide();a=this.$editor.html();this.$el.height(b).val(a).show().focus();this.setBtnActive("html");this.opts.visual=!1}else this.$el.hide(),a=this.$el.val(),this.$editor.html(a).show(),this.$content.show(),""===this.$editor.html()&&this.setCode(this.opts.emptyHtml,!1),this.focus(),this.setBtnInactive("html"),this.opts.visual=
!0,this.observeImages(),this.observeTables()},autoSave:function(){this.autosaveInterval=setInterval(b.proxy(function(){b.ajax({url:this.opts.autosave,type:"post",data:this.$el.attr("name")+"="+escape(encodeURIComponent(this.getCode())),success:b.proxy(function(a){"function"===typeof this.opts.autosaveCallback&&this.opts.autosaveCallback(a,this)},this)})},this),1E3*this.opts.interval)},buildToolbar:function(){if(!1===this.opts.toolbar)return!1;this.$toolbar=b("<ul>").addClass("redactor_toolbar");this.opts.air?
(b(this.air).append(this.$toolbar),b("body").append(this.air)):!1===this.opts.toolbarExternal?this.$box.prepend(this.$toolbar):b(this.opts.toolbarExternal).html(this.$toolbar);var a=this,c=function(c,d){if("|"!==d&&"undefined"!==typeof a.opts.toolbar[d]){var g=a.opts.toolbar[d];if(!1===a.opts.fileUpload&&"file"===d)return;c.append(b('<li class="redactor_btn_container_'+d+'">').append(a.buildButton(d,g)))}"|"===d&&c.append(b('<li class="redactor_separator"></li>'))},d=this.$toolbar;b.each(this.opts.buttons,
function(a,f){if(b.isArray(f)){var g=b("<ul />");b.each(f,function(a,b){c(g,b)});d.append(b('<li class="redactor_btn_group" />').append(g))}else c(d,f)})},buildButton:function(a,c){var d=b('<a href="javascript:void(null);" title="'+c.title+'" class="redactor_btn_'+a+'"></a>');d.attr({unselectable:"on",tabindex:-1}).on("dragstart",function(a){a.preventDefault()});"undefined"===typeof c.func?d.click(b.proxy(function(){-1!=b.inArray(a,this.opts.activeButtons)&&this.toggleBtnActive(a);(this.browser("mozilla")||
this.opts.iframe)&&this.focus();this.execCommand(c.exec,a)},this)):"show"!==c.func&&d.click(b.proxy(function(a){this[c.func](a)},this));"undefined"!==typeof c.callback&&!1!==c.callback&&d.click(b.proxy(function(b){c.callback(this,b,a)},this));if("backcolor"===a||"fontcolor"===a||"undefined"!==typeof c.dropdown){var e=b('<div class="redactor_dropdown" style="display: none;">'),e="backcolor"===a||"fontcolor"===a?this.buildColorPicker(e,a):this.buildDropdown(e,c.dropdown);this.dropdowns.push(e.appendTo(b(document.body)));
this.hdlShowDropDown=b.proxy(function(b){this.showDropDown(b,e,a,c)},this);d.click(this.hdlShowDropDown)}return d},buildDropdown:function(a,c){b.each(c,b.proxy(function(c,e){"undefined"===typeof e.className&&(e.className="");var f;"undefined"!==typeof e.name&&"separator"===e.name?f=b('<a class="redactor_separator_drop" unselectable="on">'):(f=b('<a href="javascript:void(null);" unselectable="on" class="'+e.className+'" style="'+(e.style||"")+'">'+e.title+"</a>"),"function"===typeof e.callback?b(f).click(b.proxy(function(a){e.callback(this,
a,c)},this)):"undefined"===typeof e.func?b(f).click(b.proxy(function(){this.execCommand(e.exec,c);this.focus()},this)):b(f).click(b.proxy(function(a){this[e.func](a)},this)));b(a).append(f)},this));return a},buildColorPicker:function(a,c){var d;d="backcolor"===c?this.browser("msie")?"BackColor":"hilitecolor":"forecolor";b(a).width(this.opts.colorWidth);for(var e=this.opts.colors.length,f=0;f<e;++f){var g=this.opts.colors[f],g=b('<a rel="'+g+'" href="javascript:void(null);" class="redactor_color_link" unselectable="on"></a>').css({backgroundColor:g});
b(a).append(g);var h=this;b(g).click(function(){var a=b(this).attr("rel");h.execCommand(d,a);if("forecolor"===d)if(h.opts.cleanupFontTags)h.$editor.find("font").filter(function(){return b(this).attr("color")==a}).replaceWith(function(){var a=b('<span style="color: '+b(this).attr("color")+';">'+b(this).html()+"</span>");a.find("[style]").css("color","");return a});else{var c=b(h.analyzeSelection().selectedEls);c.find("[style]").css("color","");c.filter("[style]").css("color","")}h.browser("msie")&&
"BackColor"===d&&h.$editor.find("font").replaceWith(function(){return b('<span style="'+b(this).attr("style")+'">'+b(this).html()+"</span>")});h.focus()})}e=b('<a href="javascript:void(null);" class="redactor_color_none" unselectable="on"></a>').html(RLANG.none);"backcolor"===c?e.click(b.proxy(this.setBackgroundNone,this)):e.click(b.proxy(this.setColorNone,this));b(a).append(e);return a},setBackgroundNone:function(){b(this.getCurrentNode()).parentsUntil(".redactor_editor, body").each(function(){var a=
b(this);if(a.style.backgroundColor)return a.css("background-color","transparent"),!1});this.syncCode();this.focus()},setColorNone:function(){b(this.getCurrentNode()).parentsUntil(".redactor_editor, body").addBack().each(function(){var a=b(this);if(this.attributes.color||this.style.color)return a.removeAttr("color").css("color",""),!1});this.syncCode();this.focus()},showDropDown:function(a,c,d,e){var f=this.getBtn(d);if(f.hasClass("dropact"))this.hideAllDropDown();else{this.hideAllDropDown();this.setBtnActive(d);
f.addClass("dropact");var g=f.offset(),h=g.left,k=b(window).width(),m=b(c).outerWidth();e.dropdownOnShow&&e.dropdownOnShow(this,a,c,d);h+m>k&&(h=Math.max(h-m+this.getBtn(d).outerWidth(),0));this.opts.air?(e=this.air.offset().top,b(c).css({position:"absolute",left:h+"px",top:e+30+"px"}).show()):this.opts.fixed&&this.fixed?b(c).css({position:"fixed",left:h+"px",top:"30px"}).show():(e=g.top+f.outerHeight(),b(c).css({position:"absolute",left:h+"px",top:e+"px"}).show())}h=b.proxy(function(a){this.hideDropDown(a,
c,d)},this);b(document).one("click",h);this.$editor.one("click",h);this.$content.one("click",h);a.stopPropagation()},hideAllDropDown:function(){this.$toolbar.find("a.dropact").removeClass("redactor_act").removeClass("dropact");b(".redactor_dropdown").hide()},hideDropDown:function(a,c,d){b(a.target).hasClass("dropact")||(b(c).removeClass("dropact"),this.showedDropDown=!1,this.hideAllDropDown())},getBtn:function(a){return!1===this.opts.toolbar?!1:b(this.$toolbar.find("a.redactor_btn_"+a))},toggleBtnActive:function(a){0==
this.opts.activeButtons||!1===this.opts.toolbar||this.isMobile(!0)||this.getBtn(a).toggleClass("redactor_act")},setBtnActive:function(a){0==this.opts.activeButtons||!1===this.opts.toolbar||this.isMobile(!0)||this.getBtn(a).addClass("redactor_act")},setBtnInactive:function(a){0==this.opts.activeButtons||!1===this.opts.toolbar||this.isMobile(!0)||this.getBtn(a).removeClass("redactor_act")},inactiveAllButtons:function(){b.each(this.opts.activeButtons,b.proxy(function(a,b){this.setBtnInactive(b)},this))},
changeBtnIcon:function(a,b){this.getBtn(a).addClass("redactor_btn_"+b)},removeBtnIcon:function(a,b){this.getBtn(a).removeClass("redactor_btn_"+b)},addBtnSeparator:function(){this.$toolbar.append(b('<li class="redactor_separator"></li>'))},addBtnSeparatorAfter:function(a){this.getBtn(a).parent().after(b('<li class="redactor_separator"></li>'))},addBtnSeparatorBefore:function(a){this.getBtn(a).parent().before(b('<li class="redactor_separator"></li>'))},removeBtnSeparatorAfter:function(a){this.getBtn(a).parent().next().remove()},
removeBtnSeparatorBefore:function(a){this.getBtn(a).parent().prev().remove()},setBtnRight:function(a){if(!1===this.opts.toolbar)return!1;this.getBtn(a).parent().addClass("redactor_btn_right")},setBtnLeft:function(a){if(!1===this.opts.toolbar)return!1;this.getBtn(a).parent().removeClass("redactor_btn_right")},addBtn:function(a,c,d,e){if(!1===this.opts.toolbar)return!1;a=this.buildButton(a,{title:c,callback:d,dropdown:e});this.$toolbar.append(b("<li>").append(a))},addBtnFirst:function(a,c,d,e){if(!1===
this.opts.toolbar)return!1;a=this.buildButton(a,{title:c,callback:d,dropdown:e});this.$toolbar.prepend(b("<li>").append(a))},addBtnAfter:function(a,c,d,e,f){if(!1===this.opts.toolbar)return!1;c=this.buildButton(c,{title:d,callback:e,dropdown:f});this.getBtn(a).parent().after(b("<li>").append(c))},addBtnBefore:function(a,c,d,e,f){if(!1===this.opts.toolbar)return!1;c=this.buildButton(c,{title:d,callback:e,dropdown:f});this.getBtn(a).parent().before(b("<li>").append(c))},removeBtn:function(a,b){var d=
this.getBtn(a);!0===b&&d.parent().next().remove();d.parent().removeClass("redactor_btn_right");d.remove()},getFragmentHtml:function(a){a=a.cloneNode(!0);var b=this.document.createElement("div");b.appendChild(a);return b.innerHTML},extractContent:function(a){a=a||this.$editor.get(0);for(var b=this.document.createDocumentFragment(),d;d=a.firstChild;)b.appendChild(d);return b},saveSelection:function(){this.focus();this.savedSel=this.getOrigin();this.savedSelObj=this.getFocus()},restoreSelection:function(){"undefined"!==
typeof this.savedSel&&null!==this.savedSel&&null!==this.savedSelObj?!1===this.opts.iframe&&0==b(this.savedSel[0]).closest(".redactor_editor").size()?this.focus():(this.browser("opera")&&this.focus(),this.setSelection(this.savedSel[0],this.savedSel[1],this.savedSelObj[0],this.savedSelObj[1]),this.browser("mozilla")&&this.focus()):this.focus()},getSelection:function(){var a=this.document;return this.window.getSelection?this.window.getSelection():a.getSelection?a.getSelection():a.selection.createRange()},
hasSelection:function(){if(this.oldIE()){var a=this.$editor.get(0),b;return a&&a.document&&a.document.selection?(b=a.document.selection.createRange())&&b.parentElement&&b.parentElement().document===a.document:!1}return(a=this.getSelection())&&null!=a.focusNode&&null!=a.anchorNode},getOrigin:function(){if(this.oldIE()){var a=this.$editor.get(0),b;if(!this.hasSelection())return null;a.focus();b=a.document.selection.createRange();return this._getBoundary(a.document,b,!0)}return(a=this.getSelection())&&
null!=a.anchorNode?[a.anchorNode,a.anchorOffset]:null},getFocus:function(){if(this.oldIE()){var a=this.$editor.get(0),b;if(!this.hasSelection())return null;a.focus();b=a.document.selection.createRange();return this._getBoundary(a.document,b,!1)}return(a=this.getSelection())&&null!=a.focusNode?[a.focusNode,a.focusOffset]:null},setSelection:function(a,b,d,e){null==d&&(d=a);null==e&&(e=b);if(this.oldIE()){var f=this.$editor.get(0),g=f.document.body.createTextRange();this._moveBoundary(f.document,g,!1,
d,e);this._moveBoundary(f.document,g,!0,a,b);return g.select()}if(f=this.getSelection())if(f.collapse&&f.extend)f.collapse(a,b),f.extend(d,e);else{g=this.document.createRange();g.setStart(a,b);g.setEnd(d,e);g.collapsed&&(a!=d||a==d&&b!=e)&&(g.setStart(d,e),g.setEnd(a,b));try{f.removeAllRanges()}catch(h){}f.addRange(g)}},selectLast:function(a){a||(a=this.$editor);if(a=b(a).get(0)){var c=a.lastChild;if(c){for(;c.lastChild;)c=c.lastChild;3==c.nodeType?this.setSelection(c,c.nodeValue.length,c,c.nodeValue.length):
"BR"===c.tagName||"IMG"===c.tagName?(a=c.parentNode,this.setSelection(a,a.length-1,a,a.length-1)):this.setSelection(c,0,c,0)}else this.setSelection(a,0,a,0)}},selectFirst:function(a){a||(a=this.$editor);if(a=b(a).get(0)){var c=a.firstChild;c&&"BR"!==c.tagName&&"IMG"!==c.tagName?this.setSelection(c,0,c,0):this.setSelection(a,0,a,0)}},getCurrentNode:function(){if("undefined"!==typeof this.window.getSelection){var a=this.getSelectedNode();return a?a.parentNode:!1}if("undefined"!==typeof this.document.selection)return this.getSelection().parentElement()},
getParentNode:function(){return b(this.getCurrentNode()).parent()[0]},getSelectedNode:function(){if(this.oldIE())return this.getSelection().parentElement();if("undefined"!==typeof this.window.getSelection){var a=this.window.getSelection();return a&&0<a.rangeCount?this.getSelection().getRangeAt(0).commonAncestorContainer:!1}if("undefined"!==typeof this.document.selection)return this.getSelection()},_getBoundary:function(a,b,d){var e,f,g=!1;a=a.createElement("a");e=b.duplicate();e.collapse(d);for(f=
e.parentElement();f.insertBefore(a,g?a.previousSibling:null),g=!0,e.moveToElementText(a),0<e.compareEndPoints(d?"StartToStart":"StartToEnd",b)&&null!=a.previousSibling;);-1===e.compareEndPoints(d?"StartToStart":"StartToEnd",b)&&a.nextSibling?(e.setEndPoint(d?"EndToStart":"EndToEnd",b),b=a.nextSibling,d=e.text.length):(b=a.parentNode,d=this._getChildIndex(a));a.parentNode.removeChild(a);return[b,d]},_moveBoundary:function(a,b,d,e,f){var g,h,k;k=0;g=this._isText(e)?e:e.childNodes[f];h=this._isText(e)?
e.parentNode:e;this._isText(e)&&(k=f);e=a.createElement("a");h.insertBefore(e,g||null);a=a.body.createTextRange();a.moveToElementText(e);e.parentNode.removeChild(e);b.setEndPoint(d?"StartToStart":"EndToEnd",a);return b[d?"moveStart":"moveEnd"]("character",k)},_isText:function(a){return null!=a?3==a.nodeType:!1},_getChildIndex:function(a){for(var b=0;a=a.previousSibling;)b++;return b},insertNodeAfterCaret:function(a){this.saveSelection();this.insertNodeAtCaret(a);this.restoreSelection()},insertNodeAtCaret:function(a){if(this.window.getSelection){var b=
this.getSelection();if(b.rangeCount){var d=b.getRangeAt(0);d.collapse(!1);d.insertNode(a);d=d.cloneRange();d.selectNodeContents(a);d.collapse(!1);b.removeAllRanges();b.addRange(d)}}else this.document.selection&&(b=1===a.nodeType?a.outerHTML:a.data,d="marker_"+(""+Math.random()).slice(2),b+='<span id="'+d+'"></span>',a=this.getSelection(),a.collapse(!1),a.pasteHTML(b),b=this.document.getElementById(d),a.moveToElementText(b),a.select(),b.parentNode.removeChild(b))},getSelectedHtml:function(){var a=
"";if(this.window.getSelection){var b=this.window.getSelection();if(b.rangeCount){for(var a=this.document.createElement("div"),d=0,e=b.rangeCount;d<e;++d)a.appendChild(b.getRangeAt(d).cloneContents());a=a.innerHTML}}else this.document.selection&&"Text"===this.document.selection.type&&(a=this.document.selection.createRange().htmlText);return a},analyzeSelection:function(){var a=this.getOrigin(),c=this.getFocus(),d=c[0]==a[0]&&c[1]==a[1];b(a[0]).is(".redactor_editor, body")&&(a[0]=a[0].childNodes[a[1]],
a[1]=0);b(c[0]).is(".redactor_editor, body")&&(c[0]=c[0].childNodes[c[1]?c[1]-1:0],c[1]=3==c[0].nodeType?c[0].nodeValue.length:c[0].childNodes.length);var e=b(a[0]).parentsUntil(".redactor_editor, body, html"),f=b(c[0]).parentsUntil(".redactor_editor, body, html"),g,h,k;f.each(function(a){var c=this;e.each(function(a){if(this===c)return g=b(this),k=a,!1});if(g)return h=a,!1});g||(g=this.$editor,k=e.length,h=f.length);var m=0<k?e.get(k-1):a[0],l=0<h?f.get(h-1):c[0],t=[],A=!1,p=function(){var b;b=a;
a=c;c=b;b=e;e=f;f=b;b=k;k=h;h=b;b=m;m=l;l=b};if(c[0]==a[0])a[1]>c[1]&&p();else for(var u=function(a,b){var c=[],d;for(1==a.nodeType&&c.push([a,b]);a&&a!=g[0];){b=0;for(d=a;d=d.previousSibling;)b++;c.push([a.parentNode,b]);a=a.parentNode}return c.reverse()},C=u(a[0],a[1]),u=u(c[0],c[1]),v=0;C[v]&&u[v];v++)if(C[v][0]!=u[v][0]){console.error("unexpected difference in selection path roots");break}else if(C[v][1]<u[v][1])break;else if(C[v][1]>u[v][1]){p();break}var B=function(a){for(;1==a.parentNode.childNodes.length;)a=
a.parentNode;return a};b.each(g.get(0).childNodes,function(a){if(this==l)return!1;this==m?A=!0:A&&t.push(B(this))});a[0].parentNode!=c[0].parentNode&&(p=function(a,c,d,e){var f=b(e).parentsUntil(".redactor_editor, body, html").toArray();f.push(e);f.push(c);for(e=!1;a&&!b(a).is(f);){for(;a[d];){c=a[d];if(b(c).is(f)){e=!0;break}t.push(B(c));a=c}if(e)break;a=a.parentNode}},k&&h&&(p(a[0],m,"nextSibling",c[0]),p(c[0],l,"previousSibling",a[0])));var n,w=null,q,z=null;if(a[0]==c[0])3==a[0].nodeType?0==a[1]&&
c[1]>=a[0].nodeValue.length?(n=q=B(a[0]),t.push(n)):(n=a[0],w=a[1],q=c[0],z=c[1]):0==a[1]&&a[0].childNodes.length==c[1]?(n=q=B(a[0]),t.push(n)):0==a[1]&&0==c[1]?(a[0].insertBefore(a[0].ownerDocument.createTextNode(""),a[0].firstChild),n=q=a[0].childNodes[0],t.push(n)):(b.each(a[0].childNodes,function(b){if(b>=c[1])return!1;b>=a[1]&&t.push(this)}),a[0].childNodes[a[1]]||(p=a[0].ownerDocument.createTextNode(""),a[0].appendChild(p),t.push(p),c[1]++),n=a[0].childNodes[a[1]],q=c[0].childNodes[c[1]?c[1]-
1:0]);else{if(3==a[0].nodeType)0<a[1]?(n=a[0],w=a[1]):(n=B(a[0]),t.push(n));else{var E=f.toArray();E.push(c[0]);b.each(a[0].childNodes,function(c){if(b(this).is(E))return!1;c>=a[1]&&t.push(this)});n=a[0].childNodes[a[1]];n||(n=a[0].nextSibling)}if(3==c[0].nodeType)c[1]<c[0].nodeValue.length?(q=c[0],z=c[1]):(q=B(c[0]),t.push(q));else{var F=e.toArray(),G=!1;F.push(a[0]);b.each(c[0].childNodes,function(a){b(this).is(F)?G=!0:G&&a<c[1]&&t.push(this)});q=c[0].childNodes[c[1]-1];q||(q=c[0].previousSibling)}}var r=
{origin:a,focus:c,$commonAncestor:g,isCollapsed:d,selectedEls:t},D=this,x,y;r.selectPartials=function(a){n==q&&null!==w?(n=q=D.splitTextNode(n,a,w,z),z=w=null,r.selectedEls.push(n)):(null!==w&&(n=D.splitTextNode(n,a,w),w=null,r.selectedEls.push(n)),null!==z&&(q=D.splitTextNode(q,a,0,z),z=null,r.selectedEls.push(q)));return r};r.bookmarkSelection=function(){r.selectPartials();r.removeBookmarks();var a=function(a){for(var b=[],c=!1,d=0;d<r.selectedEls.length;d++)r.selectedEls[d]==a?c=!0:b.push(r.selectedEls[d]);
if(c){for(a=a.firstChild;a;)b.push(a),a=a.nextSibling;r.selectedEls=b}};x=b('<ins class="start"></ins>');b(n).is(".redactor_editor, body, li")?(a(n),x.prependTo(n)):x.insertBefore(n);y=b('<ins class="end"></ins>');b(q).is(".redactor_editor, body, li")?(a(q),y.appendTo(q)):y.insertAfter(q);return[x,y]};r.restoreBookmark=function(){x&&y&&D.setSelection(x.get(0),0,y.get(0),0);r.removeBookmarks()};r.removeBookmarks=function(){x&&x.remove();y&&y.remove()};return r},splitTextNode:function(a,c,d,e){var f=
a.nodeValue;if("undefined"==typeof e||null===e)e=f.length;d=d||0;if(d>e){var g=d;d=e;e=g}g=f.substr(0,d);d=f.substr(d,e-d);e=f.substr(e);c=c?b(c).text(d):b(a.ownerDocument.createTextNode(d));if(g.length&&e.length)a.nodeValue=g,c=c.insertAfter(a),c.after(a.ownerDocument.createTextNode(e));else if(g.length)a.nodeValue=g,c=c.insertAfter(a);else if(e.length)a.nodeValue=e,c=c.insertBefore(a);else return a;return c.get(0)},resizeImage:function(a){var c=!1,d=!1,e,f=b(a).width()/b(a).height();b(a).off("hover mousedown mouseup click mousemove");
b(a).hover(function(){b(a).css("cursor","nw-resize")},function(){b(a).css("cursor","");c=!1});b(a).mousedown(function(g){g.preventDefault();f=b(a).width()/b(a).height();d=c=!0;Math.round(g.pageX-b(a).eq(0).offset().left);e=Math.round(g.pageY-b(a).eq(0).offset().top)});b(a).mouseup(b.proxy(function(d){c=!1;b(a).css("cursor","");this.syncCode()},this));b(a).click(b.proxy(function(a){d&&this.imageEdit(a)},this));b(a).mousemove(function(g){if(c){d=!1;Math.round(g.pageX-b(this).eq(0).offset().left);var h=
Math.round(g.pageY-b(this).eq(0).offset().top)-e,k=b(a).height(),h=parseInt(k,10)+h,k=h*f;10<k&&b(a).width(k);10<h&&b(a).height(h);Math.round(g.pageX-b(this).eq(0).offset().left);e=Math.round(g.pageY-b(this).eq(0).offset().top)}})},showTable:function(){this.saveSelection();this.modalInit(RLANG.table,this.opts.modal_table,300,b.proxy(function(){b("#redactor_insert_table_btn").click(b.proxy(this.insertTable,this));setTimeout(function(){b("#redactor_table_rows").focus()},200)},this))},insertTable:function(){for(var a=
b("#redactor_table_rows").val(),c=b("#redactor_table_columns").val(),d=b("<div></div>"),e=Math.floor(99999*Math.random()),e=b('<table id="table'+e+'"><tbody></tbody></table>'),f=0;f<a;f++){for(var g=b("<tr></tr>"),h=0;h<c;h++){var k=b("<td><br></td>");b(g).append(k)}b(e).append(g)}b(d).append(e);a=b(d).html()+"<p></p>";this.restoreSelection();this.execCommand("inserthtml",a);this.modalClose();this.observeTables()},tableObserver:function(a){this.$table=b(a.target).closest("table");this.$table_tr=this.$table.find("tr");
this.$table_td=this.$table.find("td");this.$tbody=b(a.target).closest("tbody");this.$thead=b(this.$table).find("thead");this.$current_td=b(a.target);this.$current_tr=b(a.target).closest("tr")},deleteTable:function(){b(this.$table).remove();this.$table=!1;this.syncCode()},deleteRow:function(){b(this.$current_tr).remove();this.syncCode()},deleteColumn:function(){var a=b(this.$current_td).get(0).cellIndex;b(this.$table).find("tr").each(function(){b(this).find("td").eq(a).remove()});this.syncCode()},
addHead:function(){if(0!==b(this.$table).find("thead").size())this.deleteHead();else{var a=b(this.$table).find("tr").first().clone();a.find("td").html("&nbsp;");this.$thead=b("<thead></thead>");this.$thead.append(a);b(this.$table).prepend(this.$thead);this.syncCode()}},deleteHead:function(){b(this.$thead).remove();this.$thead=!1;this.syncCode()},insertRowAbove:function(){this.insertRow("before")},insertRowBelow:function(){this.insertRow("after")},insertColumnLeft:function(){this.insertColumn("before")},
insertColumnRight:function(){this.insertColumn("after")},insertRow:function(a){var c=b(this.$current_tr).clone();c.find("td").html("&nbsp;");"after"===a?b(this.$current_tr).after(c):b(this.$current_tr).before(c);this.syncCode()},insertColumn:function(a){var c=0;this.$current_tr.find("td").each(b.proxy(function(a,e){b(e)[0]===this.$current_td[0]&&(c=a)},this));this.$table_tr.each(function(d,e){var f=b(e).find("td").eq(c),g=f.clone();g.html("&nbsp;");"after"===a?b(f).after(g):b(f).before(g)});this.syncCode()},
showVideo:function(){this.saveSelection();this.modalInit(RLANG.video,this.opts.modal_video,600,b.proxy(function(){b("#redactor_insert_video_btn").click(b.proxy(this.insertVideo,this));setTimeout(function(){b("#redactor_insert_video_area").focus()},200)},this))},insertVideo:function(){var a=b("#redactor_insert_video_area").val(),a=this.stripTags(a);this.restoreSelection();this.execCommand("inserthtml",a);this.modalClose()},imageEdit:function(a){var c=b(a.target),d=c.parent();a=b.proxy(function(){b("#redactor_file_alt").val(c.attr("alt"));
b("#redactor_image_edit_src").attr("href",c.attr("src"));b("#redactor_form_image_align").val(c.css("float"));"A"===b(d).get(0).tagName&&b("#redactor_file_link").val(b(d).attr("href"));b("#redactor_image_delete_btn").click(b.proxy(function(){this.imageDelete(c)},this));b("#redactorSaveBtn").click(b.proxy(function(){this.imageSave(c)},this))},this);this.modalInit(RLANG.image,this.opts.modal_image_edit,380,a)},imageDelete:function(a){var c=b(a).parent();0!=c.size()&&"A"==c[0].tagName?c.remove():b(a).remove();
this.modalClose();this.syncCode()},imageSave:function(a){var c=b(a).parent();b(a).attr("alt",b("#redactor_file_alt").val());var d=b("#redactor_form_image_align").val();"left"===d?b(a).css({"float":"left",margin:"0 10px 10px 0"}):"right"===d?b(a).css({"float":"right",margin:"0 0 10px 10px"}):b(a).css({"float":"none",margin:"0"});d=b.trim(b("#redactor_file_link").val());""!==d?"A"!==b(c).get(0).tagName?b(a).replaceWith('<a href="'+d+'">'+this.outerHTML(a)+"</a>"):b(c).attr("href",d):"A"===b(c).get(0).tagName&&
b(c).replaceWith(this.outerHTML(a));this.modalClose();this.observeImages();this.syncCode()},showImage:function(){this.saveSelection();var a=b.proxy(function(){!1!==this.opts.imageGetJson?b.getJSON(this.opts.imageGetJson,b.proxy(function(a){var c={},f=0;b.each(a,b.proxy(function(a,b){"undefined"!==typeof b.folder&&(f++,c[b.folder]=f)},this));var g=!1;b.each(a,b.proxy(function(a,d){var f="";"undefined"!==typeof d.title&&(f=d.title);var h=0;b.isEmptyObject(c)||"undefined"===typeof d.folder||(h=c[d.folder],
!1===g&&(g=".redactorfolder"+h));f=b('<img src="'+d.thumb+'" class="redactorfolder redactorfolder'+h+'" rel="'+d.image+'" title="'+f+'" />');b("#redactor_image_box").append(f);b(f).click(b.proxy(this.imageSetThumb,this))},this));if(!b.isEmptyObject(c)){b(".redactorfolder").hide();b(g).show();var h=b('<select id="redactor_image_box_select">');b.each(c,function(a,c){h.append(b('<option value="'+c+'">'+a+"</option>"))});b("#redactor_image_box").before(h);h.change(function(a){b(".redactorfolder").hide();
b(".redactorfolder"+b(a.target).val()).show()})}},this)):b("#redactor_tabs a").eq(1).remove();if(!1!==this.opts.imageUpload)!1===this.opts.uploadCrossDomain&&!1===this.isMobile()&&0!==b("#redactor_file").size()&&b("#redactor_file").dragupload({url:this.opts.imageUpload,uploadFields:this.opts.uploadFields,success:b.proxy(this.imageUploadCallback,this),error:b.proxy(this.opts.imageUploadErrorCallback,this)}),this.uploadInit("redactor_file",{auto:!0,url:this.opts.imageUpload,success:b.proxy(this.imageUploadCallback,
this),error:b.proxy(this.opts.imageUploadErrorCallback,this)});else if(b(".redactor_tab").hide(),!1===this.opts.imageGetJson)b("#redactor_tabs").remove(),b("#redactor_tab3").show();else{var a=b("#redactor_tabs a");a.eq(0).remove();a.eq(1).addClass("redactor_tabs_act");b("#redactor_tab2").show()}b("#redactor_upload_btn").click(b.proxy(this.imageUploadCallbackLink,this));!1===this.opts.imageUpload&&!1===this.opts.imageGetJson&&setTimeout(function(){b("#redactor_file_link").focus()},200)},this);this.modalInit(RLANG.image,
this.opts.modal_image,600,a)},imageSetThumb:function(a){this._imageSet('<img src="'+b(a.target).attr("rel")+'" alt="'+b(a.target).attr("title")+'" />&nbsp;',!0)},imageUploadCallbackLink:function(){if(""!==b("#redactor_file_link").val()){var a='<img src="'+b("#redactor_file_link").val()+'" />&nbsp;';this._imageSet(a,!0)}else this.modalClose()},imageUploadCallback:function(a){this._imageSet(a)},_imageSet:function(a,b){this.restoreSelection();if(!1!==a){var d="",d=!0!==b?'<p><img src="'+a.filelink+'" /></p>':
a;this.execCommand("inserthtml",d);!0!==b&&"function"===typeof this.opts.imageUploadCallback&&this.opts.imageUploadCallback(this,a)}this.modalClose();this.observeImages()},showLink:function(){this.saveSelection();var a=b.proxy(function(){this.insert_link_node=!1;var a=this.getSelection(),d="",e="",f="";this.browser("msie")?(e=this.getParentNode(),"A"===e.nodeName?(this.insert_link_node=b(e),e=this.insert_link_node.text(),d=this.insert_link_node.attr("href"),f=this.insert_link_node.attr("target")):
e=this.oldIE()?a.text:a.toString()):a&&a.anchorNode&&"A"===a.anchorNode.parentNode.tagName?(d=a.anchorNode.parentNode.href,e=a.anchorNode.parentNode.text,f=a.anchorNode.parentNode.target,""===a.toString()&&(this.insert_link_node=a.anchorNode.parentNode)):e=a.toString();b("#redactor_link_url_text").val(e);a=self.location.href.replace(/\/$/i,"");a=d.replace(a,"");0===d.search("mailto:")?(this.setModalTab(2),b("#redactor_tab_selected").val(2),b("#redactor_link_mailto").val(d.replace("mailto:",""))):
0===a.search(/^#/gi)?(this.setModalTab(3),b("#redactor_tab_selected").val(3),b("#redactor_link_anchor").val(a.replace(/^#/gi,""))):b("#redactor_link_url").val(a);"_blank"===f&&b("#redactor_link_blank").attr("checked",!0);b("#redactor_insert_link_btn").click(b.proxy(this.insertLink,this));setTimeout(function(){b("#redactor_link_url").focus()},200)},this);this.modalInit(RLANG.link,this.opts.modal_link,600,a)},insertLink:function(){var a=b("#redactor_tab_selected").val(),c="",d="",e="",f="";"1"===a?
(c=b("#redactor_link_url").val(),d=b("#redactor_link_url_text").val(),d.length||(d=c),b("#redactor_link_blank").prop("checked")&&(e=' target="_blank"',f="_blank"),c.length&&!c.match(/^(\w+:)|\//)&&(c=this.opts.protocol+c)):"2"===a?(c="mailto:"+b("#redactor_link_mailto").val(),d=b("#redactor_link_mailto_text").val(),d.length||(d=b("#redactor_link_mailto").val())):"3"===a&&(c="#"+b("#redactor_link_anchor").val(),d=b("#redactor_link_anchor_text").val());this._insertLink('<a href="'+c+'"'+e+">"+d+"</a>",
b.trim(d),c,f)},_insertLink:function(a,c,d,e){this.focus();this.restoreSelection();""!==c&&""!==d&&(this.insert_link_node?(b(this.insert_link_node).text(c),b(this.insert_link_node).attr("href",d),""!==e?b(this.insert_link_node).attr("target",e):b(this.insert_link_node).removeAttr("target"),this.syncCode()):this.execCommand("inserthtml",a));this.modalClose()},showFile:function(){this.saveSelection();var a=b.proxy(function(){var a=this.getSelection(),d="",d=this.oldIE()?a.text:a.toString();b("#redactor_filename").val(d);
!1===this.opts.uploadCrossDomain&&!1===this.isMobile()&&b("#redactor_file").dragupload({url:this.opts.fileUpload,uploadFields:this.opts.uploadFields,success:b.proxy(this.fileUploadCallback,this),error:b.proxy(this.opts.fileUploadErrorCallback,this)});this.uploadInit("redactor_file",{auto:!0,url:this.opts.fileUpload,success:b.proxy(this.fileUploadCallback,this),error:b.proxy(this.opts.fileUploadErrorCallback,this)})},this);this.modalInit(RLANG.file,this.opts.modal_file,600,a)},fileUploadCallback:function(a){this.restoreSelection();
if(!1!==a){var c=b("#redactor_filename").val();""===c&&(c=a.filename);c='<a href="'+a.filelink+'">'+c+"</a>";this.browser("webkit")&&this.window.chrome&&(c+="&nbsp;");this.execCommand("inserthtml",c);"function"===typeof this.opts.fileUploadCallback&&this.opts.fileUploadCallback(this,a)}this.modalClose()},modalDeferredInit:function(a,c,d,e){if(this.deferredModal[c])this.modalInit(a,this.deferredModal[c],d,e);else if(this.opts.modalLoadCallback)this.opts.modalLoadCallback(this,a,c,d,e);else{var f=this;
b.ajax(c).done(function(b){f.deferredModal[c]=b;f.modalInit(a,f.deferredModal[c],d,e)})}},modalInit:function(a,c,d,e){if("object"===typeof c&&c.url)this.modalDeferredInit(a,c.url,d,e);else{this.saveSelection();this.restoreAndClose||(this.restoreAndClose=b.proxy(function(){this.restoreSelection();this.modalClose();return!1},this));d=Math.min(d,b(window).width());0===b("#redactor_modal_overlay").size()&&(this.overlay=b('<div id="redactor_modal_overlay" style="display: none;"></div>'),b("body").append(this.overlay));
this.opts.overlay&&(b("#redactor_modal_overlay").show(),b("#redactor_modal_overlay").click(this.restoreAndClose));0===b("#redactor_modal").size()&&(this.modal=b('<div id="redactor_modal" style="display: none;"><div id="redactor_modal_close">&times;</div><div id="redactor_modal_header"></div><div id="redactor_modal_inner"></div></div>'),b("body").append(this.modal),this.opts.modalCreateCallback&&(this.modal=this.opts.modalCreateCallback(this,this.modal)));b("#redactor_modal_close").click(this.restoreAndClose);
this.hdlModalClose=b.proxy(function(a){if(27===a.keyCode)return this.restoreSelection(),this.modalClose(),!1},this);b(document).keyup(this.hdlModalClose);this.$editor.keyup(this.hdlModalClose);0==c.indexOf("#")?b("#redactor_modal_inner").empty().append(b(c).html()):b("#redactor_modal_inner").empty().append(c);b("#redactor_modal_header").html(a);"undefined"!==typeof b.fn.draggable&&(b("#redactor_modal").draggable({handle:"#redactor_modal_header"}),b("#redactor_modal_header").css("cursor","move"));
if(0!==b("#redactor_tabs").size()){var f=this;b("#redactor_tabs a").each(function(a,c){a++;b(c).click(function(){b("#redactor_tabs a").removeClass("redactor_tabs_act");b(this).addClass("redactor_tabs_act");b(".redactor_tab").hide();b("#redactor_tab"+a).show();b("#redactor_tab_selected").val(a);if(!1===f.isMobile()){var c=b("#redactor_modal").outerHeight();b("#redactor_modal").css("margin-top","-"+(c+10)/2+"px")}})})}b("#redactor_modal .redactor_btn_modal_close").click(this.restoreAndClose);!1===this.isMobile()?
(b("#redactor_modal").css({position:"fixed",top:"-2000px",left:"50%",width:d+"px",marginLeft:"-"+d/2+"px"}).show(),this.modalSaveBodyOveflow=b(document.body).css("overflow")):b("#redactor_modal").css({position:"absolute",left:0,right:0,top:b(window).scrollTop()+50}).show();"function"===typeof e&&e();!1===this.isMobile()&&setTimeout(function(){var a=b("#redactor_modal").outerHeight();b("#redactor_modal").css({top:"50%",height:"auto",minHeight:"auto",marginTop:"-"+(a+10)/2+"px"})},20)}},modalClose:function(){b("#redactor_modal_close").unbind("click",
this.restoreAndClose);b("#redactor_modal").fadeOut("fast",b.proxy(function(){b("#redactor_modal_inner").html("");this.opts.overlay&&(b("#redactor_modal_overlay").hide(),b("#redactor_modal_overlay").unbind("click",this.restoreAndClose));b(document).unbind("keyup",this.hdlModalClose);this.$editor.unbind("keyup",this.hdlModalClose)},this));!1===this.isMobile()&&b(document.body).css("overflow",this.modalSaveBodyOveflow?this.modalSaveBodyOveflow:"visible");this.focus();return!1},setModalTab:function(a){b(".redactor_tab").hide();
var c=b("#redactor_tabs a");c.removeClass("redactor_tabs_act");c.eq(a-1).addClass("redactor_tabs_act");b("#redactor_tab"+a).show()},uploadInit:function(a,c){this.uploadOptions={url:!1,success:!1,error:!1,start:!1,trigger:!1,auto:!1,input:!1};b.extend(this.uploadOptions,c);0!==b("#"+a).size()&&"INPUT"===b("#"+a).get(0).tagName?(this.uploadOptions.input=b("#"+a),this.element=b(b("#"+a).get(0).form)):this.element=b("#"+a);this.element_action=this.element.attr("action");this.uploadOptions.auto?b(this.uploadOptions.input).change(b.proxy(function(){this.element.submit(function(a){return!1});
this.uploadSubmit()},this)):this.uploadOptions.trigger&&b("#"+this.uploadOptions.trigger).click(b.proxy(this.uploadSubmit,this))},uploadSubmit:function(){this.uploadForm(this.element,this.uploadFrame())},uploadFrame:function(){this.id="f"+Math.floor(99999*Math.random());var a=this.document.createElement("div");a.innerHTML='<iframe style="display:none" id="'+this.id+'" name="'+this.id+'"></iframe>';b(a).appendTo("body");this.uploadOptions.start&&this.uploadOptions.start();b("#"+this.id).load(b.proxy(this.uploadLoaded,
this));return this.id},uploadForm:function(a,c){if(this.uploadOptions.input){var d="redactorUploadForm"+this.id,e="redactorUploadFile"+this.id;this.form=b('<form  action="'+this.uploadOptions.url+'" method="POST" target="'+c+'" name="'+d+'" id="'+d+'" enctype="multipart/form-data"></form>');!1!==this.opts.uploadFields&&"object"===typeof this.opts.uploadFields&&b.each(this.opts.uploadFields,b.proxy(function(a,c){0===c.toString().indexOf("#")&&(c=b(c).val());var d=b("<input/>",{type:"hidden",name:a,
value:c});b(this.form).append(d)},this));var d=this.uploadOptions.input,f=b(d).clone();b(d).attr("id",e);b(d).before(f);b(d).appendTo(this.form);b(this.form).css("position","absolute");b(this.form).css("top","-2000px");b(this.form).css("left","-2000px");b(this.form).appendTo("body");this.form.submit()}else a.attr("target",c),a.attr("method","POST"),a.attr("enctype","multipart/form-data"),a.attr("action",this.uploadOptions.url),this.element.submit()},uploadLoaded:function(){var a=b("#"+this.id)[0],
a=a.contentDocument?a.contentDocument:a.contentWindow?a.contentWindow.document:window.frames[this.id].document;this.uploadOptions.success&&("undefined"!==typeof a?(a=a.body.innerHTML.match(/\{(.|\n)*\}/)[0],a=b.parseJSON(a),"undefined"==typeof a.error?this.uploadOptions.success(a):(this.uploadOptions.error(this,a),this.modalClose())):(alert("Upload failed!"),this.modalClose()));this.element.attr("action",this.element_action);this.element.attr("target","")},browser:function(a){var b=navigator.userAgent.toLowerCase(),
b=/(chrome)[ \/]([\w.]+)/.exec(b)||/(webkit)[ \/]([\w.]+)/.exec(b)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(b)||/(msie) ([\w.]+)/.exec(b)||/(trident).*rv:([\w.]+)/.exec(b)||0>b.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(b)||[];return"version"==a?b[2]:"webkit"==a?"chrome"==b[1]||"webkit"==b[1]:"msie"==a?"msie"==b[1]||"trident"==b[1]:b[1]==a},oldIE:function(){return this.browser("msie")&&9>parseInt(this.browser("version"),10)?!0:!1},outerHTML:function(a){return b("<p>").append(b(a).eq(0).clone()).html()},
normalize:function(a){return parseInt(a.replace("px",""),10)},isMobile:function(a){return!0===a&&/(iPhone|iPod|iPad|BlackBerry|Android)/.test(navigator.userAgent)?!0:/(iPhone|iPod|BlackBerry|Android)/.test(navigator.userAgent)?!0:!1}};b.fn.getObject=function(){return this.data("redactor")};b.fn.getEditor=function(){return this.data("redactor").$editor};b.fn.getCode=function(){return b.trim(this.data("redactor").getCode())};b.fn.getText=function(){return this.data("redactor").$editor.text()};b.fn.getSelected=
function(){return this.data("redactor").getSelectedHtml()};b.fn.setCode=function(a,b){this.data("redactor").setCode(a,b)};b.fn.insertHtml=function(a){this.data("redactor").insertHtml(a)};b.fn.destroyEditor=function(){this.each(function(){"undefined"!=typeof b(this).data("redactor")&&(b(this).data("redactor").destroy(),b(this).removeData("redactor"))})};b.fn.setFocus=function(a){this.data("redactor").focus(a)};b.fn.execCommand=function(a,b){this.data("redactor").execCommand(a,b)}})(jQuery);
(function(b){function l(a,c){this.opts=b.extend({url:!1,success:!1,error:!1,preview:!1,uploadFields:!1,text:RLANG.drop_file_here,atext:RLANG.or_choose},c);this.$el=b(a)}b.fn.dragupload=function(a){return this.each(function(){(new l(this,a)).init()})};l.prototype={init:function(){if(-1===navigator.userAgent.search("MSIE")){this.droparea=b('<div class="redactor_droparea"></div>');this.dropareabox=b('<div class="redactor_dropareabox">'+this.opts.text+"</div>");this.dropalternative=b('<div class="redactor_dropalternative">'+
this.opts.atext+"</div>");this.droparea.append(this.dropareabox);this.$el.before(this.droparea);this.$el.before(this.dropalternative);this.dropareabox.bind("dragover",b.proxy(function(){return this.ondrag()},this));this.dropareabox.bind("dragleave",b.proxy(function(){return this.ondragleave()},this));var a=b.proxy(function(a){a=parseInt(a.loaded/a.total*100,10);this.dropareabox.text("Loading "+a+"%")},this),c=jQuery.ajaxSettings.xhr();c.upload&&c.upload.addEventListener("progress",a,!1);var d=function(){return c};
this.dropareabox.get(0).ondrop=b.proxy(function(a){a.preventDefault();this.dropareabox.removeClass("hover").addClass("drop");a=a.dataTransfer.files[0];var c=new FormData;!1!==this.opts.uploadFields&&"object"===typeof this.opts.uploadFields&&b.each(this.opts.uploadFields,b.proxy(function(a,d){0===d.toString().indexOf("#")&&(d=b(d).val());c.append(a,d)},this));c.append("file",a);b.ajax({url:this.opts.url,dataType:"html",data:c,xhr:d,cache:!1,contentType:!1,processData:!1,type:"POST",success:b.proxy(function(a){a=
b.parseJSON(a);"undefined"==typeof a.error?this.opts.success(a):(this.opts.error(this,a),this.opts.success(!1))},this)})},this)}},ondrag:function(){this.dropareabox.addClass("hover");return!1},ondragleave:function(){this.dropareabox.removeClass("hover");return!1}}})(jQuery);
(function(b){var l=/(^|&lt;|\s)(www\..+?\..+?)(\s|&gt;|$|\[|\])/g,a=/(^|&lt;|\s)(((https?|ftp):\/\/|mailto:).+?)(\s|&gt;|$|\[|\])/g,c=function(){for(var d=this.childNodes,e=d.length;e--;){var f=d[e];if(3===f.nodeType){var g=f.nodeValue;g&&(g=g.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(l,'$1<a href="http://$2">$2</a>$3').replace(a,'$1<a href="$2">$2</a>$5'),g!=f.nodeValue&&b(f).after(g).remove())}else 1!==f.nodeType||/^(a|button|textarea)$/i.test(f.tagName)||c.call(f)}};
b.fn.linkify=function(){this.each(c)}})(jQuery);
(function(b){b.event.special.textselect={setup:function(l,a){b(this).data("textselected",!1);b(this).data("ttt",l);b(this).on("mouseup",b.event.special.textselect.handler)},teardown:function(l){b(this).off("mouseup",b.event.special.textselect.handler)},handler:function(l){var a=b(this).data("ttt"),a=b.event.special.textselect.getSelectedText(a).toString();""!=a&&(b(this).data("textselected",!0),l.type="textselect",l.text=a,b.event.dispatch.apply(this,arguments))},getSelectedText:function(b){b="";
rwindow.getSelection?b=rwindow.getSelection():rdocument.getSelection?b=rdocument.getSelection():rdocument.selection&&(b=rdocument.selection.createRange().text);return b}};b.event.special.textunselect={setup:function(l,a){b(this).data("rttt",l);b(this).data("textselected",!1);b(this).on("mouseup",b.event.special.textunselect.handler);b(this).on("keyup",b.event.special.textunselect.handlerKey)},teardown:function(l){b(this).unbind("mouseup",b.event.special.textunselect.handler)},handler:function(l){if(b(this).data("textselected")){var a=
b(this).data("rttt");""==b.event.special.textselect.getSelectedText(a).toString()&&(b(this).data("textselected",!1),l.type="textunselect",b.event.dispatch.apply(this,arguments))}},handlerKey:function(l){if(b(this).data("textselected")){var a=b(this).data("rttt"),a=b.event.special.textselect.getSelectedText(a).toString();if(l.keyCode=27,""==a)b(this).data("textselected",!1),l.type="textunselect",b.event.dispatch.apply(this,arguments)}}}})(jQuery);