/*=======================================================================*\
|| ###################################################################### ||
|| # 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=$.merge(window.vBulletin.phrase.precache,["attach_video","close_preview","enter_link_title","enter_photo_gallery_title","enter_poll_question","enter_title","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","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","postminchars","threadpreview"]);window.vBulletin.contentEntryBox=window.vBulletin.contentEntryBox||{};vBulletin.contentEntryBox.disable_bbcode=false;vBulletin.contentEntryBox.handleButtonPreview=function(I){var L=$(this),O=L.closest("form"),G=O.find('input[name="parentid"]').val(),D=O.find('input[name="channelid"]').val(),C=O.data("content-type")||"",B=O.find(".js-editor").attr("id"),F=vBulletin.ckeditor.getEditorContent(B),K=O.find('.tag-editor-wrapper .tag-list input[name="tags"]').val(),J=O.find('select[name="htmlstate"]').val(),N=vBulletin.contentEntryBox.disable_bbcode,E=(C=="text");if(E&&F==""){openAlertDialog({title:vBulletin.phrase.get("preview"),message:vBulletin.phrase.get("no_post_content_to_preview"),iconType:"error"});return }var M=function(Q,P){console.warn("Error loading post: {0}".format(Q+" "+P));L.prop("disabled",false);window.vBulletin.loadingIndicator.hide();openAlertDialog({title:vBulletin.phrase.get("preview"),message:vBulletin.phrase.get(Q),iconType:"error"})};var A={parentid:G,channelid:D,pagedata:pageData,conversationtype:C,posttags:K,rawtext:F,isAjaxTemplateRender:true,isAjaxTemplateRenderWithData:true,htmlstate:J,disable_bbcode:N};if(C=="gallery"){var H=[];$('.js-photo-postdata input[name="filedataid[]"]',O).each(function(){H.push(this.value);A["title_"+this.value]=$('.js-photo-postdata input[name="title_'+this.value+'"]',O).val()||""});A.filedataid=H}if(C=="link"){A.link={};A.link["title"]=$(".js-link-title",O).val();A.link["meta"]=$(".js-link-meta",O).val();A.link["url"]=$(".js-link-url",O).val();A.link["url_image"]=$(".js-link-preview-checkbox",O).is(":checked")?0:$(".js-link-url-image:checked",O).val()}if(C=="poll"){A.poll={options:[],mutliple:($('input[name="multiple"]',O).is(":checked")?1:0)};$(".js-poll-option",O).each(function(){A.poll["options"].push(this.value)})}if(C=="video"){A.video={};A.video["title"]=$(".js-link-title",O).val();A.video["meta"]=$(".js-link-meta",O).val();A.video["url"]=$(".js-link-url",O).val();A.video["items"]=[];$(".js-video-url",O).each(function(){A.video["items"].push(this.value)})}window.vBulletin.loadingIndicator.show();L.prop("disabled",true);$.ajax({type:"POST",url:vBulletin.getAjaxBaseurl()+"/create-content/load-preview",dataType:"json",data:A,success:function(Q){L.prop("disabled",false);window.vBulletin.loadingIndicator.hide();if(!Q||Q.error||!Q.template||(E&&!Q.parsedText)){M(Q&&Q.error?Q.error:"unknown_error");return }var P=$("<div />").attr("id","preview-overlay").addClass("h-hide").append($("<div />").addClass("dialog-content")).append($("<div />").addClass("b-button-group h-margin-bottom-m h-clearfix")).appendTo("body");$("<ul />").addClass("conversation-list list-container stream-view activity-view h-clearfix b-post--preview").appendTo($(".dialog-content",P));$("<button />").addClass("js-content-entry-preview-submit b-button b-button--primary h-right").text($(".js-content-entry-submit",O).text()).on("click",function(){O.trigger("submit");P.dialog("close")}).appendTo($(".b-button-group",P));$("<button />").addClass("js-content-entry-preview-close b-button h-right").text(vBulletin.phrase.get("close")).on("click",function(){P.dialog("close")}).appendTo($(".b-button-group",P));$(Q.template).appendTo($("ul",P));$(".js-post .js-post__content-text",P).html(Q.parsedText);$(".dialog-content a",P).addClass("h-disabled").on("click",function(){return false});$(".dialog-content button",P).prop("disabled",true);P.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",P).focus()},close:function(){P.dialog("destroy").remove()}})},error:function(R,Q,P){M("error_loading_preview",P)},complete:function(){L.prop("disabled",false);window.vBulletin.loadingIndicator.hide()}})};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){var B=$(this),A=B.closest("form");vBulletin.contentEntryBox.loadNewPosts(A,B)};vBulletin.contentEntryBox.loadNewPosts=function(P,A,B){var F=P.find('input[name="parentid"]').val(),D=P.find('input[name="channelid"]').val(),G=pageData.lastloadtime||pageData.current_server_datetime,L=pageData.past_page_limit||false;var O=P.closest(".conversation-content-widget");if(O.length==0){O=P.closest("#activities-tab")}var J=$(".conversation-list",O);var K="";if(J.hasClass("thread-view")){K="thread"}else{if(J.hasClass("full-activity-view")){K="full-activity-stream"}else{if(J.hasClass("activity-view")){K="activity-stream"}else{K="stream"}}}var I=$(".list-container",O),M=$(".list-container>li.b-post",O),N=M.length,E=parseInt($('form.toolbar-filter-overlay input[name="pagenum"]').val())||1,H=Number($("form.pagenav-form span.pagetotal").text())||0;M.filter("[data-node-publishdate]").each(function(S,R){var Q=$(R).data("node-publishdate");$(R).removeData("node-publishdate");$(R).removeAttr("data-node-publishdate");if(Q&&(Q+1)>G){G=Q+1}});var C={parentid:F,channelid:D,loadnodeid:B,timestamp:G,pageload_servertime:pageData.current_server_datetime,view:K,currentpage:E,pagetotal:H,postcount:N,postsperpage:vBulletin.conversation.POSTS_PER_PAGE,commentsperpage:vBulletin.conversation.COMMENTS_PER_PAGE,past_page_limit_aware:L,};window.vBulletin.loadingIndicator.show();if(A){A.prop("disabled",true)}vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/create-content/loadnewposts",data:C,success:function(V){if(!V||V.error){return }if(V.redirect){document.location.href=V.redirect;return }pageData.lastloadtime=V.timenow;if(V.past_page_limit){pageData.past_page_limit=V.past_page_limit}if(V.template){if(I.length>1){var U=P.closest(".tab");if(U.length>0){I=$(".list-container",U)}else{I=$(".list-container",$(".tab.media-tab"))}}var R=$(V.template);if(I.hasClass("ajax-order-newest-first")&&$("li.list-item:first",I).length>0){$("li.list-item:first",I).before(R)}else{I.append(R);var S=R.closest(".ui-tabs-panel").find(".conversation-toolbar-wrapper");if(S.hasClass("scrolltofixed-floating")){var Q=S.data("object-instance");if(Q){Q.addLimit(R.filter(function(){return(this.nodeType==Node.ELEMENT_NODE)}).outerHeight(true))}}if(B){vBulletin.scrollToAnchor("#post"+B)}}var T=pageData.nodeid;if(T){if(pageData.threadmarking=="0"||pageData.userid=="0"){vBulletin.cookie.setBbarrayCookie("discussion_view",T,Math.round(new Date().getTime()/1000))}}}},complete:function(){if(A){A.prop("disabled",false)}window.vBulletin.loadingIndicator.hide()}})};vBulletin.contentEntryBox.handleButtonDelete=function(C){var E=$(this),G=$(this.form).data("content-type"),F=G,D=E.closest(".js-content-entry"),B=E.closest(".js-post").data("node-id");if(G!="comment"&&G!="media"){if(E.closest('.content-entry-box[data-node-type="visitorMessage"]').length==1){G="visitorMessage"}else{if(E.closest(".js-conversation-starter").length==1){G=E.closest(".conversation-list.blog-list").length==1?"blog":"topic";G=E.closest(".conversation-list.article-list").length==1?"article":"topic"}else{G="reply"}}}var A=vBulletin.phrase.get("delete_x",vBulletin.phrase.get("posttype_"+G));$deleteDialog=openConfirmDialog({title:A,message:vBulletin.phrase.get("loading")+"...",width:500,dialogClass:"delete-post-dialog dialog-container dialog-box loading",buttonLabel:{yesLabel:A,noLabel:vBulletin.phrase.get("cancel")},onClickYes:function(){var L=D.find("form"),K=vBulletin.triggerHandler.apply(L.get(0),["beforeDelete"]);if(K===false){return }var J=$deleteDialog.find(".delete-posts-form");var I=J.find("input:radio[name=deletetype]:checked").val()||1;var H={hard:(I==2?1:0),reason:J.find(":input[name=deletereason]").val(),nodeids:B};vBulletin.AJAX({url:vBulletin.normalizeAjaxUrl(J.attr("action")),data:H,error_phrase:"error_deleting_posts_x",success:function(M){$(window).off("beforeunload.editPost");$("body").trigger(F+"_editform_onunload",[D]);if(I==2){if(G=="topic"||G=="blog"){location.replace($("#breadcrumbs .crumb a:last").attr("href")||pageData.baseurl)}else{$('.js-post[data-node-id="'+B+'"]').remove()}}else{var N=$(".filter-wrapper",E.closest(".conversation-view, .ui-tabs-panel, .widget-content").find(".conversation-toolbar")).data("object-instance");if(N&&typeof N.applyFilters=="function"){N.forceApplyFilters()}else{if(G=="visitorMessage"){window.history.back()}else{location.reload()}}}L.trigger("afterDelete")}})}});$.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/render/delete_post_form",data:({postType:G,nodeid:B,authorid:E.data("userid")}),type:"POST",dataType:"json",success:function(H){console.log("/ajax/render/delete_post_form");if(H&&!H.errors){$deleteDialog.removeClass("loading").find(".dialog-content .message").html(H).find("[placeholder]").placeholder().end().end().dialog("option","position","center")}else{console.log("/ajax/render/delete_post_form successful, but response was not valid: "+JSON.stringify(H));openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("invalid_server_response_please_try_again"),iconType:"error",onAfterClose:function(){$deleteDialog.dialog("close")}})}},error:function(J,I,H){console.log("/ajax/render/delete_post_form failed, error: "+H);openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_loading_delete_form_x",J.status),iconType:"error",onAfterClose:function(){$deleteDialog.dialog("close")}})}})};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");$("body").trigger(G+"_editform_onunload",[H]);$(C).trigger("afterCancel");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 O=$(this),J,H=(vBulletin.contentEntryBox.MIN_EDITOR_CONTENT_LEN?vBulletin.contentEntryBox.MIN_EDITOR_CONTENT_LEN:window.vBulletin.options.get("postminchars")),M=window.vBulletin.options.get("commentminchars"),C=$(".js-editor",O),D=C.attr("id"),E=$.trim(C.val()),N=(O.closest(".js-comments").length>0)?true:false,K=O.data("content-type"),G=vBulletin.contentEntryBox.ATTACHLIMIT||0,L=$(".b-content-entry-panel__content--"+K,O);if(K=="video"&&L.length==0){L=$(".b-content-entry-panel__content--link",O)}if(K=="comment"||N){if(E.length<M){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_message_x_chars",M),iconType:"warning",onAfterClose:function(){setTimeout(function(){C.focus()},10)}});return false}return true}if(vBulletin.ckeditor.editorExists(D)){J=vBulletin.ckeditor.getEditor(D);var F=J.getData();E=$.trim($("<div />").html(F).text())}if($(".js-content-entry-title",O).is(":visible")&&$.trim($(".js-content-entry-title",O).val())==""){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_title_of_topic"),iconType:"warning",onAfterClose:function(){setTimeout(function(){$(".js-content-entry-title",O).focus()},10)}});return false}if((K!=="poll"&&K!="gallery"&&K!="link"&&K!="video")&&C.length>0&&E.length<H){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_message_x_chars",H),iconType:"warning",onAfterClose:function(){setTimeout(function(){if(J){J.focus()}else{C.focus()}},10)}});return false}if(K=="gallery"){if($(".js-photo-postdata input",L).length==0){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_upload_at_least_one_photo"),iconType:"warning"});return false}if(G>0&&$('.js-photo-postdata input[name^="filedataid"]',L).length>G){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("you_may_only_attach_x_files_per_post",G),iconType:"warning"});return false}}if(K=="link"&&!$.trim(L.find(".js-panel-content").html())){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_a_valid_url_and_click_attach"),iconType:"warning",onAfterClose:function(){setTimeout(function(){$(".b-link-input__url",L).focus()},10)}});return false}if(K=="video"&&!$.trim(L.find(".js-panel-content").html())){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_a_valid_url_and_click_attach"),iconType:"warning",onAfterClose:function(){setTimeout(function(){$(".b-link-input__url",L).focus()},10)}});return false}if(K=="poll"){var A=0,B=2,I;$(".js-poll-option:visible",O).each(function(){if($.trim($(this).val())!=""){A++}else{if(!I){I=$(this)}}if(A>=B){return false}});if(A<B){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_at_least_x_poll_answers",B),iconType:"warning",onAfterClose:function(){setTimeout(function(){I.focus()},10)}});return false}}return true};vBulletin.contentEntryBox.callbackSubmitSuccess=function(G,D,P,Q){console.log("vBulletin.contentEntryBox.callbackSubmitSuccess");if((G&&G.error)||$.trim(G)==""){$(".refresh_imagereg a",Q).click();if(typeof Recaptcha!=="undefined"){Recaptcha.reload()}var C;if(G&&G.error&&$.isArray(G.error)&&$.isArray(G.error[0])){switch(G.error[0]){case"toomanyimages":C=vBulletin.phrase.get("toomanyimages",G.error[1],G.error[2]);break;default:$.each(G.error,function(R,S){$.each(S,function(U,T){if(U>0){S[U]=vBulletin.phrase.get(T)}});G.error[R]=vBulletin.phrase.get(S)});C=G.error.join("<br />")}}else{if(G&&G.error){C=vBulletin.phrase.get(G.error)}else{C=vBulletin.phrase.get("empty_response")}}openAlertDialog({title:vBulletin.phrase.get("edit_conversation"),message:C,iconType:"warning"});return }Q.closest(".js-dialog-body").dialog("close");var F=Q.data("content-type")||"";var A=Q.data("current-channeltype")||"";var E=Q.attr("ck-editorid")||$(".js-editor",Q).attr("id");vBulletin.contentEntryBox.resetForm(Q);var I=vBulletin.triggerHandler.apply(Q.get(0),["afterSave",$(document),G]);if(I===false){return }var L=pageData,N,B=G.nodeId,O,K,J;O=Q.closest(".conversation-content-widget");if(O.length==0){O=Q.closest("#activities-tab")}K=$(".conversation-list",O);J=$(".list-container",O);if(Q.closest(".private-message-widget").length==1){if(Q.closest(".private-message-widget").find(".conversation-list").length==1){document.location.reload()}else{location.href=pageData.baseurl+"/privatemessage/index"}return }if(G.retUrl&&J.length==0){location.href=G.retUrl;return }window.vBulletin.loadingIndicator.show();if(K.hasClass("thread-view")){N="thread"}else{if(K.hasClass("full-activity-view")){N="full-activity-stream"}else{if(K.hasClass("activity-view")){N="activity-stream"}else{N="stream"}}}if(A==="forum"&&N==="thread"){vBulletin.contentEntryBox.loadNewPosts(Q,null,G.nodeId);vBulletin.hv.reset();return }var H,M=$(".js-post:not(.js-comment):last .b-post__count:first",K).text()||"1";H=Number(M.replace("#",""));L["posts-perpage"]=vBulletin.conversation.POSTS_PER_PAGE;if(N=="thread"){L["comments-perpage"]=vBulletin.conversation.COMMENTS_PER_PAGE}$.post(vBulletin.getAjaxBaseurl()+"/create-content/loadnode",{nodeid:B,view:N,index:H,page:L,type:F,isAjaxTemplateRender:true,isAjaxTemplateRenderWithData:true},function(V){Q.closest(".content-entry-inline").hide();Q.each(function(W,X){$(X).find("textarea").val("")});window.vBulletin.loadingIndicator.hide();if(V.error){if(G.moderateNode){$textarea=Q.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(V.error),iconType:"error"})}}else{var T=$(V.template);if(J.length>1){$tab=Q.closest(".tab");if($tab.length>0){J=$(".list-container",$tab)}else{J=$(".list-container",$(".tab.media-tab"))}}if(J.hasClass("ajax-order-newest-first")&&$("li.list-item:first",J).length>0){$("li.list-item:first",J).before(T)}else{J.append(T);var U=T.closest(".ui-tabs-panel").find(".conversation-toolbar-wrapper");if(U.hasClass("scrolltofixed-floating")){var R=U.data("object-instance");if(R){R.addLimit(T.outerHeight(true))}}vBulletin.scrollToAnchor("#post"+B)}if(J.children(".list-item").length>0){J.parent().find(".conversation-empty").addClass("h-hide")}$("body").trigger(F+"_savepost_success",[Q]);vBulletin.Responsive.ConversationContent.checkForSignature();var S=$(".js-conversation-starter",O).attr("data-node-id");if(S){if(pageData.threadmarking=="0"||pageData.userid=="0"){vBulletin.cookie.setBbarrayCookie("discussion_view",S,Math.round(new Date().getTime()/1000))}else{$.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/api/node/markRead",data:{nodeid:S},type:"POST",dataType:"json",complete:function(){},success:function(W){if(W&&!W.error){console.log("Topic "+S+" is marked read successfully!")}else{console.log("Topic "+S+" is marked read failed: "+W.error)}},error:function(Y,X,W){console.log("Topic "+S+" is marked read failed:"+W)}})}}vBulletin.subscribe.updateSubscribeButton(V.topic_subscribed)}},"json").error(function(T,S,R){console.warn("Error loading post: {0}".format(R));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");D.ajaxForm({dataType:"json",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);var H,K=L[L.length-1];try{H=$.parseJSON(K)}catch(J){}if(H){vBulletin.contentEntryBox.callbackSubmitSuccess(H,"",N,D);return }}openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("error_x_while_saving_content",I),iconType:"error"})},complete:function(){console.log("ajaxForm complete (vBulletin.contentEntryBox.initAjaxFormSubmit)");window.vBulletin.loadingIndicator.hide()},beforeSerialize:function(H,I){console.log("ajaxForm beforeSerialize (vBulletin.contentEntryBox.initAjaxFormSubmit)");$blogWidget=H.closest(".blog-channel-content-widget");if($blogWidget.length>0){$inputs=$blogWidget.find(".blog-editor-additional .content-entry-box input");if($inputs.length>0){$inputs.each(function(K,J){$input=$(J);$("<input>").attr({type:"hidden",id:$input.attr("name"),name:$input.attr("name"),value:($input.attr("checked"))?1:0}).appendTo(H)})}}},beforeSubmit:function(L,K,J){var I=vBulletin.contentEntryBox.validateForm.apply(K,[J]);if(I===false){return false}var H=$("button, .b-button",K);K.one("ajaxStart",function(){H.attr("disabled","disabled");K.one("ajaxComplete",function(){H.removeAttr("disabled")})});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(){function B(G,J){var C=G.data("collapse-id"),E=$('.js-collapse__link[data-collapse-id="'+C+'"]'),D=$('.js-collapse__icon[data-collapse-id="'+C+'"]'),I=$('.js-collapse__body[data-collapse-id="'+C+'"]'),F=$().add(D).add(I),H=E.is(".js-collapse--collapsed")||D.is(".js-collapse--collapsed");if(J){H=!H}if(H){I.slideDown("fast");D.removeClass("b-icon__plus-circle").addClass("b-icon__minus-circle");F.removeClass("js-collapse--collapsed")}else{I.slideUp("fast");D.removeClass("b-icon__minus-circle").addClass("b-icon__plus-circle");F.addClass("js-collapse--collapsed")}}function A(C){B($(this))}$(".js-collapse__icon").each(function(C,D){B($(this),true)});$(".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)};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 I=[],G=null,B=null,J=null,D=591,A=null,K=function(M){var e=$(M);var V=J.parent();if(!A){A={originalPanelWidth:e.width(),originalDialogWidth:V.width(),scrollbarWidth:vBulletin.getScrollbarWidth(),originalPanelHeight:e.height(),originalDialogHeight:V.height()}}function Q(g,f,j){var i=g.first();var h=i.data("css-prop-restore-value_"+f);if(typeof h=="undefined"){i.data("css-prop-restore-value_"+f,i.css(f))}if(typeof j!="undefined"){g.css(f,j)}}function S(h,g){var f=h.first().data("css-prop-restore-value_"+g);if(typeof f!="undefined"){h.css(g,f)}}var b="margin"+pageData.textDirLeft.charAt(0).toUpperCase()+pageData.textDirLeft.slice(1);Q(V,"height");Q(e,"height");Q(V.find(".photoSelectorTabs"),"height");Q(V.find(".js-dialog-body"),"padding");Q(V.find(".photoSelectorTabs ul"),"width");Q(V.find(".photoSelectorTabs ul li"),"width");Q(V.find(".photoSelectorTabs .tabPanel"),"width");Q(V.find(".photo-item-wrapper"),"width");Q(V.find(".js-photo-counter"),b);var a=$(window).width();var W=(A.originalDialogWidth+A.scrollbarWidth>a);var T=A.originalPanelWidth;var R=A.originalDialogWidth;if(W){T-=200;R-=200}e.css({width:T});V.css({width:R});var N=(V.outerWidth()>a);if(!N){S(V,"height");S(e,"height");S(V.find(".photoSelectorTabs"),"height");S(V.find(".js-dialog-body"),"padding");S(V.find(".photoSelectorTabs ul"),"width");S(V.find(".photoSelectorTabs ul li"),"width");S(V.find(".photoSelectorTabs .tabPanel"),"width");S(V.find(".photo-item-wrapper"),"width");S(V.find(".js-photo-counter"),b);V.find(".photo-checkbox input").css(pageData.textDirLeft,"");V.find(".photo-checkbox input").css(pageData.textDirRight,"5px");V.find(".js-photo-counter").removeClass("h-margin-top-s")}e.css({width:T});V.css({width:R});var U=e.find(".photo-item-wrapper");var Y=U.first().outerHeight();var X;if(W){X=U.length;U.addClass("last-in-row")}else{X=Math.ceil(U.length/2);U.filter(":even").removeClass("last-in-row")}var c=X*Y;var d=(A.originalPanelHeight<c);if(d){T+=A.scrollbarWidth;R+=A.scrollbarWidth;e.css({width:T});V.css({width:R})}var P=$(window).height();var O=V.outerHeight();O=O>P?P:O;V.css({position:"absolute",left:"50%",top:"50%",marginLeft:"-"+(V.outerWidth()/2)+"px",marginTop:"-"+(O/2)+"px"});if(N){V.css({width:a+"px",left:0,top:0,marginLeft:0,marginTop:0,});var Z=(A.originalDialogHeight-A.originalPanelHeight)+c+60;Q(V,"height",Z+"px");Q(e,"height",c+"px");Q(V.find(".photoSelectorTabs"),"height",c+"px");Q(V.find(".js-dialog-body"),"padding",0);Q(V.find(".photoSelectorTabs ul"),"width","30%");Q(V.find(".photoSelectorTabs ul li"),"width","100%");Q(V.find(".photoSelectorTabs .tabPanel"),"width","70%");Q(V.find(".photo-item-wrapper"),"width","auto");Q(V.find(".js-photo-counter"),b,"12px");V.find(".photo-checkbox input").css(pageData.textDirRight,"");V.find(".photo-checkbox input").css(pageData.textDirLeft,"5px");V.find(".js-photo-counter").addClass("h-margin-top-s")}},E=function(M,N){K(N.panel)},H=function(O,Q){var N=$(Q.panel),P=$(".photo-item-wrapper .photo-item .filedataid",this),M=$(".js-photo-counter",$(this).parent());K(Q.panel);P.off("click").on("click",function(S){S.stopPropagation();var T=$(this).data("nodeid");if(this.checked){I.push(T);$(this).closest(".photo-item-wrapper").addClass("selected")}else{$(this).closest(".photo-item-wrapper").removeClass("selected");var R=$.inArray(T,I);if(R!=-1){I.splice(R,1)}}M.html(vBulletin.phrase.get("x_selected",I.length));$(".js-photo-selector-continue",J).prop("disabled",I.length==0)});$(".photo-item-wrapper",this).off("click").on("click",function(){var R=$(".photo-checkbox .filedataid",this);R.prop("checked",!R.prop("checked")).triggerHandler("click")});if(I.length>0){P.each(function(){if($.inArray($(this).data("nodeid"),I)!=-1){this.checked=true;$(this).closest(".photo-item-wrapper").addClass("selected")}});$(".js-photo-selector-continue",J).prop("disabled",false)}else{P.prop("checked",false);$(".photo-item-wrapper",this).removeClass("selected");$(".js-photo-selector-continue",J).prop("disabled",true)}M.html(vBulletin.phrase.get("x_selected",I.length));$(".tabPanel:not(:has(.photo-item-wrapper))",this).addClass("ui-tabs-hide")},F=function(M){var O=2;var P;var N=M.nodes;$(".photo-selector-tabs",G).html("");$.each(N,function(Q,R){if(R.nodeid!=-1){P=(R.nodeid==-2?0:R.nodeid);B.tabs("add",vBulletin.getAjaxBaseurl()+"/profile/get-photo-tab-content?nodeid="+P+"&ppr="+O,vBulletin.htmlEntities(R.title))}});J.dialog("open")},C=function(){B.tabs("destroy")},L=function(){$(document).data("gallery-container",$(this).closest(".b-content-entry-panel__content--gallery"));I=[];G=$(".js-photo-selector-wrapper .js-photo-selector-container");if(G.length==0){G=$(this).closest(".b-content-entry").find(".js-photo-selector-container")}B=$(".photo-selector-galleries",G);B.tabs({tabTemplate:'<li class="tab-item"><a href="#{href}"><span>#{label}</span></a></li>',panelTemplate:'<div class="tabPanel photo-display h-left"></div>',spinner:"<em>{0}&#8230;</em>".format(vBulletin.phrase.get("loading")),select:E,load:H,cache:true,ajaxOptions:{type:"POST"}});J=G.dialog({modal:true,width:D,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",close:C});vBulletin.AJAX({call:"/profile/get-photo-tabs",success:F})};$(document).off("click",".js-photo-selector-button").on("click",".js-photo-selector-button",L)};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");$(".photo-display-result, .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))}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,true)}D.data("prev-selected-panel","");D.find(".b-toolbar__item").removeClass("b-toolbar__item--active");vBulletin.contentEntryBox.changeFormToSelectedContentType(D.find(".b-toolbar"));vBulletin.ckeditor.resetEditor(E);D.find(".js-content-entry-title").val("");if(D.find(".js-button-group").data("hide-buttons-until-click")){D.find(".js-button-group").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()}if(typeof A=="function"){A.apply(C)}};vBulletin.contentEntryBox.isPanelEmpty=function(B){if(B.hasClass("b-content-entry-panel__content--gallery")){return !$.trim(B.find(".js-panel-content").html())}else{if(B.hasClass("b-content-entry-panel__content--link")||B.hasClass("b-content-entry-panel__content--video")){return !$.trim(B.find(".js-panel-content").html())&&!B.find(".b-link-input__url").val()}else{if(B.hasClass("b-content-entry-panel__content--poll")){var A=false;$(".b-poll-fieldset .b-form-input__input",B).each(function(){if($(this).val()){A=true;return false}});if(!A){$(".b-poll-fieldset .b-form-control__control",B).each(function(){if(this.defaultChecked!=this.checked){A=true;return false}})}return !A}else{if(B.hasClass("b-content-entry-panel__content--attachment")){return !(B.find(".js-attach-list .js-attach-item").length>1)}}}}return true};vBulletin.contentEntryBox.resetPanel=function(C){C.addClass("h-hide");if(C.hasClass("b-content-entry-panel__content--gallery")){C.find(".js-panel-content").empty();C.find(".b-button--upload .js-upload-label").text(vBulletin.phrase.get("upload"));C.find(".b-form-input__file--hidden").prop("disabled",true);C.find(".js-photo-postdata").empty();var A=vBulletin.upload.getUploadedPhotosDlg(false,C);$(".photo-display",A).empty()}else{if(C.hasClass("b-content-entry-panel__content--link")||C.hasClass("b-content-entry-panel__content--video")){C.find(".js-panel-content").empty();C.find(".b-link-input__url").val("").prop("disabled",true).parent().removeClass("h-hide")}else{if(C.hasClass("b-content-entry-panel__content--poll")){var B=C.find(".b-poll-fieldset__poll-answers li");if(B.length>3){B.filter(function(D){return D>=3}).remove()}C.find(".b-poll-fieldset input").each(function(){var D=this;if(D.type=="text"){D.value="";if($(D).hasClass("placeholder")){setTimeout(function(){$(D).focus().blur().prop("disabled",true)},10)}else{D.disabled=true}}else{if(D.type=="checkbox"){D.checked=D.defaultChecked;if($(D).hasClass("js-poll-timeout")){vBulletin.triggerHandler.apply(D,["click"])}}}})}else{if(C.hasClass("b-content-entry-panel__content--attachment")){C.find('.js-attach-list .js-attach-item:not(.h-hide) .js-attach-ctrl[data-action="remove"]').click()}else{if(C.hasClass("b-content-entry-panel__content--advanced-options")){C.removeClass("h-hide");C.find(".js-htmlstate").selectBox("value","off");if(C.find(".b-content-entry-panel__section--lite").length==0){C.find(".js-collapse__icon:not(.js-collapse--collapsed)").trigger("click")}else{C.find(".js-collapse__icon:not(.js-collapse--collapsed)").first().trigger("click")}}}}}}};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")){switch(A){case"b-content-entry-panel__content--gallery":if(B.closest(".edit-conversation-container").length==1){B.attr("action",vBulletin.getAjaxBaseurl()+"/uploader/save-gallery")}else{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}F.attr("placeholder",vBulletin.phrase.get("write_something_here_optional"));$(".b-editor__placeholder",B).text(vBulletin.phrase.get("write_something_here_optional"))}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({url:vBulletin.getAjaxBaseurl()+"/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.handlePanelCloseButton=function(B){var A=$(this).parent().data("class");if($(this).parent().is(".cke_top")){A="b-content-entry-panel__content--toggle-editor"}$(this).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)).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 m="",f="",c=pageData.baseurl+"/filedata/fetch?filedataid="+j,a=pageData.baseurl+"/filedata/fetch?filedataid="+j+"&thumb=1";var h=(W.match(/^(gif|jpg|jpeg|jpe|png|bmp)$/i)!==null);var o="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 l=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";l=P;A="n"+P;B.data("first-insert-id",A);if((g!="insert_image")&&(g!="insert_sigpic")&&!V){V="thumb"}if(V){var n={};n.attachmentid=P;n.size=V;vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/uploader/saveattachmentsetting",data:n,success:function(p){if(p.success){console.log("/uploader/saveattachmentsetting Success!")}},})}}}else{if(L){e=h;d=false}}}if(!h){if(P>0){A=P;l=A}else{if(B.data("tempid")){A=B.data("tempid");l=A}}}if(h){Z="setting["+A+"][size]";if(g=="insert_sigpic"){m=" [SIGPIC][/SIGPIC] ";f=m}else{if(g=="insert_image"){if(V=="icon"||V=="thumb"||V=="small"||V=="medium"||V=="large"||V=="full"){c+="&amp;type="+V}m=' <img class="bbcode-attachment" src="{0}" {1}="{2}" /> '.format(c,k,l);f=" [ATTACH=CONFIG]{0}[/ATTACH] ".format(A)}else{V="thumb";m=' <img class="thumbnail" src="{0}" {1}="{2}" /> '.format(a,k,l);f=" [ATTACH=CONFIG]{0}[/ATTACH] ".format(A)}}}else{if(g=="insert_sigpic"){m="";f=m}else{m=' <a class="bbcode-attachment" href="{0}" {1}="{2}" />'.format(c,k,l)+i+"</a> ";f=" [ATTACH]{0}[/ATTACH] ".format(A)}}if(d){B.find('input[type="hidden"][name="'+o+'"]').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:o}).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(m)}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 F=$(this),A=F.closest(".js-content-entry"),H=A.find("."+F.data("panel")),E=F.closest(".js-toolbar-primary").length==1,I=A.data("prev-selected-panel")||"";if(E){if(A.data("allow-type-text")=="0"){F.addClass("b-toolbar__item--unselectable");if(F.hasClass("b-toolbar__item--active")){return false}}if(!B){if((I.length&&I.is(":visible")&&!vBulletin.contentEntryBox.isPanelEmpty(I))||(H.is(":visible")&&!vBulletin.contentEntryBox.isPanelEmpty(H))){return vBulletin.contentEntryBox.openConfirmRemoveContentDialog(function(){if(I.length){vBulletin.contentEntryBox.resetPanel(I);I=""}else{vBulletin.contentEntryBox.resetPanel(H)}F.trigger("click",[true])})}}$(".js-toolbar-primary .b-toolbar__item",A).removeClass(function(){if(this==F.get(0)){$(this).toggleClass("b-toolbar__item--active");return""}return"b-toolbar__item--active b-toolbar__item--unselectable"});if(I.length&&I.is(":visible")){vBulletin.contentEntryBox.resetPanel(I);I=""}if(F.hasClass("b-toolbar__item--active")){vBulletin.contentEntryBox.enablePanelFields(H);vBulletin.contentEntryBox.showPanel(H);I=H}else{vBulletin.contentEntryBox.resetPanel(H);I=""}vBulletin.contentEntryBox.changeFormToSelectedContentType(F);A.data("prev-selected-panel",I)}else{if(!B&&F.data("panel")=="b-content-entry-panel__content--attachment"&&H.is(":visible")&&!vBulletin.contentEntryBox.isPanelEmpty(H)){return vBulletin.contentEntryBox.openConfirmRemoveContentDialog(function(){vBulletin.contentEntryBox.resetPanel(H);F.trigger("click",[true])})}F.toggleClass("b-toolbar__item--active");if(F.data("panel")=="b-content-entry-panel__content--toggle-editor"){vBulletin.contentEntryBox.toggleAdvancedEditor(F)}else{H.toggleClass("h-hide",!F.hasClass("b-toolbar__item--active"))}}vBulletin.contentEntryBox.afterPanelChange(A);var G=A.find(".js-human-verification"),C=G.find(".imagereg");A.find(".js-button-group").removeClass("h-hide");G.removeClass("h-hide");if(C.height()!=C.attr("height")){G.find(".refresh_imagereg").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 B=$(".js-content-entry").not(".js-content-entry-basic");isCkeditorCompatible=vBulletin.ckeditor.checkEnvironment();if(B.length>0){$("form",B).each(function(){var D=$(this),E=D.find(".js-editor"),C=vBulletin.ckeditor.getEditorContent(E);D.trigger("reset");if(C){if(vBulletin.ckeditor.editorExists(E)){vBulletin.ckeditor.getEditor(E).setData(C)}else{E.val(C)}}});vBulletin.contentEntryBox.initAjaxFormSubmit();vBulletin.contentEntryBox.initPhotoGallery();vBulletin.contentEntryBox.initVideoEditPane();vBulletin.contentEntryBox.initAutofillFromTitle(B);vBulletin.contentEntryBox.initCollapse();$(document).off("click",".js-content-entry-save-draft").on("click",".js-content-entry-save-draft",vBulletin.contentEntryBox.handleButtonSaveDraft);$(document).off("click",".js-content-entry-preview").on("click",".js-content-entry-preview",vBulletin.contentEntryBox.handleButtonPreview);$(document).off("keydown",".js-content-entry .b-link-input__url").on("keydown",".js-content-entry .b-link-input__url",vBulletin.contentEntryBox.handleLinkInputKeypress);$(document).off("focus",".js-content-entry .js-editor").on("focus",".js-content-entry .js-editor",function(){var C=$(this).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()}});vBulletin.contentEntryBox.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(C,D){vBulletin.contentEntryBox.disable_bbcode=D})}$(document).off("click",".js-content-entry-delete").on("click",".js-content-entry-delete",vBulletin.contentEntryBox.handleButtonDelete);$(document).off("click",".js-content-entry-cancel").on("click",".js-content-entry-cancel",vBulletin.contentEntryBox.handleButtonCancel);$(document).off("click",".b-content-entry .b-toolbar__item").on("click",".b-content-entry .b-toolbar__item",vBulletin.contentEntryBox.handleToolbarButtons);$(document).off("click",".js-content-entry .js-contententry-panel-x").on("click",".js-content-entry .js-contententry-panel-x",vBulletin.contentEntryBox.handlePanelCloseButton);if(isCkeditorCompatible){$(document).off("click",".js-smilie-container .js-toggle-more-smilies").on("click",".js-smilie-container .js-toggle-more-smilies",vBulletin.contentEntryBox.toggleMoreSmilies);$(document).off("click",".js-smilie-container .js-smilie-button").on("click",".js-smilie-container .js-smilie-button",vBulletin.contentEntryBox.insertSmilie)}$(document).off("click",".js-content-entry .js-attach-ctrl").on("click",".js-content-entry .js-attach-ctrl",vBulletin.contentEntryBox.handleAttachmentControls);B.each(function(){vBulletin.contentEntryBox.setDefaultTab(this)});if($(".js-facebook-publish").length){var A=function(){vBfb.has_permission("publish_actions",function(C){if(!C){$(".js-facebook-publishcb").prop("disabled",true);$(".js-facebook-needpublish").removeClass("h-hide")}$(".js-facebook-publish").removeClass("h-hide")})};if(typeof vBfb!="undefined"){A()}$(document).on("facebookinitialized",A);$(document).off("click",".js-facebook-needpublish").on("click",".js-facebook-needpublish",function(C){vBfb.request_permission("publish_actions",function(D){if(D){$(".js-facebook-publishcb").prop("disabled",false);$(".js-facebook-needpublish").addClass("h-hide")}});return false})}console.log("vBulletin.contentEntryBox.init finish")};vBulletin.contentEntryBox.init();(function(A){A(document).off("click",".additional_options_toggle").on("click",".additional_options_toggle",function(){A(this).siblings(".additional_options_content").toggle()});if(typeof pageData.pageView!="undefined"&&pageData.pageView=="thread"){vBulletin.conversation.replyWithQuotes.showAddWithQuotesButton()}})(jQuery);