/*=======================================================================*\
|| ###################################################################### ||
|| # vBulletin 5.5.2
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2019 MH Sub I, LLC dba vBulletin. 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=$.merge(window.vBulletin.phrase.precache,["all_changes_made_will_be_lost_would_you_like_to_continue","attach_video","close_preview","enter_link_title","enter_photo_gallery_title","enter_poll_question","enter_title","error_x_while_saving_content","event_invalid_enddate","follow","following","following_pending","html_off","html_on","invalid_user_filedata","loading","max_attachments_reached","no_photos_or_albums","no_post_content_to_preview","please_enter_message_x_chars","please_enter_video_url","preview","preview_map","saving","select_from_photo_album","unexpected_error","write_something_here","write_something_here_optional","x_selected","your_post_is_now_being_reviewed_and_waiting_for_moderators_approval"]);window.vBulletin.options=window.vBulletin.options||{};window.vBulletin.options.precache=window.vBulletin.options.precache||[];window.vBulletin.options.precache=$.merge(window.vBulletin.options.precache,["commentminchars","threadpreview"]);window.vBulletin.contentEntryBox=window.vBulletin.contentEntryBox||{};vBulletin.contentEntryBox.disable_bbcode=false;vBulletin.contentEntryBox.handleButtonPreview=function(J){var M=$(this),P=M.closest("form"),H=P.find('input[name="parentid"]').val(),D=P.find('input[name="channelid"]').val(),C=P.data("content-type")||"",B=P.find(".js-editor").attr("id"),F=vBulletin.ckeditor.getEditorContent(B),L=P.find('.tag-editor-wrapper .tag-list input[name="tags"]').val(),K=P.find('select[name="htmlstate"]').val(),O=vBulletin.contentEntryBox.disable_bbcode,E=(C=="text");if(E&&F==""){vBulletin.error("preview","no_post_content_to_preview");return }var A={parentid:H,channelid:D,pagedata:pageData,conversationtype:C,posttags:L,rawtext:F,isAjaxTemplateRender:true,isAjaxTemplateRenderWithData:true,htmlstate:K,disable_bbcode:O};if(C=="gallery"){var I=[];$('.js-photo-postdata input[name="filedataid[]"]',P).each(function(){I.push(this.value);A["title_"+this.value]=$('.js-photo-postdata input[name="title_'+this.value+'"]',P).val()||""});A.filedataid=I}if(C=="link"){A.link={};A.link["title"]=$(".js-link-title",P).val();A.link["meta"]=$(".js-link-meta",P).val();A.link["url"]=$(".js-link-url",P).val();A.link["url_image"]=$(".js-link-preview-checkbox",P).is(":checked")?0:$(".js-link-url-image:checked",P).val()}if(C=="poll"){A.poll={options:[],mutliple:($('input[name="multiple"]',P).is(":checked")?1:0)};$(".js-poll-option",P).each(function(){A.poll["options"].push(this.value)})}if(C=="video"){A.video={};A.video["title"]=$(".js-link-title",P).val();A.video["meta"]=$(".js-link-meta",P).val();A.video["url"]=$(".js-link-url",P).val();A.video["items"]=[];$(".js-video-url",P).each(function(){A.video["items"].push(this.value)})}if(C=="event"){var G=["eventstartdate","eventenddate","location",],N=["is_all_day","ignoredst",];$.each(G,function(S,R){var Q=$('input[name="'+R+'"]',P);if(Q.length){A[R]=Q.val()}});$.each(N,function(S,R){var Q=$('input[name="'+R+'"]:checked',P);if(Q.length){A[R]=Q.val()}})}M.prop("disabled",true);vBulletin.AJAX({call:"/create-content/load-preview",data:A,success:function(R){var Q=$("<div />").attr("id","preview-overlay").addClass("h-hide").append($("<div />").addClass("dialog-content")).append($("<div />").addClass("b-button-group h-margin-bottom-m")).appendTo("body");$("<ul />").addClass("conversation-list list-container stream-view activity-view h-clearfix b-post--preview").appendTo($(".dialog-content",Q));$("<button />").addClass("js-content-entry-preview-submit b-button b-button--primary").text($(".js-content-entry-submit",P).text()).on("click",function(){P.trigger("submit");Q.dialog("close")}).appendTo($(".b-button-group",Q));$("<button />").addClass("js-content-entry-preview-close b-button").text(vBulletin.phrase.get("close")).on("click",function(){Q.dialog("close")}).appendTo($(".b-button-group",Q));$(R.template).appendTo($("ul",Q));$(".js-post .js-post__content-text",Q).html(R.parsedText);$(".dialog-content a",Q).addClass("h-disabled").on("click",function(){return false});$(".dialog-content .js-button, .dialog-content .b-button, .dialog-content button",Q).prop("disabled",true);Q.removeClass("h-hide").dialog({title:vBulletin.phrase.get("preview"),autoOpen:true,modal:true,resizable:false,closeOnEscape:true,showCloseButton:false,width:800,minHeight:0,dialogClass:"preview-dialog-container dialog-container dialog-box",open:function(){$(".b-button--primary",Q).focus()},close:function(){Q.dialog("destroy").remove()}})},title_phrase:"preview",error_phrase:"error_loading_preview",complete:function(){M.prop("disabled",false)}})};vBulletin.contentEntryBox.handleButtonSaveDraft=function(B){var A=$(this).closest("form");if(A.find('input[name="save_draft"]').length==0){$('<input type="hidden" name="save_draft" value="1" />').appendTo(A)}window.setTimeout(function(){A.find('input[name="save_draft"]').remove()},100)};vBulletin.contentEntryBox.handleButtonLoadNewPosts=function(C){console.log("vBulletin.contentEntryBox.handleButtonLoadNewPosts start");var B=$(this),A=B.closest("form");vBulletin.contentEntryBox.loadNewPosts(A,B)};vBulletin.contentEntryBox.loadNewPosts=function(E,D,G){var M=E.find('input[name="parentid"]').val(),A=E.find('input[name="channelid"]').val(),C=pageData.lastloadtime||pageData.current_server_datetime,L=0,Q=pageData.past_page_limit||false;var N=E.closest(".conversation-content-widget");if(N.length==0){N=E.closest("#activities-tab")}var K=$(".conversation-list",N);var I="";if(K.hasClass("thread-view")){I="thread"}else{if(K.hasClass("full-activity-view")){I="full-activity-stream"}else{if(K.hasClass("activity-view")){I="activity-stream"}else{I="stream"}}}var O=$(".list-container",N),P=$(".list-container>li.b-post",N),H=P.length,J=parseInt($('form.toolbar-filter-overlay input[name="pagenum"]').val())||1,R=Number($("form.pagenav-form span.pagetotal").text())||0;var F=[];P.each(function(V,U){var S=$(U).data("node-id");if(S){F.push(S)}var T=$(U).data("node-publishdate");if(T&&T>L){L=T}});console.dir(F);console.dir(L);var B={parentid:M,channelid:A,newreplyid:G,loadednodes:F,lastpublishdate:L,lastloadtime:C,pageload_servertime:pageData.current_server_datetime,view:I,currentpage:J,pagetotal:R,postcount:H,postsperpage:vBulletin.conversation.POSTS_PER_PAGE,commentsperpage:vBulletin.conversation.COMMENTS_PER_PAGE,past_page_limit_aware:Q,};window.vBulletin.loadingIndicator.show();if(D){D.prop("disabled",true)}vBulletin.AJAX({call:"/create-content/loadnewposts",data:B,success:function(X){if(!X||X.error){return }if(X.redirect){document.location.href=X.redirect;return }pageData.lastloadtime=X.timenow;if(X.past_page_limit){pageData.past_page_limit=X.past_page_limit}if(X.template){if(O.length>1){var W=E.closest(".tab");if(W.length>0){O=$(".list-container",W)}else{O=$(".list-container",$(".tab.media-tab"))}}var T=$(X.template);if(O.hasClass("ajax-order-newest-first")&&$("li.list-item:first",O).length>0){$("li.list-item:first",O).before(T)}else{O.append(T);var U=T.closest(".ui-tabs-panel").find(".conversation-toolbar-wrapper");if(U.hasClass("scrolltofixed-floating")){var S=U.data("object-instance");if(S){S.addLimit(T.filter(function(){return(this.nodeType==Node.ELEMENT_NODE)}).outerHeight(true))}}if(G){vBulletin.scrollToAnchor("#post"+G)}}var V=pageData.nodeid;if(V){if(pageData.threadmarking=="0"||pageData.userid=="0"){vBulletin.cookie.setBbarrayCookie("discussion_view",V,Math.round(new Date().getTime()/1000))}}$(document).trigger("vb-loadnewposts",{insertedHtml:T})}},complete:function(){if(D){D.prop("disabled",false)}window.vBulletin.loadingIndicator.hide()}})};vBulletin.contentEntryBox.handleButtonDelete=function(D){var F=$(this),H=$(this.form).data("content-type"),G=H,E=F.closest(".js-content-entry"),A=F.closest(".js-post"),C=A.data("node-id");if(!C){C=A.data("nodeid")}if(H!="comment"&&H!="media"){if(F.closest('.js-post__content-wrapper[data-node-type="visitorMessage"]').length==1){H="visitorMessage"}else{if(F.closest('.list-item-body-wrapper[data-node-type="visitorMessage"]').length==1){H="visitorMessage"}else{if(F.closest(".js-conversation-starter").length==1){H=F.closest(".conversation-list.blog-list").length==1?"blog":"topic";H=F.closest(".conversation-list.article-list").length==1?"article":"topic"}else{H="reply"}}}}var B=vBulletin.phrase.get("delete_x",vBulletin.phrase.get("posttype_"+H));$deleteDialog=openConfirmDialog({title:B,message:vBulletin.phrase.get("loading")+"...",width:500,dialogClass:"delete-post-dialog dialog-container dialog-box loading",buttonLabel:{yesLabel:B,noLabel:vBulletin.phrase.get("cancel")},onClickYes:function(){var M=E.find("form"),L=vBulletin.triggerHandler.apply(M.get(0),["beforeDelete"]);if(L===false){return }var K=$deleteDialog.find(".delete-posts-form");var J=K.find("input:radio[name=deletetype]:checked").val()||1;var I={hard:(J==2?1:0),reason:K.find(":input[name=deletereason]").val(),nodeids:C};vBulletin.AJAX({url:vBulletin.normalizeAjaxUrl(K.attr("action")),data:I,error_phrase:"error_deleting_posts",success:function(N){$(window).off("beforeunload.editPost");$("body").trigger(G+"_editform_onunload",[E]);if(J==2){if(H=="topic"||H=="blog"){location.replace($("#breadcrumbs .crumb a:last").attr("href")||pageData.baseurl)}else{$('.js-post[data-node-id="'+C+'"]').remove()}}else{var O=$(".filter-wrapper",F.closest(".conversation-view, .ui-tabs-panel, .widget-content").find(".conversation-toolbar")).data("object-instance");if(O&&typeof O.applyFilters=="function"){O.forceApplyFilters()}else{if(H=="visitorMessage"){window.history.back()}else{location.reload()}}}M.trigger("afterDelete")}})}});vBulletin.AJAX({call:"/ajax/render/delete_post_form",data:{postType:H,nodeid:C,authorid:F.data("userid")},title_phrase:"error",error_phrase:"error_loading_delete_form",success:function(I){$deleteDialog.removeClass("loading").find(".dialog-content .message").html(I).find("[placeholder]").placeholder().end().end().dialog("option","position",{of:window})}})};vBulletin.contentEntryBox.handleButtonCancel=function(D,B){var I=this,C=I.form,E,F=$(I).closest(".edit-conversation-container");if(!B){E=vBulletin.triggerHandler.apply(C,["beforeCancel"]);if(E===false){return false}}if(F.length==1){if(!B){return vBulletin.contentEntryBox.openConfirmRemoveContentDialog(function(){var J=vBulletin.triggerHandler.apply(C,["beforeCancel"]);if(J!==false){$(I).trigger("click",[true])}},"cancel_edit")}var G=$(C).data("content-type");var H=(G=="comment")?$(I).closest(".js-comment"):$(I).closest(".js-post__content-wrapper");if(H.length==0){H=$(I).closest(".js-post__content-wrapper")}H.removeClass("b-post--edit");H.find(".b-post__content--edit").removeClass("b-post__content--edit");H.find(".b-post__footer--edit").removeClass("b-post__footer--edit");$(window).off("beforeunload.editPost");$(C).trigger("afterCancel");$("body").trigger(G+"_editform_onunload",[H]);F.empty().hide()}else{if($(I).closest(".sb-dialog").length==1){vBulletin.contentEntryBox.resetForm($(C),true,function(){$(I).closest(".sb-dialog").dialog("close")})}else{if($(this.form).data("message-type")=="vm"||$(this.form).data("message-type")=="pm-reply"||$(this.form).data("message-type")=="reply"){vBulletin.contentEntryBox.resetForm($(this.form),true)}else{var A="";if(this.form.ret&&this.form.ret.value){A=this.form.ret.value}else{if($(this.form).data("message-type")=="pm-new"){A=pageData.baseurl+"/privatemessage/index"}else{if($(this.form).data("message-type")=="pm-forward"){A=pageData.baseurl+"/privatemessage/index"}else{if(this.form.parentid&&this.form.parentid.value){A=pageData.baseurl+"/node/"+this.form.parentid.value}else{A=pageData.baseurl}}}}if(!vBulletin.contentEntryBox.isEmpty($(this.form).closest(".js-content-entry"))){vBulletin.contentEntryBox.openConfirmRemoveContentDialog(function(){document.location.href=A})}else{document.location.href=A}}}}$(C).trigger("afterCancel")};vBulletin.contentEntryBox.validateForm=function(){var N=$(this),I,L=window.vBulletin.options.get("commentminchars"),D=$(".js-editor",N),E=D.attr("id"),F=$.trim(D.val()),M=(N.closest(".js-comments").length>0)?true:false,J=N.data("content-type"),G=vBulletin.contentEntryBox.ATTACHLIMIT||0,K=$(".b-content-entry-panel__content--"+J,N);if(J=="video"&&K.length==0){K=$(".b-content-entry-panel__content--link",N)}var B=function(O){return function(){setTimeout(function(){O.focus()},10)}};if(J=="comment"||M){if(F.length<L){vBulletin.warning("error",["please_enter_message_x_chars",L],B(D));return false}return true}if($(".js-content-entry-title",N).is(":visible")&&$.trim($(".js-content-entry-title",N).val())==""){vBulletin.warning("error","please_enter_title_of_topic",B($(".js-content-entry-title",N)));return false}if(J=="gallery"){if($(".js-photo-postdata input",K).length==0){vBulletin.warning("error","please_upload_at_least_one_photo");return false}if(G>0&&$('.js-photo-postdata input[name^="filedataid"]',K).length>G){vBulletin.warning("error",["you_may_only_attach_x_files_per_post",G]);return false}}if((J=="link"||J=="video")&&!$.trim(K.find(".js-panel-content").html())){vBulletin.warning("error","please_enter_a_valid_url_and_click_attach",B($(".b-link-input__url",K)));return false}if(J=="poll"){var A=0,C=2,H;$(".js-poll-option:visible",N).each(function(){if($.trim($(this).val())!=""){A++}else{if(!H){H=$(this)}}if(A>=C){return false}});if(A<C){vBulletin.warning("error",["please_enter_at_least_x_poll_answers",C],B(H));return false}}return true};vBulletin.contentEntryBox.callbackSubmitSuccess=function(F,C,O,P){console.log("vBulletin.contentEntryBox.callbackSubmitSuccess");P.closest(".js-dialog-body").dialog("close");var E=P.data("content-type")||"";var A=P.data("current-channeltype")||"";var D=P.attr("ck-editorid")||$(".js-editor",P).attr("id");vBulletin.contentEntryBox.resetForm(P);var H=vBulletin.triggerHandler.apply(P.get(0),["afterSave",$(document),F]);if(H===false){return }var K=pageData,M,B=F.nodeId,N,J,I;N=P.closest(".conversation-content-widget");if(N.length==0){N=P.closest("#activities-tab")}J=$(".conversation-list",N);I=$(".list-container",N);if(P.closest(".private-message-widget").length==1){if(P.closest(".private-message-widget").find(".conversation-list").length==1){document.location.reload()}else{location.href=pageData.baseurl+"/privatemessage/index"}return }if(F.retUrl&&I.length==0){location.href=F.retUrl;return }window.vBulletin.loadingIndicator.show();if(J.hasClass("thread-view")){M="thread"}else{if(J.hasClass("full-activity-view")){M="full-activity-stream"}else{if(J.hasClass("activity-view")){M="activity-stream"}else{M="stream"}}}if(A==="forum"&&M==="thread"){vBulletin.contentEntryBox.loadNewPosts(P,null,F.nodeId);vBulletin.hv.reset();return }var G,L=$(".js-post:not(.js-comment):last .b-post__count:first",J).text()||"1";G=Number(L.replace("#",""));K["posts-perpage"]=vBulletin.conversation.POSTS_PER_PAGE;if(M=="thread"){K["comments-perpage"]=vBulletin.conversation.COMMENTS_PER_PAGE}if(F&&vBulletin.ajaxtools.hasError(F.warnings,"warning_spam_post")){vBulletin.ajaxtools.showApiError(F.warnings,F,{title_phrase:"warning",after_error:function(){if(F.warningReturnUrl){location.href=F.warningReturnUrl}else{window.location.reload(true)}}});return }$.post(vBulletin.getAjaxBaseurl()+"/create-content/loadnode",{nodeid:B,view:M,index:G,page:K,type:E,isAjaxTemplateRender:true,isAjaxTemplateRenderWithData:true},function(U){P.each(function(V,W){$(W).find("textarea").val("")});if(U.error){if(F.moderateNode){$textarea=P.find(".js-editor");if(vBulletin.ckeditor.editorExists($textarea)){vBulletin.ckeditor.getEditor($textarea).setData("")}else{$textarea.val("")}showStatusMessage(vBulletin.phrase.get("your_post_is_now_being_reviewed_and_waiting_for_moderators_approval"),"moderate")}else{openAlertDialog({title:vBulletin.phrase.get("conversation"),message:vBulletin.phrase.get(U.error),iconType:"error"})}}else{var S=$(U.template);if(I.length>1){$tab=P.closest(".tab");if($tab.length>0){I=$(".list-container",$tab)}else{I=$(".list-container",$(".tab.media-tab"))}}if(I.hasClass("ajax-order-newest-first")&&$("li.list-item:first",I).length>0){$("li.list-item:first",I).before(S)}else{I.append(S);var T=S.closest(".ui-tabs-panel").find(".conversation-toolbar-wrapper");if(T.hasClass("scrolltofixed-floating")){var Q=T.data("object-instance");if(Q){Q.addLimit(S.outerHeight(true))}}I.removeClass("h-hide");vBulletin.scrollToAnchor("#post"+B)}if(I.children(".list-item").length>0){I.parent().find(".conversation-empty").addClass("h-hide")}$("body").trigger(E+"_savepost_success",[P]);vBulletin.Responsive.ConversationContent.checkForSignature();var R=$(".js-conversation-starter",N).attr("data-node-id");if(R){if(pageData.threadmarking=="0"||pageData.userid=="0"){vBulletin.cookie.setBbarrayCookie("discussion_view",R,Math.round(new Date().getTime()/1000))}else{vBulletin.markRead(R)}}vBulletin.subscribe.updateSubscribeButton(U.topic_subscribed)}},"json").error(function(S,R,Q){console.warn("Error loading post: {0}".format(Q));openAlertDialog({title:vBulletin.phrase.get("conversation"),message:vBulletin.phrase.get("error_loading_post"),iconType:"error"})}).complete(function(){window.vBulletin.loadingIndicator.hide()});vBulletin.hv.reset()};vBulletin.contentEntryBox.initAjaxFormSubmit=function(){var A=$(".js-content-entry");A.each(function(){var B=$(this);if(B.data("initAjaxFormSubmitDone")||B.closest(".edit-conversation-container").length==1){return }var C=$("form",B);C.each(function(F,E){var D=$(E),G=D.data("content-type");vBulletin.ajaxForm.apply(D,[{success:vBulletin.contentEntryBox.callbackSubmitSuccess,error:function(N,M,I){console.warn("Error when submitting content: {0}, {1}".format(M,I));if(M=="parsererror"){var L=String(N.responseText).split(/\r?\n/g),K=L[L.length-1],H;try{H=$.parseJSON(K)}catch(J){}if(H){vBulletin.contentEntryBox.callbackSubmitSuccess(H,"",N,D);return }}vBulletin.error("error",["error_x_while_saving_content",I])},api_error:vBulletin.hv.resetOnError,complete:function(){console.log("ajaxForm complete (vBulletin.contentEntryBox.initAjaxFormSubmit)");window.vBulletin.loadingIndicator.hide()},beforeSubmit:function(K,J,I){var H=vBulletin.contentEntryBox.validateForm.apply(J,[I]);if(H===false){return false}window.vBulletin.loadingIndicator.show();return true}}])});B.data("initAjaxFormSubmitDone",true)})};vBulletin.contentEntryBox.initVideoEditPane=function(){vBulletin.conversation.bindEditFormEventHandlers("video");$(".b-content-entry .b-content-entry-panel__content--video").each(function(){$this=$(this);if($this.data("initVideoEditPaneDone")){return }$("body").trigger("video_editform_onload",[$this]);$this.data("initVideoEditPaneDone",true)})};vBulletin.contentEntryBox.initAutofillFromTitle=function(A){A.each(function(H,G){var B=$(G),F=B.find(".js-content-entry-title").first(),I=B.find(".js-content-entry-url-alias").first(),D=B.find(".js-content-entry-html-title").first(),J="",E="",C=B.is(".js-content-entry-edit-post");if(C){E=F.val()}$(F).off("keydown keyup").on("keydown keyup",function(O){var N=I.val(),M=D.val();if(!C&&(N==""||J==N)){J=vBulletin.contentEntryBox.generateUrlAlias(F.val());I.val(J)}if(M==""||E==M){E=F.val();D.val(E);if(!D.is(":visible")||!I.is(":visible")){var K=D.closest(".js-collapse__body").data("collapse-id"),L=$('.js-collapse__icon.js-collapse--collapsed[data-collapse-id="'+K+'"]'),P=$('.js-collapse__icon.js-collapse--collapsed[data-collapse-id="collapse_advoptionspanel"]');P.trigger("click");L.trigger("click")}}})})};vBulletin.contentEntryBox.initCollapse=function(){var C=(function(){var H=pageData.cookie_prefix+"collapse";function F(I,L){var J=I.replace(/(^collapse_|_edit$|_new$)/g,""),K=G();K[J]=L?"1":"0";E(K)}function G(){var I=$.cookie(H);if(!I){return{}}var K=I.split("|");var J={};$.each(K,function(M,N){var L=N.split(".");J[L[0]]=L[1]});return J}function E(K){var J=[];$.each(K,function(N,O){var M=N+"."+O;J.push(M)});var I=J.join("|");var L={path:pageData.cookie_path,domain:pageData.cookie_domain,expires:365};$.cookie(H,I,L)}function D(){var J=G(),I={};$.each(J,function(K,L){I["collapse_"+K+"_edit"]=L;I["collapse_"+K+"_new"]=L});$(".js-content-entry .js-collapse__icon").each(function(L,N){var M=$(this),K=M.data("collapse-id");if(typeof I[K]!="undefined"){if((I[K]=="1"&&!M.is(".js-collapse--collapsed"))||(I[K]=="0"&&M.is(".js-collapse--collapsed"))){M.trigger("click")}}})}return{save:F,getAll:G,restoreAll:D}})();function B(M,E,J){var D=M.data("collapse-id"),H=$('.js-collapse__link[data-collapse-id="'+D+'"]'),I=$('.js-collapse__icon[data-collapse-id="'+D+'"]'),F=$('.js-collapse__body[data-collapse-id="'+D+'"]'),L=$().add(I).add(F),G=H.is(".js-collapse--collapsed")||I.is(".js-collapse--collapsed");if(E){G=!G}if(G){F.show();var K=F.find(".js-toggle-slider__dependent.h-hide").removeClass("h-hide");F.find(".js-select-box").selectBox();K.addClass("h-hide");F.hide();F.slideDown("fast");I.removeClass("b-icon__plus-circle").addClass("b-icon__minus-circle");L.removeClass("js-collapse--collapsed")}else{if(!F.is(".b-content-entry-panel__section--lite")){F.slideUp("fast",function(){F.hide()});I.removeClass("b-icon__minus-circle").addClass("b-icon__plus-circle");L.addClass("js-collapse--collapsed")}}if(!E&&J){C.save(D,!G)}}function A(E){var D=!!E.originalEvent;B($(this),false,D)}$(".js-collapse__icon").each(function(D,E){B($(this),true,false)});$(".js-collapse__link").addClass("b-link js-link").off("click").on("click",A);$(".js-collapse__icon").addClass("b-link js-link b-icon").off("click").on("click",A);$(".js-content-entry-edit-post .js-collapse__icon.js-collapse--collapsed").click();setTimeout(function(){C.restoreAll()},0)};vBulletin.contentEntryBox.generateUrlAlias=function(A){return A.replace(/[\s\v\0\x00-\x1F\x7F<>!\*#%{}\|\\^\[\]\(\)<>`;\/\?:@&=+$,\.\"\'|]+/gi,"-").replace(/-+/gi,"-").replace(/^-|-$/gi,"").toLowerCase()};vBulletin.contentEntryBox.populateMetaDescription=function(B,H){var I=H.find(".js-meta-description").first();if(I.length==1){var A=I.val(),J="",F=H.is(".js-content-entry-edit-post"),G=vBulletin.options.get("threadpreview");if(G<=0){G=150}B=$("<div />").html(B).text();B=B.replace(/[\s\v\0]+/g," ").replace(/^ | $/g,"");if(B.length>G+10){B=B.substr(0,G+10);var C=B.length-1,D=B.length>20?20:B.length,K="";while(D>0){K=B.substr(C,1);if(K.match(/[\s\v\0\.\?\n-]/)){B=B.substr(0,(B.length-(B.length-C)));break}--D;--C}}if(F){J=B}if((A==""&&B!="")||(J==A&&A!="")||(A.indexOf(J)===0&&A!="")){prevHtmlTitle=B;I.val(prevHtmlTitle);if(!I.is(":visible")){var E=I.closest(".js-collapse__body");$matches=$(".js-collapse__icon, .js-collapse__body"),thisIndex=$matches.index(E),$icon=$matches.eq(thisIndex-1);$icon.trigger("click")}}}};vBulletin.contentEntryBox.initPhotoGallery=function(){var F=[],B=null,G=null,C=597,A=null,H=function(M){var Q=G.parent();if(!A){A={originalPanelWidth:M.width(),originalDialogWidth:Q.width(),scrollbarWidth:vBulletin.getScrollbarWidth(),originalPanelHeight:M.height(),originalDialogHeight:Q.height()}}function J(a,Z,d){var c=a.first();var b=c.data("css-prop-restore-value_"+Z);if(typeof b=="undefined"){c.data("css-prop-restore-value_"+Z,c.css(Z))}if(typeof d!="undefined"){a.css(Z,d)}}function N(b,a){var Z=b.first().data("css-prop-restore-value_"+a);if(typeof Z!="undefined"){b.css(a,Z)}}function U(a,Z){M.css({width:a});Q.css({width:Z})}var O="margin"+pageData.textDirLeft.charAt(0).toUpperCase()+pageData.textDirLeft.slice(1);J(Q,"height");J(M,"height");J(Q.find(".photoSelectorTabs"),"height");J(Q.find(".js-dialog-body"),"padding");J(Q.find(".photoSelectorTabs ul"),"width");J(Q.find(".photoSelectorTabs ul li"),"width");J(Q.find(".photoSelectorTabs .tabPanel"),"width");J(Q.find(".photo-item-wrapper"),"width");J(Q.find(".js-photo-counter"),O);var T=$(window).width();var L=(A.originalDialogWidth+A.scrollbarWidth>T);var V=A.originalPanelWidth;var X=A.originalDialogWidth;if(L){V-=200;X-=200}U(V,X);var P=(Q.outerWidth()>T);if(!P){N(Q,"height");N(M,"height");N(Q.find(".photoSelectorTabs"),"height");N(Q.find(".js-dialog-body"),"padding");N(Q.find(".photoSelectorTabs ul"),"width");N(Q.find(".photoSelectorTabs ul li"),"width");N(Q.find(".photoSelectorTabs .tabPanel"),"width");N(Q.find(".photo-item-wrapper"),"width");N(Q.find(".js-photo-counter"),O);Q.find(".photo-checkbox input").css(pageData.textDirLeft,"");Q.find(".photo-checkbox input").css(pageData.textDirRight,"5px");Q.find(".js-photo-counter").removeClass("h-margin-top-s")}U(V,X);var S=M.find(".photo-item-wrapper");var R=S.first().outerHeight();var K;if(L){K=S.length;S.addClass("last-in-row")}else{K=Math.ceil(S.length/2);S.filter(":even").removeClass("last-in-row")}var W=K*R;var Y=(A.originalPanelHeight<W);if(Y){V+=A.scrollbarWidth;X+=A.scrollbarWidth;U(V,X)}if(P){Q.css({width:T+"px",left:0,top:0,marginLeft:0,marginTop:0,});J(Q,"height","auto");J(M,"height",W+"px");J(Q.find(".photoSelectorTabs"),"height",W+"px");J(Q.find(".js-dialog-body"),"padding",0);J(Q.find(".photoSelectorTabs ul"),"width","30%");J(Q.find(".photoSelectorTabs ul li"),"width","100%");J(Q.find(".photoSelectorTabs .tabPanel"),"width","70%");J(Q.find(".photo-item-wrapper"),"width","auto");J(Q.find(".js-photo-counter"),O,"12px");Q.find(".photo-checkbox input").css(pageData.textDirRight,"");Q.find(".photo-checkbox input").css(pageData.textDirLeft,"5px");Q.find(".js-photo-counter").addClass("h-margin-top-s")}if($("body").is(".l-xsmall")){J(Q,"height","auto")}},E=function(K){var L=$(".photo-item-wrapper .photo-item .filedataid",K),J=$(".js-photo-counter",K.parent());H(K);L.off("click").on("click",function(O){O.stopPropagation();var P=$(this).data("nodeid"),N=$(this).closest(".photo-item-wrapper");if(this.checked){F.push(P);N.addClass("selected")}else{N.removeClass("selected");var M=$.inArray(P,F);if(M!=-1){F.splice(M,1)}}J.html(vBulletin.phrase.get("x_selected",F.length));$(".js-photo-selector-continue",G).prop("disabled",F.length==0)});$(".photo-item-wrapper",K).off("click").on("click",function(){var M=$(".photo-checkbox .filedataid",this);M.prop("checked",!M.prop("checked")).triggerHandler("click")});if(F.length>0){L.each(function(){if($.inArray($(this).data("nodeid"),F)!=-1){this.checked=true;$(this).closest(".photo-item-wrapper").addClass("selected")}});$(".js-photo-selector-continue",G).prop("disabled",false)}else{L.prop("checked",false);$(".photo-item-wrapper",this).removeClass("selected");$(".js-photo-selector-continue",G).prop("disabled",true)}J.html(vBulletin.phrase.get("x_selected",F.length))},D=function(K,J){var M=2;var L=K.nodes;B=$(".photo-selector-galleries",J);var O=B.find(".photo-selector-tabs");O.empty();B.children(".tabPanel").remove();$.each(L,function(P,S){if(S.nodeid!=-1){var Q=(S.nodeid==-2?0:S.nodeid),R="tab-gallery-"+Q;O.append('<li class="tab-item"><a href="{0}"><span>{1}</span></a></li>'.format("#"+R,S.title));B.append('<div id="{0}" class="tabPanel photo-display h-left"></div>'.format(R))}});var N=function(R,P){var Q=R.substring(R.lastIndexOf("-")+1);if(!$(R).html()){vBulletin.AJAX({call:"/profile/get-photo-tab-content?nodeid="+Q+"&ppr="+M,dataType:"html",success:function(S){$(R).html(S);E($(P))}})}else{H(P)}};G=J.dialog({modal:true,width:C,autoOpen:false,showCloseButton:false,closeOnEscape:true,resizable:false,showTitleBar:true,title:vBulletin.phrase.get("select_from_photo_album"),dialogClass:"js-photo-selector-wrapper photo-selector-wrapper dialog-container dialog-box"});B.tabs({create:function(P,Q){N(Q.panel.selector,Q.panel)},activate:function(P,Q){N(Q.newPanel.selector,Q.newPanel)}});G.addClass("js-no-responsive-resize");G.off("vbulletin:dialogresize").on("vbulletin:dialogresize",function(){var P=G.find(".ui-tabs-panel");H(P)});G.dialog("open")},I=function(){$(document).data("gallery-container",$(this).closest(".b-content-entry-panel__content--gallery"));F=[];var J=$(".js-photo-selector-wrapper .js-photo-selector-container");if(J.length==0){J=$(this).closest(".b-content-entry").find(".js-photo-selector-container")}vBulletin.AJAX({call:"/profile/get-photo-tabs",success:function(K){return D(K,J)}})};$(document).off("click",".js-photo-selector-button").on("click",".js-photo-selector-button",I)};vBulletin.contentEntryBox.resetForm=function(C,B,A){var D=C.closest(".js-content-entry"),E=D.find(".js-editor");if(B&&!vBulletin.contentEntryBox.isEmpty(D)){return vBulletin.contentEntryBox.openConfirmRemoveContentDialog(function(){vBulletin.contentEntryBox.resetForm(C,false,A)})}C.trigger("reset");$(".linkcontainer, .js-photo-postdata, .js-attach-postdata",C).html("");$(".edit-photo-link",C).addClass("h-hide");$(".upload-photo-dialog-container .photo-display-container .photo-display").html("");if(C.attr("default-action")){C.attr("action",C.attr("default-action"))}if(vBulletin.upload&&vBulletin.upload.restoreButtonText){vBulletin.upload.restoreButtonText($(".b-button--upload .js-upload-label",C))}vBulletin.ckeditor.resetEditor(E,function(){D.find(".b-content-entry-panel__content").each(function(F,G){vBulletin.contentEntryBox.resetPanel($(G))});vBulletin.contentEntryBox.afterPanelChange(D);if(E.attr("id")&&vBulletin.ckeditor.editorExists(E.attr("id"))){vBulletin.ckeditor.toggleToolbar(E,false)}D.data("prev-selected-panel","");D.find(".b-toolbar__item").removeClass("b-toolbar__item--active");vBulletin.contentEntryBox.changeFormToSelectedContentType(D.find(".b-toolbar"));D.find(".js-content-entry-title").val("");if(D.find(".js-contententry-buttons").data("hide-buttons-until-click")){D.find(".js-contententry-buttons").addClass("h-hide");D.find(".js-human-verification").addClass("h-hide")}if(vBulletin.conversation&&vBulletin.conversation.replyWithQuotes&&typeof vBulletin.conversation.replyWithQuotes.clickCancelButton=="function"){vBulletin.conversation.replyWithQuotes.clickCancelButton()}vBulletin.contentEntryBox.restoreEditorState(E.attr("id"));if(typeof A=="function"){A.apply(C)}})};vBulletin.contentEntryBox.isPanelEmpty=function(E){if(E.hasClass("b-content-entry-panel__content--gallery")){return !$.trim(E.find(".js-panel-content").html())}else{if(E.hasClass("b-content-entry-panel__content--link")||E.hasClass("b-content-entry-panel__content--video")){return !$.trim(E.find(".js-panel-content").html())&&!E.find(".b-link-input__url").val()}else{if(E.hasClass("b-content-entry-panel__content--poll")){var A=false;$(".b-poll-fieldset .b-form-input__input",E).each(function(){if($(this).val()){A=true;return false}});if(!A){$(".b-poll-fieldset .b-form-control__control",E).each(function(){if(this.defaultChecked!=this.checked){A=true;return false}})}return !A}else{if(E.hasClass("b-content-entry-panel__content--attachment")){return !(E.find(".js-attach-list .js-attach-item").length>1)}else{if(E.hasClass("b-content-entry-panel__content--event")){var A=false;var D=$('input[name="eventstartdate"]',E),B=$(".js-toggle-slider[data-name='is_all_day']",E),C=$('input[name="eventenddate"]',E),F=$("input[name='location']");if(D.length&&D.val()!=D.data("initial-value")){A=true}if(B.length&&B.hasClass("b-toggle-slider--no")){A=true}if(C.length&&C.val()!=C.data("initial-value")){A=true}if(F.length&&F.val()!=""){A=true}return !A}}}}}return true};vBulletin.contentEntryBox.resetPanel=function(F){F.addClass("h-hide");if(F.hasClass("b-content-entry-panel__content--gallery")){F.find(".js-panel-content").empty();F.find(".b-button--upload .js-upload-label").text(vBulletin.phrase.get("upload"));F.find(".b-form-input__file--hidden").prop("disabled",true);F.find(".js-photo-postdata").empty();var B=vBulletin.upload.getUploadedPhotosDlg(false,F);$(".photo-display",B).empty()}else{if(F.hasClass("b-content-entry-panel__content--link")||F.hasClass("b-content-entry-panel__content--video")){F.find(".js-panel-content").empty();F.find(".b-link-input__url").val("").prop("disabled",true).parent().removeClass("h-hide")}else{if(F.hasClass("b-content-entry-panel__content--poll")){var E=F.find(".b-poll-fieldset__poll-answers li");if(E.length>3){E.filter(function(H){return H>=3}).remove()}F.find(".b-poll-fieldset input").each(function(){var H=this;if(H.type=="text"){H.value="";if($(H).hasClass("placeholder")){setTimeout(function(){$(H).focus().blur().prop("disabled",true)},10)}else{H.disabled=true}}else{if(H.type=="checkbox"){H.checked=H.defaultChecked;if($(H).hasClass("js-poll-timeout")){vBulletin.triggerHandler.apply(H,["click"])}}}})}else{if(F.hasClass("b-content-entry-panel__content--attachment")){F.find('.js-attach-list .js-attach-item:not(.h-hide) .js-attach-ctrl[data-action="remove"]').click()}else{if(F.hasClass("b-content-entry-panel__content--advanced-options")){F.removeClass("h-hide");F.find(".js-htmlstate").selectBox("value","off");if(F.find(".b-content-entry-panel__section--lite").length==0){F.find(".js-collapse__icon:not(.js-collapse--collapsed)").trigger("click")}else{F.find(".js-collapse__icon:not(.js-collapse--collapsed)").first().trigger("click")}}else{if(F.hasClass("b-content-entry-panel__content--event")){var D=$('input[name="eventstartdate"]',F),A=$(".js-toggle-slider[data-name='is_all_day']",F),C=$('input[name="eventenddate"]',F),G=$("input[name='location']");if(D.length){D.val(D.data("initial-value"))}if(A.length&&A.hasClass("b-toggle-slider--no")){A.trigger("click")}if(C.length){C.val(C.data("initial-value"))}if(G.length){G.val("")}}}}}}}};vBulletin.contentEntryBox.showPanel=function(A){A.removeClass("h-hide");if(A.closest(".edit-conversation-container").length==1){if(A.hasClass("b-content-entry-panel__content--link")||A.hasClass("b-content-entry-panel__content--video")){$(".b-link-input",A).addClass("h-hide")}}};vBulletin.contentEntryBox.enablePanelFields=function(A){if(A.hasClass("b-content-entry-panel__content--gallery")){A.find(".b-form-input__file--hidden").prop("disabled",false)}else{if(A.hasClass("b-content-entry-panel__content--link")||A.hasClass("b-content-entry-panel__content--video")){A.find(".b-link-input__url").prop("disabled",false)}else{if(A.hasClass("b-content-entry-panel__content--poll")){A.find(".b-poll-fieldset .b-form-input__input").prop("disabled",false)}}}};vBulletin.contentEntryBox.changeFormToSelectedContentType=function(C){var B=C.closest("form"),A=C.data("panel");var E=$(".js-content-entry-title",B);var F=$(".js-editor",B);var D=E.filter(".placeholder").focus();if(!B.data("default-action")){B.data("default-action",B.attr("action"))}if(!B.data("default-content-type")&&B.data("content-type")){B.data("default-content-type",B.data("content-type"))}if(!E.data("default-placeholder")){E.data("default-placeholder",E.attr("placeholder"))}if(!F.data("default-placeholder")){F.data("default-placeholder",F.attr("placeholder"))}if(C.hasClass("b-toolbar__item--active")){F.attr("placeholder",vBulletin.phrase.get("write_something_here_optional"));$(".b-editor__placeholder",B).text(vBulletin.phrase.get("write_something_here_optional"));switch(A){case"b-content-entry-panel__content--gallery":B.attr("action",vBulletin.getAjaxBaseurl()+"/create-content/gallery");B.data("content-type","gallery");E.attr("placeholder",vBulletin.phrase.get("enter_photo_gallery_title"));break;case"b-content-entry-panel__content--link":B.attr("action",vBulletin.getAjaxBaseurl()+"/create-content/link");B.data("content-type","link");E.attr("placeholder",vBulletin.phrase.get("enter_link_title"));break;case"b-content-entry-panel__content--video":B.attr("action",vBulletin.getAjaxBaseurl()+"/create-content/video");B.data("content-type","video");E.attr("placeholder",vBulletin.phrase.get("enter_video_title"));break;case"b-content-entry-panel__content--poll":B.attr("action",vBulletin.getAjaxBaseurl()+"/create-content/poll");B.data("content-type","poll");E.attr("placeholder",vBulletin.phrase.get("enter_poll_question"));break;case"b-content-entry-panel__content--event":B.attr("action",vBulletin.getAjaxBaseurl()+"/create-content/event");B.data("content-type","event");E.attr("placeholder",vBulletin.phrase.get("enter_event_title"));F.attr("placeholder",vBulletin.phrase.get("enter_event_details_here"));$(".b-editor__placeholder",B).text(vBulletin.phrase.get("enter_event_details_here"));break}}else{if(B.data("default-action")){B.attr("action",B.data("default-action"))}else{B.attr("action",vBulletin.getAjaxBaseurl()+"/create-content/text")}if(B.data("default-content-type")){B.data("content-type",B.data("default-content-type"))}else{B.data("content-type","text")}if(E.data("default-placeholder")){E.attr("placeholder",E.data("default-placeholder"))}else{E.attr("placeholder",vBulletin.phrase.get("enter_title"))}if(F.data("default-placeholder")){F.attr("placeholder",F.data("default-placeholder"));$(".b-editor__placeholder",B).text(F.data("default-placeholder"))}else{F.attr("placeholder",vBulletin.phrase.get("write_something_here"));$(".b-editor__placeholder",B).text(vBulletin.phrase.get("write_something_here"))}}if(D.length){E.blur()}};vBulletin.contentEntryBox.toggleAdvancedEditor=function(A){var B=A.closest(".js-content-entry").find(".js-editor");if(B.attr("id")&&vBulletin.ckeditor.editorExists(B.attr("id"))){vBulletin.ckeditor.toggleToolbar(B)}else{vBulletin.ckeditor.initEditor(B,{showToolbar:true,success:function(D,C){this.focus();var E=B.data("callback");if(typeof E=="function"){E.call(this,B)}}})}};vBulletin.contentEntryBox.normalizeFloatRowHeight=function(G,E){var A=null,C=null,B=0,D=0;var F=function(L,K,J,I,H){if(I){L.find(K).slice(J,I).height(H)}else{L.find(K).slice(J).height(H)}};G.find(E).each(function(H){C=$(this).position().top;if(C!==A){if(D){F(G,E,B,H,D)}B=H;D=0;A=$(this).position().top}var I=$(this).outerHeight(true);D=D>I?D:I});F(G,E,B,0,D)};vBulletin.contentEntryBox.toggleMoreSmilies=function(){var D=$(this),B=D.closest(".js-smilie-container");var C=function(F){$(".js-smilie-category",F).add(".js-toggle-more-smilies",F).add(".js-smilie-category-preview",F).toggleClass("h-hide");F.toggleClass("b-smilie__container--big")};if(!B.data("all-smilies-loaded")){var E=$("<span />").addClass("h-left h-margin-top-xs").text(vBulletin.phrase.get("loading")+"...");D.after(E).addClass("h-hide");var A=function(F){F.find(".js-smilie-category").each(function(){var J=$(this),I=J.find("img"),H=I.length,G=0;I.off("load").on("load",function(K){++G;if(G>=H-1){vBulletin.contentEntryBox.normalizeFloatRowHeight(J,".js-smilie-button")}})})};vBulletin.AJAX({call:"/ajax/render/contententry_panel_smilies",data:{previewOnly:0},success:function(F,G,I){D.removeClass("h-hide");E.remove();var H=$(F).find(".js-smilie-container");B.replaceWith(H);H.data("all-smilies-loaded","1");C(H);A(H)}})}else{C(B)}return false};vBulletin.contentEntryBox.insertSmilie=function(E){var D=function(H){var J=$(this),L=J.attr("src"),K=J.attr("title"),G=J.data("smilieid");var I=H.document.createElement("img",{attributes:{src:L,"data-cke-saved-src":L,title:K,alt:K,smilieid:G}});H.insertElement(I)};var C=$(this),F=C.closest(".js-content-entry").find(".js-editor"),B=C.find("img").get(0),A=F.attr("id");if(C.hasClass("b-smilie__button--disabled")){return false}if(A&&vBulletin.ckeditor.editorExists(A)){D.apply(B,[vBulletin.ckeditor.getEditor(A)])}else{vBulletin.ckeditor.initEditor(F,{showToolbar:true,success:function(H,G){D.apply(B,[this])}})}return false};vBulletin.contentEntryBox.handleEventStartEndTimeChanges=function(L){var B=$(L.target).closest(".js-content-entry-panel__content--event").find(".js-event-dateinput"),C=B.filter("[name=eventstartdate]"),A=B.filter("[name=eventenddate]"),D=C.val(),I=A.val(),N=false;if(typeof vBulletin.contentEntryBox.handleEventStartEndTimeChanges_eventLength=="undefined"){vBulletin.contentEntryBox.handleEventStartEndTimeChanges_eventLength=3600*1000;vBulletin.contentEntryBox.handleEventStartEndTimeChanges_startDate=C.data("initial-value");vBulletin.contentEntryBox.handleEventStartEndTimeChanges_endDate=A.data("initial-value")}if(D!=vBulletin.contentEntryBox.handleEventStartEndTimeChanges_startDate){var M=new Date(Date.parse(D)),G=M.getTime()+vBulletin.contentEntryBox.handleEventStartEndTimeChanges_eventLength;M=new Date(G);function H(O){return O<10?"0"+O:O}I=H(M.getMonth()+1)+"/"+H(M.getDate())+"/"+M.getFullYear()+" "+H(M.getHours())+":"+H(M.getMinutes());N=true}else{if(I!=vBulletin.contentEntryBox.handleEventStartEndTimeChanges_endDate){var K=new Date(Date.parse(D)),F=new Date(Date.parse(I)),E=F.getTime()-K.getTime();vBulletin.contentEntryBox.handleEventStartEndTimeChanges_eventLength=E}}vBulletin.contentEntryBox.handleEventStartEndTimeChanges_startDate=D;vBulletin.contentEntryBox.handleEventStartEndTimeChanges_endDate=I;if(N){var J=vBulletin.flatpickr.getInstance(A);J.setDate(I)}};vBulletin.contentEntryBox.handleEventAllDayChanges=function(I){var J=($(this).find("input[name=is_all_day]:checked").val()=="1"),C=$(I.target).closest(".js-content-entry-panel__content--event").find(".js-event-dateinput"),E=C.filter("[name=eventstartdate]"),L=E.data("initial-value"),D=E.val()||L,A=C.filter("[name=eventenddate]"),G=A.data("initial-value"),H=A.val()||G,K="datetime",M="temp-saved-date";if(J){K="date";E.data(M,D);A.data(M,H)}else{if(E.val().indexOf(":")===-1){E.val(D)}if(A.val().indexOf(":")===-1){A.val(H)}var B=E.data(M),F=A.data(M);if(B&&B.indexOf(D)>=0){E.val(B)}if(F&&F.indexOf(H)>=0){A.val(F)}}vBulletin.flatpickr.changePickerType(E,K);vBulletin.flatpickr.changePickerType(A,K)};vBulletin.contentEntryBox.handlePanelCloseButton=function(C){var B=$(this),A=B.parent().data("class");if(B.is(".js-ckeditor-toolbar-close")){A="b-content-entry-panel__content--toggle-editor"}B.closest(".b-content-entry").find(".b-toolbar__item[data-panel="+A+"]").trigger("click")};vBulletin.contentEntryBox.handleLinkInputKeypress=function(A){if(A.keyCode==13){$(this).next(".js-attach-button").trigger("click");return false}return true};vBulletin.contentEntryBox.afterPanelChange=function(C){var B=C.find(".js-content-entry-panel"),A=B.find(".b-content-entry-panel__content").not(".h-hide");B.toggleClass("h-hide",!A.length);A.removeClass("b-content-entry-panel__content--first").first().addClass("b-content-entry-panel__content--first");B.closest(".js-content-entry").toggleClass("b-content-entry--all-panels-hidden",A.length==0);var D=B.data("callback");if(typeof D=="function"){D.call(B)}};vBulletin.contentEntryBox.openConfirmRemoveContentDialog=function(B,A){openConfirmDialog({title:vBulletin.phrase.get(A||"content_entry"),message:vBulletin.phrase.get("all_changes_made_will_be_lost_would_you_like_to_continue"),iconType:"warning",onClickYes:B});return false};vBulletin.contentEntryBox.isEditorEmpty=function(A){return vBulletin.ckeditor.isEditorEmpty(A.find(".js-editor"))};vBulletin.contentEntryBox.arePanelsEmtpy=function(B){var A=true;B.find(".b-content-entry-panel__content").each(function(C,D){if(!vBulletin.contentEntryBox.isPanelEmpty($(D))){A=false;return false}});return A};vBulletin.contentEntryBox.isEmpty=function(A){var B=A.find(".js-content-entry-title").val();return((typeof B!="string"||B=="")&&vBulletin.contentEntryBox.isEditorEmpty(A)&&vBulletin.contentEntryBox.arePanelsEmtpy(A))};vBulletin.contentEntryBox.addAttachmentItemPanel=function(E,G,D){if(!E){console.log("addAttachmentItemPanel failed because $closestElement was not provided");return false}var B=E.closest(".js-content-entry"),F=B.find(".js-attach-list"),H=F.find(".js-attach-item-sample").first().clone(true),A=$("<img />").attr("src",pageData.baseurl+"/filedata/fetch?type=thumb&filedataid="+D.filedataid).addClass("b-attach-item__image"),C=B.find('.b-toolbar__item[data-panel="b-content-entry-panel__content--attachment"]');H.removeClass("js-attach-item-sample");H.find(".js-attach-item-image").append(A);H.find(".js-attach-item-filename").text(D.filename);var I="";if(matches=D.filename.match(/\.([a-z]+)$/i)){I=matches[1]}H.data("fileext",I);H.data("filename",D.filename);H.data("filedataid",D.filedataid);H.data("attachnodeid",0);H.data("first-insert-id",G);H.append($("<input />").attr({type:"hidden",name:"filedataids["+G+"]"}).val(D.filedataid)).append($("<input />").attr({type:"hidden",name:"filenames["+G+"]"}).val(D.filename));if(D.imagesize){H.append($("<input />").attr({type:"hidden",name:"setting["+G+"][size]"}).val(D.imagesize))}H.appendTo(F).removeClass("h-hide");F.removeClass("h-hide");if(!C.hasClass("b-toolbar__item--active")){C.trigger("click")}return true};vBulletin.contentEntryBox.handleAttachmentControls=function(T){var H=$(this),E=H.closest("form"),B=H.closest(".js-attach-item"),Q=H.data("action"),C=H.data("imagesize"),S=B.data("filedataid"),A=vBulletin.ckeditor.generateTempAttachmentId(S),P=B.data("attachnodeid")||0,D=B.data("fileext"),R=B.data("filename"),U=E.find(".js-editor"),L=B.data("first-insert-id");var F=function(j,W,i,Y,g,V){var n="",f="",c=pageData.baseurl+"/filedata/fetch?filedataid="+j,a=pageData.baseurl+"/filedata/fetch?filedataid="+j+"&thumb=1",l="";var h=(W.match(/^(gif|jpg|jpeg|jpe|png|bmp)$/i)!==null);var p="filedataids["+A+"]";var b="filenames["+A+"]";var Z=false;var i=B.data("filename");var d=true;var e=false;var k="data-tempid";var m=A;if(!L&&(P==0)){$filenameInput=B.find('input[type="hidden"][name="filenames[]"]');i=$filenameInput&&$filenameInput.val();$filenameInput.remove();B.find('input[type="hidden"][name="filedataids[]"]').remove();B.data("first-insert-id",A)}else{if(!L&&(P>0)){foundFirstInsert=false;if(Y.mode=="wysiwyg"){temp=document.createElement("div");temp.innerHTML=Y.getData();if(h){$insertedImgTag=$(temp).find('img[data-attachmentid="'+P+'"]');foundFirstInsert=($insertedImgTag.length>0)}else{$insertedAnchorTag=$(temp).find('a[data-attachmentid="'+P+'"]');foundFirstInsert=($insertedAnchorTag.length>0)}}else{regex=new RegExp("\\[ATTACH(=[^\\]]+)?\\]n"+P+"\\[/ATTACH\\]","i");sourceText=$(Y.container.$).find("textarea.cke_source").val();matches=regex.exec(sourceText);if(matches){foundFirstInsert=true}}d=false;if(foundFirstInsert){e=true}else{c=pageData.baseurl+"/filedata/fetch?id="+P;a=pageData.baseurl+"/filedata/fetch?id="+P+"&thumb=1";k="data-attachmentid";m=P;A="n"+P;B.data("first-insert-id",A);if((g!="insert_image")&&(g!="insert_sigpic")&&!V){V="thumb"}if(V){var o={};o.attachmentid=P;o.size=V;vBulletin.AJAX({call:"/uploader/saveattachmentsetting",data:o,success:function(q){if(q.success){console.log("/uploader/saveattachmentsetting Success!")}},})}}}else{if(L){e=h;d=false}}}if(!h){if(P>0){A=P;m=A}else{if(B.data("tempid")){A=B.data("tempid");m=A}}}if(h){Z="setting["+A+"][size]";if(g=="insert_sigpic"){n=" [SIGPIC][/SIGPIC] ";f=n}else{if(g=="insert_image"){if(V=="icon"||V=="thumb"||V=="small"||V=="medium"||V=="large"||V=="full"){c+="&amp;type="+V}n=' <img class="bbcode-attachment" src="{0}" {1}="{2}" /> '.format(c,k,m);f=" [ATTACH=CONFIG]{0}[/ATTACH] ".format(A);l=c}else{V="thumb";n=' <img class="bbcode-attachment thumbnail" src="{0}" {1}="{2}" /> '.format(a,k,m);f=" [ATTACH=CONFIG]{0}[/ATTACH] ".format(A);l=a}}}else{if(g=="insert_sigpic"){n="";f=n}else{n=' <a class="bbcode-attachment" href="{0}" {1}="{2}" />'.format(c,k,m)+i+"</a> ";f=" [ATTACH]{0}[/ATTACH] ".format(A)}}if(d){B.find('input[type="hidden"][name="'+p+'"]').remove();B.find('input[type="hidden"][name="'+b+'"]').remove();if(Z){B.find('input[type="hidden"][name="'+Z+'"]').remove()}B.append($("<input />").attr({type:"hidden",name:p}).val(j));B.append($("<input />").attr({type:"hidden",name:b}).val(i));if(Z){B.append($("<input />").attr({type:"hidden",name:Z}).val(V))}B.attr("data-tempid",A)}if(e){filedataObj={filedataid:j,filename:i,imagesize:V};vBulletin.contentEntryBox.addAttachmentItemPanel(H,A,filedataObj)}var X=Y.document&&Y.document.getBody();if(X){X.setAttribute("contentEditable",false);X.setAttribute("contentEditable",true)}if(Y.mode=="wysiwyg"){Y.insertHtml(n);if(l!=""){vBulletin.ckeditor.autogrowEditorOnImageLoad(l,Y)}}else{$sourceTextArea=$(Y.container.$).find("textarea.cke_source");cursorStart=$sourceTextArea[0].selectionStart;cursorEnd=$sourceTextArea[0].selectionEnd;text=$sourceTextArea.val();newtext=text.substring(0,cursorStart)+f+text.substring(cursorEnd);$sourceTextArea.val(newtext)}window.setTimeout(function(){Y.focus();Y.execCommand("autogrow")},10)};switch(Q){case"remove":var O=function(){console.log("removeAttachmentFromPanel attachnodeid: "+P);if(P>0){$("<input />").attr("type","hidden").attr("name","removeattachnodeids[]").val(P).appendTo(B.closest("form"))}B.remove()};if(vBulletin.ckeditor.editorExists(U.attr("id"))){var I=vBulletin.ckeditor.getEditor(U.attr("id")),K=I.getData(),N=pageData.baseurl+"/filedata/fetch?filedataid="+S,M=pageData.baseurl+"/filedata/fetch?filedataid="+S+"&thumb=1";K=K.replace("[ATTACH]{0}[/ATTACH]".format(L),"");K=K.replace("[ATTACH=CONFIG]{0}[/ATTACH]".format(L),"");K=K.replace("[IMG]{0}[/IMG]".format(N),"");K=K.replace("[IMG]{0}&amp;type=icon[/IMG]".format(N),"");K=K.replace("[IMG]{0}&amp;type=thumb[/IMG]".format(N),"");K=K.replace("[IMG]{0}&amp;type=small[/IMG]".format(N),"");K=K.replace("[IMG]{0}&amp;type=medium[/IMG]".format(N),"");K=K.replace("[IMG]{0}&amp;type=large[/IMG]".format(N),"");K=K.replace("[IMG]{0}&amp;type=full[/IMG]".format(N),"");var J=B.find('input[type="hidden"]'),G;for(G=0;G<J.length;G++){regex=/filedataids\[([^\]]+)]/;matches=regex.exec(J[G].name),tempid=matches&&matches[1];if(tempid){regexpBbcode=new RegExp("\\[ATTACH(=[^\\]]+)?\\]"+tempid+"\\[/ATTACH\\]","i");K=K.replace(regexpBbcode,"");temp=document.createElement("div");temp.innerHTML=K;$(temp).find('img[data-tempid="'+tempid+'"]').remove();$(temp).find('a[data-tempid="'+tempid+'"]').remove();K=temp.innerHTML}}if(P>0){regexpBbcode=new RegExp("\\[ATTACH(=[^\\]]+)?\\]n"+P+"\\[/ATTACH\\]","i");K=K.replace(regexpBbcode,"");temp=document.createElement("div");temp.innerHTML=K;$(temp).find('img[data-attachmentid="'+P+'"]').remove();$(temp).find('a[data-attachmentid="'+P+'"]').remove();K=temp.innerHTML}I.setData(K,function(){O()})}else{O()}break;case"insert":case"insert_image":case"insert_sigpic":default:if(!vBulletin.ckeditor.editorExists(U.attr("id"))){vBulletin.ckeditor.initEditor(U,{success:function(){window.setTimeout(function(){F(S,D,R,vBulletin.ckeditor.getEditor(U.attr("id")),Q,C)},0)}})}else{F(S,D,R,vBulletin.ckeditor.getEditor(U.attr("id")),Q,C)}break}return false};vBulletin.contentEntryBox.handleToolbarButtons=function(D,B){var H=$(this),A=H.closest(".js-content-entry"),K=A.find("."+H.data("panel")),G=H.closest(".js-toolbar-primary").length==1,L=A.data("prev-selected-panel")||"";if(G){if(A.data("allow-type-text")=="0"){H.addClass("b-toolbar__item--unselectable");if(H.hasClass("b-toolbar__item--active")){return false}}if(!B){if((L.length&&L.is(":visible")&&!vBulletin.contentEntryBox.isPanelEmpty(L))||(K.is(":visible")&&!vBulletin.contentEntryBox.isPanelEmpty(K))){return vBulletin.contentEntryBox.openConfirmRemoveContentDialog(function(){if(L.length){vBulletin.contentEntryBox.resetPanel(L);L=""}else{vBulletin.contentEntryBox.resetPanel(K)}H.trigger("click",[true])})}}$(".js-toolbar-primary .b-toolbar__item",A).removeClass(function(){if(this==H.get(0)){$(this).toggleClass("b-toolbar__item--active");return""}return"b-toolbar__item--active b-toolbar__item--unselectable"});if(L.length&&L.is(":visible")){vBulletin.contentEntryBox.resetPanel(L);L=""}if(H.hasClass("b-toolbar__item--active")){vBulletin.contentEntryBox.enablePanelFields(K);vBulletin.contentEntryBox.showPanel(K);L=K}else{vBulletin.contentEntryBox.resetPanel(K);L=""}vBulletin.contentEntryBox.changeFormToSelectedContentType(H);A.data("prev-selected-panel",L)}else{if(!B&&H.data("panel")=="b-content-entry-panel__content--attachment"&&K.is(":visible")&&!vBulletin.contentEntryBox.isPanelEmpty(K)){return vBulletin.contentEntryBox.openConfirmRemoveContentDialog(function(){vBulletin.contentEntryBox.resetPanel(K);H.trigger("click",[true])})}H.toggleClass("b-toolbar__item--active");var I=H.hasClass("b-toolbar__item--active"),J=parseInt(pageData.user_editorstate,10),F=H.data("panel"),E=vBulletin.contentEntryBox.getPanelStateIntValue(F),C;if(F=="b-content-entry-panel__content--toggle-editor"){vBulletin.contentEntryBox.toggleAdvancedEditor(H)}else{K.toggleClass("h-hide",!I)}if(I){J=(J|E);C="add"}else{J-=(J&E);C="remove"}if(J!=pageData.user_editorstate){vBulletin.loadingIndicator.suppressNextAjaxIndicator();vBulletin.AJAX({call:"/ajax/api/user/saveEditorState",data:{action:C,value:E},success:function(M){if(M&&M.success&&typeof M.editorstate!="undefined"){pageData.user_editorstate=parseInt(M.editorstate,10)}}})}}vBulletin.contentEntryBox.afterPanelChange(A);A.find(".js-contententry-buttons").removeClass("h-hide");vBulletin.hv.show(A.find(".js-human-verification"))};vBulletin.contentEntryBox.getPanelStateIntValue=function(B){var A={"b-content-entry-panel__content--toggle-editor":1,"b-content-entry-panel__content--attachment":2,"b-content-entry-panel__content--smiley":4};return(typeof A[B]!="undefined")?A[B]:0};vBulletin.contentEntryBox.restoreEditorState=function(C){var D=$("#"+C),A=D.closest(".js-content-entry"),B=A.find(".b-toolbar__item--secondary");B.each(function(){var F=$(this),G=F.data("panel"),E=vBulletin.contentEntryBox.getPanelStateIntValue(G);if((pageData.user_editorstate&E)&&!F.hasClass("b-toolbar__item--active")){F.trigger("click")}})};vBulletin.contentEntryBox.setDefaultTab=function(C){var A=$(C).data("default-content-type");if(A&&A!="Text"){var B=$('.b-toolbar__item[data-panel="b-content-entry-panel__content--{0}"]'.format(A.toLowerCase()),C);if(!B.data("defaultSelected")&&!B.hasClass("b-toolbar__item--active")){B.trigger("click");B.data("defaultSelected",true)}}};vBulletin.contentEntryBox.init=function(){console.log("vBulletin.contentEntryBox.init start");var E=$(".js-content-entry").not(".js-content-entry-basic"),C=vBulletin.contentEntryBox;isCkeditorCompatible=vBulletin.ckeditor.checkEnvironment();if(E.length>0){$("form",E).each(function(){var G=$(this),H=G.find(".js-editor"),F=vBulletin.ckeditor.getEditorContent(H);G.trigger("reset");if(F){if(vBulletin.ckeditor.editorExists(H)){vBulletin.ckeditor.getEditor(H).setData(F)}else{H.val(F)}}});C.initAjaxFormSubmit();C.initPhotoGallery();C.initVideoEditPane();C.initAutofillFromTitle(E);C.initCollapse();$(document).off("click",".js-content-entry-save-draft").on("click",".js-content-entry-save-draft",C.handleButtonSaveDraft);$(document).off("click",".js-content-entry-preview").on("click",".js-content-entry-preview",C.handleButtonPreview);$(document).off("click",".js-content-entry-loadnewposts").on("click",".js-content-entry-loadnewposts",C.handleButtonLoadNewPosts);$(document).off("keydown",".js-content-entry .b-link-input__url").on("keydown",".js-content-entry .b-link-input__url",C.handleLinkInputKeypress);$(document).off("focus",".js-content-entry .js-editor").on("focus",".js-content-entry .js-editor",function(){var F=$(this).closest(".js-content-entry");F.find(".js-contententry-buttons").removeClass("h-hide");vBulletin.hv.show(F.find(".js-human-verification"))});C.disable_bbcode=$('.js-content-entry .js-toggle-slider[data-name="disable_bbcode"]').data("value");$(document).off("change",'.js-content-entry .js-toggle-slider[data-name="disable_bbcode"]').on("change",'.js-content-entry .js-toggle-slider[data-name="disable_bbcode"]',function(F,G){C.disable_bbcode=G});var A=".js-content-entry .js-content-entry-panel__content--event ",B=A+".js-event-dateinput",D=A+".js-toggle-slider[data-name='is_all_day']";$(document).off("change",B).on("change",B,C.handleEventStartEndTimeChanges).off("change",D).on("change",D,C.handleEventAllDayChanges);$(document).off("keyup",".js-event-location").on("keyup",".js-event-location",function(F){var G=$(F.target);G.closest("form").find(".js-event-previewmap").prop("disabled",(G.val()==""))});$(document).off("click",".js-event-previewmap").on("click",".js-event-previewmap",function(G){var F=$(G.target).closest("form").find(".js-event-location").val();vBulletin.AJAX({call:"/ajax/render/display_event_map",data:{location:F},success:function(H){openAlertDialog({title:vBulletin.phrase.get("preview_map"),message:H,})}})})}$(document).off("click",".js-content-entry-delete").on("click",".js-content-entry-delete",C.handleButtonDelete);$(document).off("click",".js-content-entry-cancel").on("click",".js-content-entry-cancel",C.handleButtonCancel);$(document).off("click",".b-content-entry .b-toolbar__item").on("click",".b-content-entry .b-toolbar__item",C.handleToolbarButtons);$(document).off("click",".js-content-entry .js-contententry-panel-x").on("click",".js-content-entry .js-contententry-panel-x",C.handlePanelCloseButton);if(isCkeditorCompatible){$(document).off("click",".js-smilie-container .js-toggle-more-smilies").on("click",".js-smilie-container .js-toggle-more-smilies",C.toggleMoreSmilies);$(document).off("click",".js-smilie-container .js-smilie-button").on("click",".js-smilie-container .js-smilie-button",C.insertSmilie)}$(document).off("click",".js-content-entry .js-attach-ctrl").on("click",".js-content-entry .js-attach-ctrl",C.handleAttachmentControls);E.each(function(){C.setDefaultTab(this)});console.log("vBulletin.contentEntryBox.init finish")};vBulletin.contentEntryBox.init();