/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.1.9 Patch Level 4
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2016 vBulletin Solutions Inc. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/
window.vBulletin=window.vBulletin||{};window.vBulletin.phrase=window.vBulletin.phrase||{};window.vBulletin.phrase.precache=window.vBulletin.phrase.precache||[];window.vBulletin.phrase.precache.push("wrap_x_tags","insert_video","retrieve_remote_file_and_ref_local");window.vBulletin.options=window.vBulletin.options||{};window.vBulletin.options.precache=window.vBulletin.options.precache||[];window.vBulletin.options.precache=$.merge(window.vBulletin.options.precache,["threadpreview","minuserlength","maxuserlength"]);vBulletin.ckeditor=vBulletin.ckeditor||{};CKEDITOR.config.allowedContent=true;if(typeof (pageData.ckeditorCss)!="undefined"){CKEDITOR.config.contentsCss=pageData.ckeditorCss}CKEDITOR.config.toolbar_vBulletinFull=(function(){var D=[["EnhancedSource","Source","RemoveFormat","PasteText","PasteFromWord"],["Font","FontSize"],["TextColor","-","Undo","Redo"],["Bold","Italic","Underline"],["JustifyLeft","JustifyCenter","JustifyRight"],["NumberedList","BulletedList","Outdent","Indent"],["Link","Email","Unlink","Image","Video"],["Quote"],["Code","Html","Php"],["Table","vBTable"],["Subscript","Superscript","HorizontalRule"]];if(window.pageData&&window.pageData.channelType&&window.pageData.channelType=="article"){D.push(["PageBreak","PreviewBreak"])}if(jQuery.type(window.vBulletin.customBbcode)!=="undefined"){var B=[];for(var A in window.vBulletin.customBbcode){if(!A){continue}var C=window.vBulletin.customBbcode[A];B.push(C.title)}if(B.length>0){D[D.length]=B}}return D})();var CK2BB={Font:"font",FontSize:"size",TextColor:"color",Bold:"b",Italic:"i",Underline:"u",Subscript:"sub",Superscript:"sup",HorizontalRule:"hr",Table:"table",TableProperties:"table",DeleteTable:"table",InsertRowBefore:"table",InsertRowAfter:"table",DeleteRow:"table",InsertColumnBefore:"table",InsertColumnAfter:"table",DeleteColumn:"table",JustifyLeft:"left",JustifyCenter:"center",JustifyRight:"right",NumberedList:"list",BulletedList:"list",Outdent:"indent",Indent:"indent",Link:"url",Email:"email",Unlink:"url",Quote:"quote",Code:"code",Html:"html",Php:"php"};CKEDITOR.config.baseHref=pageData.baseurl+"/";CKEDITOR.config.smiley_path=pageData.baseurl_core+"/";CKEDITOR.config.enterMode=CKEDITOR.ENTER_BR;CKEDITOR.config.entities=false;CKEDITOR.config.height=70;CKEDITOR.config.width="100%";CKEDITOR.config.autoGrow_minHeight=70;CKEDITOR.config.autoGrow_maxHeight=800;CKEDITOR.config.contentsLangDirection=pageData.textdirection;CKEDITOR.config.language="en";CKEDITOR.config.defaultLanguage="en";CKEDITOR.config.language_list=["en"];vBulletin.ckeditor.config={toolbar:"vBulletinFull",customConfig:"",toolbarCanCollapse:false,resize_dir:"vertical",removePlugins:"about,elementspath,link,smiley,liststyle,resize,sourcearea,scayt",extraPlugins:"vblink,vbwrapbuttons,vbsource,videotag,autosave,autogrow,vbtable",pluginPath:pageData.baseurl+"/js/ckeplugins/",tabIndex:1,disableNativeSpellChecker:false,filebrowserImageUploadUrl:pageData.baseurl+"/uploader/CKEditorInsertImage"};(function(){var A=vBulletin.ckeditor.config.extraPlugins.split(",");for(var B=0;B<A.length;B++){try{if(!CKEDITOR.plugins.get(A[B])){console.log("Ckeditor: Plugin Loaded: "+pageData.baseurl+"/js/ckeplugins/"+A[B]+"/plugin.js");CKEDITOR.plugins.addExternal(A[B],vBulletin.ckeditor.config.pluginPath+A[B]+"/","plugin.js")}}catch(C){console.warn("Ckeditor: Plugin failed to load: "+pageData.baseurl+"/js/ckeplugins/"+A[B]+"/plugin.js")}}})();vBulletin.ckeditor.instances={};vBulletin.ckeditor.imageSettings=["imgAlignment","imgSize","imgTitle","imgDescription","imgStyles","imgLink","imgLinkURL","imgLinkTarget",];vBulletin.ckeditor.initFocus=function(B,A){if($("#"+B).is(".js-ckeditor-init-on-focus")||$("#"+B).is(".js-ckeditor-focus-editor-after-init")){A.focus();console.log("Ckeditor: Focus on editor for editor: {0}".format(B))}};vBulletin.ckeditor._isEmptyData=function(A){A=A+"";if(A.length>1000){return false}if(A.match(/<(table|ol|ul|li|img|hr)/)||A.match(/<(div|ol|ul|li|img) style="(margin-left|margin-right|text-align)/)){return false}if(A.match(/<h3\s+class="wysiwyg_pagebreak">/)){return false}A=$("<div />").append(A).text();A=$.trim(A).replace(/&nbsp;|\s|\n|\t/g,"");return !A};vBulletin.ckeditor.initPlaceholder=function(D,C){var E=$("#"+D),J=E.closest(".b-editor").find(".cke_contents"),I=E.attr("placeholder");C=C||vBulletin.ckeditor.getEditor(D);console.log("Ckeditor: Initializing placeholder text");if(!I){console.warn("Ckeditor: Placeholder text: No placeholder text");return }var G=J.find(".b-editor__placeholder");if(G.length==0){G=$("<div />").text(I).addClass("b-editor__placeholder h-hide placeholder").appendTo(J)}var B=function(K){return K.document?K.document.getBody():null};var F=function(K){if(K&&!K.hasClass("js-vbulletin-has-placeholder-events")){console.log("Ckeditor: Placeholder text: attachBodyEventHandlers");K.on("keydown",H);K.on("drop",H);K.addClass("js-vbulletin-has-placeholder-events")}};var A=true;var H=function(K){window.setTimeout(function(){var L=B(C);if(L){F(L);var P=vBulletin.ckeditor._isEmptyData(L.getHtml());G.toggleClass("h-hide",!P);if(A&&!P){var M=E.closest(".js-content-entry"),O=M.find(".js-human-verification"),N=O.find(".imagereg");M.find(".js-button-group").removeClass("h-hide");O.removeClass("h-hide");if(N.height()!=N.attr("height")){O.find(".refresh_imagereg").click()}A=false}}},10)};C.on("saveSnapshot",H);C.on("afterCommandExec",H);F(B(C));C.on("mode",function(K){if(K.editor.mode!="source"){vBulletin.ckeditor.initPlaceholder(D)}});H()};vBulletin.ckeditor.initToolbarCloseButton=function(B,A){var E=$("#"+B),D=E.closest(".b-editor").find(".cke_top");var C=$("<span />").addClass("b-icon b-icon__x-circle--dark h-right js-link js-contententry-panel-x h-margin-right-m h-margin-top-m").text("x").appendTo(D)};vBulletin.ckeditor.modifyDialogs=function(C,A){var B=vBulletin.ckeditor.getEditor(C);CKEDITOR.on("dialogDefinition",function(F){var G=F.data.name;var I=F.data.definition;switch(G){case"image":I.removeContents("advanced");I.removeContents("Link");var E=I.getContents("info");E.remove("remote");E.remove("txtWidth");E.remove("txtHeight");E.remove("txtBorder");E.remove("txtAlt");E.remove("ratioLock");E.remove("txtHSpace");E.remove("txtVSpace");E.remove("cmbAlign");for(var D=0;D<vBulletin.ckeditor.imageSettings.length;D++){E.remove(vBulletin.ckeditor.imageSettings[D])}E.add({type:"radio",id:"imgAlignment",label:B.lang.common.align,items:[[B.lang.vbulletin.none,"none"],[B.lang.common.alignLeft,"left"],[B.lang.common.alignCenter,"center"],[B.lang.common.alignRight,"right"]],"default":"none",});E.add({type:"radio",id:"imgSize",label:B.lang.vbulletin.size,items:[[B.lang.vbulletin.icon,"icon"],[B.lang.vbulletin.thumbnail,"thumb"],[B.lang.vbulletin.small,"small"],[B.lang.vbulletin.medium,"medium"],[B.lang.vbulletin.large,"large"],[B.lang.vbulletin.fullsize,"full"]],"default":"full",});E.add({type:"text",id:"imgTitle",label:B.lang.vbulletin.title,});E.add({type:"textarea",id:"imgDescription",label:B.lang.vbulletin.description,});E.add({type:"text",id:"imgStyles",label:B.lang.vbulletin.style,});E.add({type:"radio",id:"imgLink",label:B.lang.vbulletin.linktype,items:[[B.lang.vbulletin["default"],"0"],[B.lang.common.url,"1"],[B.lang.vbulletin.none,"2"]],"default":"0",onChange:function(){var J=this.getDialog();var K=J.getContentElement("info","imgLink");var M=J.getContentElement("info","imgLinkURL");var L=J.getContentElement("info","imgLinkTarget");if(K.isEnabled()&&K.getValue()==1){M.enable();L.enable()}else{M.disable();L.disable()}},});E.add({type:"text",id:"imgLinkURL",label:B.lang.vbulletin.linkurl,onShow:function(){var J=this.getDialog();var K=J.getContentElement("info","imgLink");if(K.isEnabled()&&K.getValue()==1){this.enable()}else{this.disable()}},});E.add({type:"select",id:"imgLinkTarget",label:B.lang.vbulletin.linktarget,items:[[B.lang.common.targetSelf,"0"],[B.lang.common.targetNew,"1"]],"default":"0",onShow:function(){var J=this.getDialog();var K=J.getContentElement("info","imgLink");if(K.isEnabled()&&K.getValue()==1){this.enable()}else{this.disable()}},});E.add({type:"checkbox",id:"remote",label:vBulletin.phrase.get("retrieve_remote_file_and_ref_local"),validate:function(){if(this.getValue()){var L=this.getDialog();var K=L.getContentElement("info","txtUrl");var J=K.getValue();if(!J){return true}L.disableButton("ok");L.disableButton("cancel");var N=false;var M=this;vBulletin.AJAX({async:false,url:vBulletin.getAjaxBaseurl()+"/uploader/url",data:{urlupload:J,attachment:1},skipdefaultsuccess:true,success:function(O){if(O.errors){var P=O.errors;if($.isArray(P)&&P.length>0){P=P[0]}alert(vBulletin.phrase.get("error_x",vBulletin.phrase.get(P)))}else{if(O.imageUrl){var Q={url:O.imageUrl,filedataid:O.filedataid,name:O.filename,};vBulletin.ckeditor.closeFileDialog(C,new Array(Q));N=true}}},fail:function(P){var Q=vBulletin.phrase.get("error_uploading_image");var O="error";if(P&&P.files.length>0){switch(P.files[0].error){case"acceptFileTypes":Q=vBulletin.phrase.get("invalid_image_allowed_filetypes_are");O="warning";break}}alert(Q)},complete:function(){L.enableButton("ok");L.enableButton("cancel")}});return N}}});var H=I.onOk;I.onOk=function(K){var J=this.getContentElement("info","remote");if(J&&J.getValue()){}else{H.apply(this,K)}};break;default:}});B.on("dialogShow",function(O){var N=O.data;var H=N.getName();switch(H){case"image":var F=B.getSelection(),K=F&&F.getSelectedElement(),P=K&&B.elementPath(K).contains("a",1);N.getContentElement("info","htmlPreview").getElement().hide();var T=K&&K.getAttribute("src");var I=pageData.baseurl+"/filedata/fetch?";showDefaultImageBits=function(){N.showPage("Upload");for(var U=0;U<vBulletin.ckeditor.imageSettings.length;U++){imgSettingElement=N.getContentElement("info",vBulletin.ckeditor.imageSettings[U]);if(imgSettingElement){imgSettingElement.getElement().hide()}}N.getContentElement("info","remote").getElement().show();N.getContentElement("info","txtUrl").getElement().show()};if(K&&K.getName()=="img"&&T&&(T.indexOf(I)!==-1)){var S=K.getAttribute("data-tempid"),E=K.getAttribute("data-attachmentid"),M=S||E,R=false;if(!M){var Q=/(\?|&)filedataid=(\d+)/,L=Q.exec(T),D=L&&L[2];if(!D){Q=/(\?|&)([A-Za-z]*id)=(\d+)/;L=Q.exec(T);if(L){vBulletin.AJAX({async:false,url:vBulletin.getAjaxBaseurl()+"/uploader/fetchfiledataid",data:{idname:L[2],id:L[3]},success:function(U){if(U.filedataid){D=U.filedataid}},})}}M=D&&vBulletin.ckeditor.generateTempAttachmentId(D);R=D&&true}if(M){N.hidePage("Upload");for(var J=0;J<vBulletin.ckeditor.imageSettings.length;J++){imgSettingElement=N.getContentElement("info",vBulletin.ckeditor.imageSettings[J]);if(imgSettingElement){imgSettingElement.getElement().show()}}N.getContentElement("info","remote").getElement().hide();N.getContentElement("info","txtUrl").getElement().hide();for(var J=0;J<vBulletin.ckeditor.imageSettings.length;J++){cleanId=vBulletin.ckeditor.imageSettings[J].substring(3).toLowerCase();attributeName="data-"+cleanId;fieldValue=K.getAttribute(attributeName);if(fieldValue){N.getContentElement("info",vBulletin.ckeditor.imageSettings[J]).setValue(fieldValue)}}var G=N.on("ok",function(){var U=$("#"+C).closest("form"),Z={},W=false;for(var V=0;V<vBulletin.ckeditor.imageSettings.length;V++){fieldElement=N.getContentElement("info",vBulletin.ckeditor.imageSettings[V]);fieldValue=fieldElement&&fieldElement.isEnabled()&&fieldElement.getValue();cleanId=vBulletin.ckeditor.imageSettings[V].substring(3).toLowerCase();attributeName="data-"+cleanId;hiddenInputName="setting["+M+"]["+cleanId+"]";if(fieldValue){K.setAttribute(attributeName,fieldValue);if(E){Z[cleanId]=fieldValue}else{$('input[type="hidden"][name="'+hiddenInputName+'"]').remove();$parent=U.find('input[name="filedataids['+M+']"]').parent();if(!$parent||$parent.length==0){$parent=U}$parent.append($("<input />").attr({type:"hidden",name:hiddenInputName}).val(fieldValue));W=true}}else{K.removeAttribute(attributeName);if(E){}else{$('input[type="hidden"][name="'+hiddenInputName+'"]').remove()}}switch(cleanId){case"size":newImgSrc=T.replace(/&type=[A-Za-z]+/,"")+"&type="+fieldValue;K.setAttribute("src",newImgSrc);break;case"alignment":K.removeClass("align_left");K.removeClass("align_center");K.removeClass("align_right");if(fieldValue!=="none"){K.addClass("align_"+fieldValue)}break;case"title":break;default:break}}if(W&&R){vBulletin.ckeditor.insertImageAttachment(C,D,"",M);var X=/(\?|&)[A-Za-z]*id=\d+/,Y=X.exec(T);K.setAttribute("src",K.getAttribute("src").replace(Y[0],"?filedataid="+D));if(K.getAttribute("data-cke-saved-src")){K.setAttribute("data-cke-saved-src",K.getAttribute("data-cke-saved-src").replace(Y[0],"?filedataid="+D))}K.setAttribute("data-tempid",M);K.setAttribute("data-tempid",M);K.addClass("bbcode-attachment")}if(E){Z.attachmentid=E;vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/uploader/saveattachmentsetting",data:Z,success:function(a){if(a.success){console.log("/uploader/saveattachmentsetting Success!")}else{}},})}});N.on("hide",function(){G.removeListener()})}else{showDefaultImageBits()}}else{showDefaultImageBits()}N.on("selectPage",function(V){var U=V.data.page;switch(U){case"Upload":var W=$(N.getElement().$).find("iframe.cke_dialog_ui_input_file").contents().find("form");if(W.find('input[name="securitytoken"]').length){W.find('input[name="securitytoken"]').val(pageData.securitytoken)}else{W.append('<input type="hidden" name="securitytoken" value="'+pageData.securitytoken+'" />')}break}});break;default:}})};vBulletin.ckeditor.killImageFloat=function(C,A){var B=vBulletin.ckeditor.getEditor(C);var D=B.getCommand("justifyright");$.each(D._.events.exec.listeners,function(E,F){D.removeListener("exec",F.fn)});$.each(D._.events.refresh.listeners,function(E,F){D.removeListener("refresh",F.fn)});var D=B.getCommand("justifyleft");$.each(D._.events.exec.listeners,function(E,F){D.removeListener("exec",F.fn)});$.each(D._.events.refresh.listeners,function(E,F){D.removeListener("refresh",F.fn)});var D=B.getCommand("justifycenter");$.each(D._.events.refresh.listeners,function(E,F){D.removeListener("refresh",F.fn)})};vBulletin.ckeditor.modifyMagicline=function(B,A){try{A.plugins.magicline.backdoor.that.triggers.h3=1;console.log("Ckeditor: Added h3 to ckeditor magicline triggers.")}catch(C){console.warn("Ckeditor: Unable to add h3 to ckeditor magicline triggers. Error: {0}".format(C))}};vBulletin.ckeditor.verifyEditorCss=function(C,B,F,G,H,J){var E=function(L){if(L&&L.document&&L.document.$&&L.document.$.defaultView&&L.document.$.defaultView.frameElement){return L.document.$.defaultView.frameElement.contentDocument||L.document.$.defaultView.frameElement.contentWindow.document}return false},K=function(S,O){if(!S){return -1}var N,M,R,Q=false,L=function(T){return(T+"").replace(/&amp;/g,"&")};for(N=0;N<S.styleSheets.length;++N){try{if(L(S.styleSheets[N].href)==L(pageData.ckeditorCss)){Q=true}R=S.styleSheets[N].cssRules;for(M=0;M<R.length;++M){if(R[M].selectorText==O){return 1}}}catch(P){}}return Q?0:-1},A=E(B),D=function(){++I;if(F>0&&K(A,H)==0){--F;window.setTimeout(D,G)}else{J.apply(B,[C,B]);console.log("Ckeditor: Init: verifyEditorCss: checkCss called {0} times".format(I))}},I=0;D()};vBulletin.ckeditor.initSmilies=function(B,A){A.on("mode",function(C){if(C.editor.mode=="source"){$("#"+B).closest(".js-content-entry").find(".js-smilie-container .js-smilie-button").addClass("b-smilie__button--disabled")}else{$("#"+B).closest(".js-content-entry").find(".js-smilie-container .js-smilie-button").removeClass("b-smilie__button--disabled")}})};vBulletin.ckeditor.initHandleEditorFocus=function(B,A){A.on("focus",function(G){var C=$("#"+B).closest(".js-content-entry"),E=C.find(".js-human-verification"),D=E.find(".imagereg");C.find(".js-button-group").removeClass("h-hide");E.removeClass("h-hide");if(D.height()!=D.attr("height")){E.find(".refresh_imagereg").click()}var F=$.cookie(pageData.cookie_prefix+"showcketoolbar");if(F!="null"){var H=F==1?true:false;if(H){vBulletin.ckeditor.toggleToolbar($("#"+B),H)}}})};vBulletin.ckeditor.initHandleEditorBlur=function(B,A){A.on("blur",function(C){(function(){var D=$("#"+B).closest(".js-content-entry"),E=vBulletin.ckeditor.getEditorContent(B);vBulletin.contentEntryBox.populateMetaDescription(E,D)})()})};vBulletin.ckeditor.isEditorEmpty=function(A){var B=vBulletin.ckeditor.getEditorContent(A);if(B===false||B===""){return true}return vBulletin.ckeditor._isEmptyData(B)};vBulletin.ckeditor.resetEditor=function(B){B=vBulletin.ckeditor.verifyEditorId(B);var A=vBulletin.ckeditor.getEditor(B);if(!A){return false}A.setData("")};vBulletin.ckeditor.maintainContent=function(B,A){};vBulletin.ckeditor.convertToAdvancedEditor=function(A){};vBulletin.ckeditor.convertToBasicEditor=function(A){};vBulletin.ckeditor.toggleAdvancedAndBasicEditor=function(B,A){};vBulletin.ckeditor.toggleToolbar=function(C,D,B){var E=$(C);if(typeof D=="undefined"){E.closest(".b-editor").toggleClass("b-editor--cke-toolbar-is-hidden")}else{E.closest(".b-editor").toggleClass("b-editor--cke-toolbar-is-hidden",!D)}var A=!E.closest(".b-editor").hasClass("b-editor--cke-toolbar-is-hidden");E.closest(".js-content-entry").find(".js-toolbar-secondary .b-toolbar__item").filter(function(){return($(this).data("panel")=="b-content-entry-panel__content--toggle-editor")}).toggleClass("b-toolbar__item--active",A);if(!B){$.cookie(pageData.cookie_prefix+"showcketoolbar",(A?1:0),{path:pageData.cookie_path,domain:pageData.cookie_domain,expires:365})}};vBulletin.ckeditor.doInitEditor=function(A,J){if(CKEDITOR.env.mobile&&!CKEDITOR.env.isCompatible){console.log("Ckeditor: Not supported on this mobile device");vBulletin.ckeditor.hideLoadingDialog(A);return }console.log("Ckeditor: Initializing editor: {0}".format(A));var F=$("#"+A);F.trigger("beforeInit",[A]);if(vBulletin.ckeditor.editorExists(A)){console.log("The editor ({0}) already exists.".format(A));return }if(F.is(":visible")&&F.val()==""){F.val(" ")}var D=F.data("disable-features");if(D){if(D=="all"){console.log("Ckeditor: Disabling features: All");vBulletin.ckeditor.config.toolbar=[]}else{D=D.split(",");var C=CKEDITOR.config["toolbar_"+vBulletin.ckeditor.config.toolbar];var I,E,B,G;for(E=0;E<C.length;E++){for(B=0;B<C[E].length;B++){I=C[E][B];if(I.length==0||I=="-"||!CK2BB[I]){continue}if(jQuery.inArray(CK2BB[I],D)>=0){console.log("Ckeditor: Disabling feature: "+I);delete CKEDITOR.config["toolbar_"+vBulletin.ckeditor.config.toolbar][E][B]}}}}}var H=(typeof J.showToolbar=="undefined"?false:J.showToolbar);vBulletin.ckeditor.toggleToolbar(F,H,true);F.ckeditor(function(){vBulletin.ckeditor.hideLoadingDialog(A);vBulletin.ckeditor.instances[A]=this;vBulletin.ckeditor.initPlaceholder(A,this);vBulletin.ckeditor.initHandleEditorFocus(A,this);vBulletin.ckeditor.initHandleEditorBlur(A,this);vBulletin.ckeditor.initFocus(A,this);vBulletin.ckeditor.initToolbarCloseButton(A,this);vBulletin.ckeditor.initSmilies(A,this);vBulletin.ckeditor.killImageFloat(A,this);vBulletin.ckeditor.modifyDialogs(A,this);vBulletin.ckeditor.modifyMagicline(A,this);console.log("Ckeditor: Editor initialized: {0}".format(A));if(F.closest("form").length>0){F.closest("form").attr("ck-editorid",A);console.log('Ckeditor: Added editorId "'+A+'" to form')}this.on("afterSetData",function(K){vBulletin.ckeditor.initPlaceholder(A,this)});vBulletin.ckeditor.verifyEditorCss(A,this,5,50,"hr.previewbreak",function(L,K){F.trigger("afterInit",[L]);vBulletin.ckeditor.fireCallbacks(L,J,"success",this)})},vBulletin.ckeditor.config)};vBulletin.ckeditor.editorExists=function(A){A=vBulletin.ckeditor.verifyEditorId(A);return(typeof vBulletin.ckeditor.instances[A]!="undefined"&&vBulletin.ckeditor.instances[A])};vBulletin.ckeditor.getEditor=function(A){A=vBulletin.ckeditor.verifyEditorId(A);return vBulletin.ckeditor.editorExists(A)?vBulletin.ckeditor.instances[A]:null};vBulletin.ckeditor.closeFileDialog=function(E,J){var G=vBulletin.ckeditor.getEditor(E);if(G){var H=CKEDITOR.dialog.getCurrent();if(H.getName()=="image"){for(var F=0;F<J.length;F++){var C=J[F]["url"],A=J[F]["filedataid"],B=J[F]["name"],I=vBulletin.ckeditor.generateTempAttachmentId(A);if(A&&C){var D=CKEDITOR.dom.element.createFromHtml('<img class="bbcode-attachment" src="'+C+'" data-tempid="'+I+'" />');if(B){D.setAttribute("data-title",B)}G.insertElement(D);vBulletin.ckeditor.insertImageAttachment(E,A,B,I)}}H.hide()}}};vBulletin.ckeditor.insertImageAttachment=function(C,D,E,A){var B=$("#"+C).closest("form");E=E||"";A=A||"";filedataObj={filedataid:D,filename:E,imagesize:"full"};vBulletin.contentEntryBox.addAttachmentItemPanel(B,A,filedataObj)};vBulletin.ckeditor.destroyEditor=function(A){console.log("Ckeditor: Destroying editor: {0}".format(A));A=vBulletin.ckeditor.verifyEditorId(A);if(vBulletin.ckeditor.editorExists(A)){try{vBulletin.ckeditor.getEditor(A).destroy()}catch(B){}vBulletin.ckeditor.instances[A]=null;vBulletin.ckeditor.toggleToolbar($("#"+A),false);return true}else{console.warn("Ckeditor: Not destroyed, because editor {0} does not exist.".format(A))}return false};vBulletin.ckeditor.generateTempAttachmentId=function(C){var B=Math.floor(Math.random()*1000),A=(new Date()).getTime();return"temp_"+C+"_"+A+"_"+B};vBulletin.ckeditor.swapLanguage=function(A){A.editor.on("langLoaded",function(D){var C=($("#debug-information").length==1);CKEDITOR.vBulletin=CKEDITOR.vBulletin||{};if(typeof (CKEDITOR.vBulletin.langInit)=="undefined"&&typeof (window.vBulletin.ckeditorPhrases)!="undefined"){CKEDITOR.vBulletin.langInit=true;if(C){var E={};function B(G,F){F=F||"";$.each(G,function(H,I){if(typeof I=="object"){B(G[H],H+".")}else{G[H]="~~"+I+"~~ ("+F+H+")";E[F+H]=0}})}B(CKEDITOR.lang.en)}$.each(window.vBulletin.ckeditorPhrases,function(G,F){var I=CKEDITOR.lang.en;var H=G.split(".");for(var J=0;J<H.length;J++){if(J==(H.length-1)){if(C){if(typeof I[H[J]]!="undefined"){E[G]=1}else{E[G]=-1}}if(F===null){I[H[J]]="Undefined: "+G}else{I[H[J]]=F}}else{if(typeof (I[H[J]])!="object"||I[H[J]]===null){I[H[J]]={}}I=I[H[J]]}}});CKEDITOR.lang.en.dir=pageData.textdirection;if(C){}}else{if(typeof (window.vBulletin.ckeditorPhrases)=="undefined"&&C){console.warn("Ckeditor phrases not loaded.")}}});CKEDITOR.removeListener("instanceCreated",vBulletin.ckeditor.swapLanguage)};vBulletin.ckeditor.fixMobileDisplay=function(B){var A=B.editor;if(CKEDITOR.env.ie){try{document.execCommand("AutoUrlDetect",false,false)}catch(D){}}var C=$("#cke_contents_"+A.name).children().filter(function(){return this.tagName=="IFRAME"?true:false});if(parseInt(A.config.width)<310){C.hide();C.show()}if("ontouchstart" in document.documentElement){C.get(0).contentWindow.scrollTo(0,10)}A.dataProcessor.dataFilter.addRules({elements:{img:function(H){if(H.attributes["class"]&&H.attributes["class"].indexOf("js-need-data-att-update")!==-1){var E=H.attributes["data-tempid"],F=$("#"+A.element.getId()).closest("form");if(E&&F){for(var G=0;G<vBulletin.ckeditor.imageSettings.length;G++){cleanId=vBulletin.ckeditor.imageSettings[G].substring(3).toLowerCase();inputName="setting["+E+"]["+cleanId+"]";$inputElement=F.find('input[name="'+inputName+'"]');inputValue=$inputElement&&$inputElement.is(":enabled")&&$inputElement.val();if(inputValue){H.attributes["data-"+cleanId]=inputValue;switch(cleanId){case"size":newImgSrc=H.attributes.src.replace(/&type=[A-Za-z]+/,"")+"&type="+inputValue;H.attributes.src=newImgSrc;break;case"alignment":H.attributes["class"]=H.attributes["class"].replace("align_left","").replace("align_center","").replace("align_right","");if(inputValue!=="none"){H.attributes["class"]=H.attributes["class"]+" align_"+inputValue}break;case"title":break;default:break}}}}H.attributes["class"]=H.attributes["class"].replace("js-need-data-att-update","")}}}})};vBulletin.ckeditor.fixIeEditorClick=function(B){var A=B.editor||false;if(A&&A.container&&A.container.$){$(".cke_wysiwyg_frame",A.container.$).contents().on("click",function(C){A.focus()})}};vBulletin.ckeditor.fixTableFunctionality=function(D,E){var C=E||D.editor;$("#"+C.id+"_top .cke_button__table").hide();var B=C.editable();if(B.hasListeners("contextmenu")){var A=(B.getPrivate&&B.getPrivate())||B._||{};if(typeof A.events.contextmenu.listeners=="object"){A.events.contextmenu.listeners={}}}};vBulletin.ckeditor.initUsernameAutosuggest=function(L){var I=0;var P=300;var H={};var O=[];var A=false;function R(S){if(S&&S.data&&S.data.keyCode){switch(S.data.keyCode){case 27:case 13:case 38:case 40:if(I){window.clearTimeout(I);I=0}return E(S);break}}if(I){return }I=window.setTimeout(function(){E(S)},P)}function E(T){var S=N(T.editor);var U=C(T,S);if(A&&!S){A=false}I=0;return U}function C(S,Z){if(!S||!S.data||!S.data.keyCode){return true}var b=S.data.keyCode;if([13,27,38,40].indexOf(b)==-1){return true}var U=vBulletin.ckeditor.verifyEditorId(S.editor);var a=$("#"+U).closest(".js-content-entry");var c=$(".ui-autocomplete",a);if(!c.is(":visible")){return true}var X=$(".js-contententry-username-autosuggest",a);function d(e){c.find(".ui-menu-item a").removeClass("ui-state-hover").prop("id","");e.addClass("ui-state-hover").prop("id","ui-active-menuitem")}switch(b){case 27:A=true;X.val("").trigger("keydown");break;case 13:var Y=c.find(".ui-menu-item a.ui-state-hover");if(Y.length==1){var T={};var W={item:{value:Y.text()}};B.apply(X.get(0),[T,W])}break;case 38:case 40:var Y=c.find(".ui-menu-item a.ui-state-hover");if(Y.length==1){if(b==38){var V=Y.closest(".ui-menu-item").prev(".ui-menu-item").find("a")}else{var V=Y.closest(".ui-menu-item").next(".ui-menu-item").find("a")}if(V.length==1){d(V)}}else{d(c.find(".ui-menu-item a").first())}break}S.cancel();S.stop();return false}function N(T){var W=K(T);if(W&&W.username!=""&&W.username.length>=3&&W.username.length<=vBulletin.options.get("maxuserlength")){F(T,W.username,W.startNode);return true}else{var S=vBulletin.ckeditor.verifyEditorId(T);var U=$("#"+S).closest(".js-content-entry");var V=$(".js-contententry-username-autosuggest",U);V.val("");V.trigger("keydown");return false}}function K(c){var b=c.getSelection().getRanges()[0];b.collapse(true);b.setStartAt(c.editable(),CKEDITOR.POSITION_AFTER_START);var U=b.endOffset;var S=new CKEDITOR.dom.walker(b);var d=0;var X=S.previous();--d;var V=X;if(!X){return false}var h=X.getText();var f=h.lastIndexOf("@");if(f==-1){while(true){var T=S.previous();--d;if(T&&T.type==CKEDITOR.NODE_TEXT){var e=T.getText();var i=e.lastIndexOf("@");h=e+h;f=i;U+=e.length;if(f!=-1){V=T;break}}else{break}}}if(f==-1){return false}if(f==h.length-1){return false}if(f==0){var T=S.previous();--d;if(T){var W=T.getText();if(W!=""&&!(/\s$/.test(W))){return false}if(T&&T.$&&T.$.tagName&&T.$.tagName.toUpperCase){var a=T.$.tagName.toUpperCase();if(a!="BR"&&a!="HR"){return false}}}}if(f>0){if(!(/\s/.test(h.substr(f-1,1)))){return }}while(d<0){S.next();++d}while(1){var Y=S.next();if(Y&&Y.type==CKEDITOR.NODE_TEXT){var g=Y.getText();if(g!=""){h+=g;U+=g.length}}else{break}}var Z=h.substr(f+1);Z=Z.substr(0,U-f-1);Z=$.trim(Z);return{username:Z,startNode:V}}function F(V,W,b){G("showUsernameAutosuggest()");var g=vBulletin.ckeditor.verifyEditorId(V);var c=$("#"+g).closest(".js-content-entry");var U=$(".js-contententry-username-autosuggest",c);if(A){U.val("");U.trigger("keydown");return }var S=c.find(".cke_wysiwyg_frame").offset();var a=c.offset();var Z=b.getParent();var d=Z.getDocumentPosition();var i=Z.getHtml();var T=b.getText();function X(k){return k.replace(/&nbsp;/g," ").replace((new RegExp("\u00A0","g"))," ")}i=X(i);T=X(T);var e=T.lastIndexOf("@");if(T.substr(e+1).length<W.length){T=T.substr(0,e+1)+W}var Y=T.substr(0,e)+'<span id="vb-get-pos">x</span>'+T.substr(e);var j=i.replace(T,Y);$("<div />").attr("id","vb-temp-position-el").css({position:"absolute",top:(S.top-a.top+d.y),left:(S.left-a.left+d.x),border:"1px solid red",background:"#CCC",zIndex:"999"}).html(j).appendTo(c);var h=$("#vb-get-pos",c).offset();var f=$("#vb-get-pos",c).outerHeight();$("#vb-temp-position-el",c).remove();U.css({top:(h.top-a.top+f),left:(h.left-a.left)});U.val(W);U.trigger("keydown");U.data("node",b)}function J(T){var S=vBulletin.ckeditor.verifyEditorId(T.editor.name);var U=$("#"+S).closest(".js-content-entry");var V=$(".js-contententry-username-autosuggest",U);V.val("");V.trigger("keydown")}function D(S,X){var T=false;$.each(O,function(Y,Z){if(S.term.indexOf(Z)==0){T=true;return false}});if(T){$(this.element).val("").trigger("keydown");return }var V=$(this.element);var U=V.closest(".js-content-entry");function W(Y){X(Y);window.setTimeout(function(){var a=$(".ui-autocomplete",U);a.css("zIndex","2");function Z(){var d=a.find(".ui-menu-item a.ui-state-hover").length;if(d>0){return }var c=a.find(".ui-menu-item a").first();c.addClass("ui-state-hover").prop("id","ui-active-menuitem")}function b(){var d=a.find(".ui-menu-item a.ui-state-hover").length;var c=a.find(".ui-menu-item a").first();if(d==1&&c.hasClass("ui-state-hover")){return }c.removeClass("ui-state-hover").prop("id","")}Z();a.find(".ui-menu-item a").on("mouseout",function(){Z()}).on("mouseover",function(){b()})},10)}if(typeof H[S.term]!="undefined"){W(H[S.term])}else{vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/user/getAutocomplete",data:({searchStr:S.term}),success:function(Z){if(Z&&$.isArray(Z.suggestions)){var Y=[];$.each(Z.suggestions,function(a,b){Y.push({label:b.title,value:b.value})});if(Y.length>0){W(Y);H[S.term]=Y}else{O.push(S.term);V.val("").trigger("keydown")}}},error_phrase:"error_getting_suggestions"})}}function B(a,b){var c=$(this);var d=c.closest(".js-content-entry");var U=d.find(".js-editor").attr("id");var Y=vBulletin.ckeditor.getEditor(U);var X=c.data("node").getParent();var f=X.getHtml();var W="@"+c.val();var S=f.lastIndexOf(W);var V=f.substr(0,S);var T=f.substr(S+W.length).replace(/<br>$/i,"");var Z=T.match(/(&nbsp;| )$/);if(Z){T=T.replace(/(&nbsp;| )$/,"")}X.setText("");Y.insertHtml(V);Y.insertHtml('<a href="#" class="b-bbcode-user js-bbcode-user">'+b.item.value+"</a>&nbsp;");Y.insertHtml(T);I=0;c.val("").trigger("keydown")}function Q(S){I=0}function G(T,S){console.log("Ckeditor: Username autosuggest: "+T);if(typeof S!="undefined"){console.dir(S)}}function M(T){G("init() start");if(!T){G("Editor instance in empty");return }T.on("key",R,null,null,1);T.on("contentDom",function(){this.document.on("click",function(W){N(T)})});T.on("blur",J);var S=vBulletin.ckeditor.verifyEditorId(T);var U=$("#"+S).closest(".js-content-entry").css("position","relative");var V=$('<input type="text" class="js-contententry-username-autosuggest" style="position:absolute;top:0px;left:0px;visibility:hidden;width:1px;height:1px;" />');V.appendTo(U).autocomplete({appendTo:U,delay:0,minLength:3,source:D,select:B,close:Q});G("init() finish")}M(L.editor)};vBulletin.ckeditor.modifyCkeditorDialogs=function(C){var D=C.data.name,B=C.data.definition;switch(D){case"table":case"tableProperties":var A=B.getContents("info");A.remove("txtCaption");A.remove("txtSummary");A.remove("selHeaders");A.remove("txtCellSpace");delete B.contents[0].elements[1];delete B.contents[0].elements[2];B.minHeight=200;delete B.contents[1];break;default:break}};CKEDITOR.on("instanceCreated",vBulletin.ckeditor.swapLanguage);CKEDITOR.on("instanceReady",vBulletin.ckeditor.fixMobileDisplay);CKEDITOR.on("instanceReady",vBulletin.ckeditor.fixIeEditorClick);CKEDITOR.on("instanceReady",vBulletin.ckeditor.fixTableFunctionality);CKEDITOR.on("instanceReady",vBulletin.ckeditor.initUsernameAutosuggest);CKEDITOR.on("dialogDefinition",vBulletin.ckeditor.modifyCkeditorDialogs);