/*=======================================================================*\
|| ###################################################################### ||
|| # 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,["add_folder","are_you_sure_move_to_trash","are_you_sure_permanently_delete_messages","delete_folder","edit_folder","error","error_deleting_folder","error_editing_folder","error_x","folder_name","follow_request_denied","invalid_node_id","messages_updated_desc","need_folder_name","no_moderate_permissions","no_publish_permissions","page_does_not_exist","pending_posts","delete_pending_posts","please_enter_a_valid_page_number","please_select_messages","pm_ajax_error_desc","selected_folder_and_contents_will_be_deleted","sent_follow_request","private_messages","mark_message_status_text_for_move","mark_messages_status_text_for_move","mark_message_status_text_for_delete","mark_messages_status_text_for_delete","mark_message_status_text_for_read","mark_messages_status_text_for_read","mark_message_status_text_for_unread","mark_messages_status_text_for_unread","mark_message_status_text_generic","mark_messages_status_text_generic","mark_report_status_text_for_delete","mark_reports_status_text_for_delete","mark_report_status_text_for_open","mark_reports_status_text_for_open","mark_report_status_text_for_closed","mark_reports_status_text_for_closed","mark_report_status_text_generic","mark_reports_status_text_generic","messages_header","following","following_pending","follow","members_in_this_message","all_changes_made_will_be_lost_would_you_like_to_continue","cancel","need_privatemessage_text","invalid_pm_recipients"]);var $pmWidget;(function(F){window.vBulletin=window.vBulletin||{};window.vBulletin.privateMessage=window.vBulletin.privateMessage||{};var E=vBulletin.history.instance(true),C=getNotificationsFilterParams(),I={};if(Object.keys(C).length>0){I.notificationFilterParams=C}E.setDefaultState(I,document.title,window.location.href);E.setStateChange(function(L){var J=E.getState();if(J.data.hasOwnProperty("notificationFilterParams")){var K=J.data.notificationFilterParams;G(K);H(K.page,true)}},"privatemessage");window.vBulletin.privateMessage.pmFilterHistory=E;vBulletin.privateMessage.updatePaginationLinks=function(S,a,M){var J=S.find(".js-pagenav");if(J.length>0){var N=J.find(".js-pagenav-button:not(.js-pagenav-button--template)"),X=J.find(".js-pagenav-next-button"),W=J.find(".js-pagenav-prev-button"),Q=J.find(".js-pagenav-button--template"),P=/\/(\d+)\/?$/,b=0,U="",L="",Y="",K={},Z=a-2,T=a+2,R=F("#maxPageNum").val();if(Q.attr("href")==""&&J.data("baseurl")!=""){Q.attr("href",J.data("baseurl"))}Y=Q.attr("href");K=D(a,Y);Q.attr("href",K.newHrefBase);L=K.queryString;if(Z<1){Z=1}T=Z+4;if(T>R){T=R}N.not(".js-pagenav-next-button, .js-pagenav-prev-button").remove();for(var V=Z;V<=T;V++){U=Q.attr("href").replace(P,"/"+V)+L;var O=Q.clone().removeClass("js-pagenav-button--template h-hide-imp").attr("data-page",V).text(V).attr("href",U);if(V==a){O.removeClass("b-button--secondary").addClass("b-button--primary")}O.insertBefore(X);F(document.createTextNode("\n")).insertBefore(X)}b=parseInt(a,10)-1;b=b>1?b:1;W.data("page",b);U=Q.attr("href").replace(P,"/"+b)+L;W.attr("href",U);b=parseInt(a,10)+1;b=b<=R?b:R;X.data("page",b);U=Q.attr("href").replace(P,"/"+b)+L;X.attr("href",U);W.add(X).removeClass("h-hide h-hide-imp");if(a==1){W.addClass("h-hide-imp")}if(a==R){X.addClass("h-hide-imp")}if(typeof (M)!="undefined"){var c=(M>1);J.closest(".pagenav-container").toggleClass("h-hide",!c);J.closest(".js-pagenav-wrapper").toggleClass("h-hide",!c)}}};function G(J){F.each(["readFilter","sortDir","typename"],function(K,M){var L="filter_"+M;if(J.hasOwnProperty(L)){J[M]=J[L];delete J[L]}});if(!J.hasOwnProperty("readFilter")){J.readFilter="unread_only"}if(!J.hasOwnProperty("sortDir")){J.sortDir="DESC"}if(!J.hasOwnProperty("typename")){J.typename=""}F("#notificationFilters").find("input:radio").each(function(K,M){var N=F(this),L=N.attr("name");if(J.hasOwnProperty(L)&&J[L]==N.val()){N.attr("checked","checked")}})}function A(J){F(this).closest(".filter-options").find(":input[type=radio]").removeAttr("checked");F(this).attr("checked","checked");H(1)}function H(J,L){J=J||1;L=L||false;var K=getNotificationsFilterParams();K.page=J;vBulletin.AJAX({call:"/ajax/render/privatemessage_notificationcontent",data:{params:K,isAjaxTemplateRenderWithData:true,},success:function(M){F("#notificationContent").html(M.template);pmPageNum=J;F("#notificationPageto").val(pmPageNum);F("#iconNotificationNext").toggleClass("h-disabled",(J>=pmPages));F("#iconNotificationPrevious").toggleClass("h-disabled",(J<=1));if(E.isEnabled()&&!L){var P=D(pmPageNum),O={notificationFilterParams:K,};E.pushState(O,document.title,P.url)}var N={folderid:folderid,page:pmPageNum,perpage:pmPerPage,about:"",filterParams:K};vBulletin.privateMessage.updatePaginationLinks(F("#notificationContent").parent(),F("#notificationPageto").val());vBulletin.AJAX({call:"/ajax/api/content_privatemessage/getFolderMsgCount",data:N,success:function(Q){if(Q&&Q.pages>0){if(E.isEnabled()&&!L&&pmPageNum!=Q.pagenum){var S=D(Q.pagenum),R={notificationFilterParams:K,};E.setDefaultState(R,document.title,S.url)}pmPageNum=Q.pagenum;pmPages=Q.pages;pmNotificationCount=Q.count;F("#notificationPageCount").html(pmPages);F("#maxPageNum").val(pmPages);F("#iconNotificationNext").toggleClass("h-disabled",!(pmPages>1));F("#privatemessagePaging").toggleClass("h-hide",(pmPages<=1));F("#notificationPageto").val(pmPageNum);F("#iconNotificationPrevious").toggleClass("h-disabled",(pmPageNum<=1));F("#iconNotificationNext").toggleClass("h-disabled",(pmPageNum>=pmPages));vBulletin.privateMessage.updatePaginationLinks(F("#notificationContent").parent(),pmPageNum,pmPages)}}})}})}vBulletin.privateMessage.getPageFiltersForUrl=function(J){return J};function D(J,O){var S={},Q="",M=/\/(\d+)\/?$/,N={};if(typeof O=="undefined"){O=window.location.href}Q=O;N=vBulletin.parseUrl(O);if(N.search.length>1){var P=N.search.substr(1).split("&");for(var K=0;K<P.length;K++){var R=P[K].split("=");if(R.length>1){S[R[0]]=R[1]}}Q=window.location.protocol+"//"+N.hostname;if(N.port.length>0){Q+=":"+N.port+N.pathname}else{Q+=N.pathname}}Q=Q.replace(M,"/"+J);if(F("#notificationFilters").length){var L=getNotificationsFilterParams();F.each(["readFilter","sortDir","typename"],function(T,U){if(L.hasOwnProperty(U)){S["filter_"+U]=L[U]}})}S=vBulletin.privateMessage.getPageFiltersForUrl(S);queryString="?"+F.param(S);return{newHrefBase:Q,queryString:queryString,hash:N.hash,url:Q+queryString+N.hash,}}vBulletin.privateMessage.getPrivateMessageUrl=D;function B(L){var J=L.target.id.substring(15);J=parseInt(J);if(!isNaN(J)){var M=(typeof messageDetailPage!="undefined"&&messageDetailPage)?0:1,K="";if(F(L.target).hasClass("rate")){M=1;K="rate"}vBulletin.AJAX({call:"/ajax/render/privatemessage_participants",data:{nodeid:J,showFollowButtons:M,notificationType:K,isAjaxTemplateRenderWithData:true,},success:function(N){F("#pmInfoContent").html(N.template);F(".pmBtnFollowRequest").off("click").on("click",sendFollowRequest);F("#pmInfoDialog").dialog({title:vBulletin.phrase.get("members_in_this_message"),autoOpen:false,modal:true,resizable:false,closeOnEscape:true,showCloseButton:true,width:500,dialogClass:"dialog-container member-list-dialog-container dialog-box"}).dialog("open")},error_phrase:"pm_ajax_error_desc",})}}F(document).ready(function(){$pmWidget=F(".private-message-widget");var M=F(".js-pm-content-entry-container"),R=F(".js-editor",M);F(document).off("focus",".js-editor.js-focus-on-page-load").on("focus",".ckeditor-bare-box.ckeditor-load-on-focus",function(){vBulletin.ckeditor.initEditor(F(this).attr("id"),{error:function(Y){F("#"+Y).prop("disabled",false).removeClass("ckeditor-load-on-focus").closest(".js-pm-content-entry-container").addClass("no-ckeditor")}})});if(R.length>0&&(M.hasClass("msg-type-new")||M.hasClass("msg-type-forward"))){vBulletin.ckeditor.initEditor(R.attr("id"),{success:function(Y){var Z=R.prev(".js-editor-parsed-text");if(Z.length>0){this.setData(Z.html())}setTimeout(function(){F(".autocompleteHelper",M)[0].focus()},200)},error:function(Y){F("#"+Y).prop("disabled",false).removeClass("ckeditor-load-on-focus").closest(".js-pm-content-entry-container").addClass("no-ckeditor")}})}F(".folder-list.custom-folder-list form",$pmWidget).trigger("reset");$pmWidget.off("click",".folder-item.custom-folder .edit-icon-wrapper").on("click",".folder-item.custom-folder .edit-icon-wrapper",function(a){a.stopPropagation();var Y=F(this).closest(".custom-folder").addClass("edit-folder-mode");var Z=Y.find(".edit-folder-box").select().focus();Z.val(vBulletin.htmlEntities_decode(Z.val()));Z.data({origFolderName:Z.val(),updateFlag:true});V(true);return false});var S;$pmWidget.off("keydown blur",".folder-item.custom-folder .edit-folder-box").on("keydown",".folder-item.custom-folder .edit-folder-box",function(a){var Z=F(this),Y=false;switch(a.which){case 27:Z.data("updateFlag",false);Z.closest(".custom-folder").removeClass("edit-folder-mode");V(false);Z.val(Z.data("origFolderName"));Y=true;break;case 13:Z.data("updateFlag",true);Z.trigger("blur",[true]);Y=true;break;default:}return !Y}).on("blur",".folder-item.custom-folder .edit-folder-box",function(b,Y){var Z=F(this);var a=function(){if(!Z.data("updateFlag")){return false}Z.data("updateFlag",false);if(!isFolderNameValid(Z,"edit_folder")){Z.data("updateFlag",true);return false}V(false);var d=Z.closest(".custom-folder"),e=Z.val().trim(),c=Z.data("origFolderName");if(e!=c){vBulletin.AJAX({call:"/ajax/api/content_privatemessage/updateFolderTitle",data:{folderName:e,folderid:Z.data("nodeId")},success:function(f){d.find(".label").text(e);T(d.detach(),$pmWidget);Q(folderid,e)},title_phrase:"edit_folder",error_phrase:"error_editing_folder",complete:function(){d.removeClass("edit-folder-mode")},after_error:function(){Z.val(c)}})}else{d.removeClass("edit-folder-mode")}};if(!Y){S=setTimeout(a,200)}else{a()}});$pmWidget.off("click",".folder-item.custom-folder .delete-icon").on("click",".folder-item.custom-folder .delete-icon",function(a,Y){clearTimeout(S);a.stopPropagation();var b=F(this),Z=b.prev(".edit-folder-box");if(!Y){openConfirmDialog({title:vBulletin.phrase.get("delete_folder"),message:vBulletin.phrase.get("selected_folder_and_contents_will_be_deleted"),iconType:"warning",onClickYes:function(){b.trigger("click",[true])},onClickNo:function(){Z.select().focus()}});return false}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/deleteFolder",data:{folderid:Z.attr("data-node-id")},success:function(c){V(false);var e=b.closest(".custom-folder"),d=e.find("a").hasClass("selected");e.remove();if(d){location.href=F(".nav-pane .folder-list .folder-item.messages a",$pmWidget).attr("href")}},title_phrase:"delete_folder",error_phrase:"error_deleting_folder",})});$pmWidget.off("click",".folder-list .folder-item > a[href]").on("click",".folder-list .folder-item > a[href]",function(a){var Y=F(".folder-list .custom-folder.edit-folder-mode",$pmWidget);if(Y.length>0){Y.trigger("blur",[true]);return false}var b=F(this),Z=b.parent();if(Z.hasClass("edit-folder-mode")||(!Z.hasClass("special-folder")&&b.hasClass("selected"))){return false}if(!Z.hasClass("add-folder")){F(".folder-list .folder-item > a.selected",$pmWidget).removeClass("selected");b.addClass("selected")}return true});$pmWidget.off("click",".folder-list .folder-item.add-folder > a[href]").on("click",".folder-list .folder-item.add-folder > a[href]",function(Y){createNewFolder.apply(this,[Y,function(a,d){var c=F(".folder-item.custom-folder.template",$pmWidget).clone(true).removeClass("h-hide template"),b=c.find("a"),Z=c.find(".label").text(d);b.attr("href",b.attr("href").replace(/\/list\/0\//i,"/list/"+a+"/"));c.find(".edit-folder-box").attr("data-node-id",a).val(d);T(c,$pmWidget);Q(a,d)},function(){F(this).removeClass("selected")}]);return false});function T(d,a){var b=false,c=d.find(".edit-folder-box").val().toLowerCase(),Z=F(".folder-list.custom-folder-list"),Y;Z.find(".folder-item",a).each(function(){Y=F(this);if(c<Y.find(".label").text().toLowerCase()){Y.before(d);b=true;return false}});if(!b){Z.append(d)}}function Q(b,c){var a=false,Z=F("folder_"+b),Y;c=vBulletin.htmlEntities(c);if(Z.length){Z.find("span").html(c);Z.parent().detach()}else{Z=F('<li class="pmMoveToFolder" id="folder_'+b+'"><span>'+c+"</span></li>")}c=c.toLowerCase();F("#pmMoveToFolder li.pmMoveToFolder").each(function(d){Y=F(this);if(d>0&&c<Y.html().trim().toLowerCase()){Y.before(Z);a=true;return false}});if(!a&&Y){Y.after(Z)}}function V(a){var Z,Y;if(a){Z="data-href";Y="href"}else{Z="href";Y="data-href"}F(".folder-list .folder-item a",$pmWidget).each(function(){var b=F(this);var c={};c[Z]=b.attr(Y);b.attr(c).removeAttr(Y)})}function K(Y){return U(Y.postId,Y.postContentTypeId,Y.currentPosition,Y.maxPosition,Y.userId,Y.postType)}function U(Y,Z,c,d,a,e){var b={nodeid:Y,contenttypeid:Z,currentPosition:c,maxPosition:d,};F.each(b,function(g,f){b[g]=parseInt(f,10)});a=parseInt(a,10);if(F.map(b,isNaN).some(Boolean)||isNaN(a)){return false}b.postType=e;b.isAjaxTemplateRenderWithData=true;vBulletin.AJAX({call:"/ajax/render/privatemessage_pendingpost_overlay",type:"POST",data:b,success:function(f){F(".pending-post-overlay").html(f.template).dialog({title:vBulletin.phrase.get("pending_posts"),modal:true,resizable:false,closeOnEscape:false,showCloseButton:false,width:700,dialogClass:"dialog-container pending-post-overlay-container dialog-box",}).dialog("open");var i=F(".pending-post-overlay-container"),h=i.find(".ui-dialog-titlebar");h.find(".nav-buttons").remove();var g=i.find(".pending-post-overlay .nav-buttons").detach();h.append(g);F(".pending-post-overlay .list-item").data("user-id",a).data("post-type",e).prepend(F(".pending-posts-container .list-container .list-item[data-node-id={0}] .list-item-header".format(b.nodeid)).clone());vBulletin.ckeditor.initEditor("ckeditor-bare",{success:function(k,j){if(!j){j=vBulletin.ckeditor.getEditor(k)}j.setData(F(".pending-post-overlay .list-item .ckeditor-bare-box").html())}})},error_phrase:"unable_to_contact_server_please_try_again"})}function O(d,b){var h=parseInt(d.data("nodeId"),10),Z=parseInt(d.data("userId"),10),Y=d.data("postType");b=parseInt(b,10);if(isNaN(h)||isNaN(b)){return false}var c=-1,a=0;F(".conversation-list .list-item",$pmWidget).filter(function(i){a++;if(F(this).attr("data-node-id")==h){c=i;return true}});if(c==-1){return false}c=c+b;var e=F(".conversation-list .list-item",$pmWidget).filter(function(i){if(c==i){return true}});if(e.length>0){var f=parseInt(e.attr("data-node-id"),10),g=parseInt(e.attr("data-node-contenttype-id"));Z=e.data("userId");Y=e.data("postType");c++;return{postId:f,postContentTypeId:g,currentPosition:c,maxPosition:a,userId:Z,postType:Y}}else{return false}}function N(Y,c,h){if(!Y){Y=F("#private-message-toolbar .pending-posts-paginator .pendingpostsPageTo");if(Y.length==0){return false}}if(!h){h=0}var e=Y.closest(".pending-posts-paginator"),g=e.find("#maxPageNum").filter("input[type=hidden]"),a=e.find("input[name=pagenum]"),b=g.val(),d=parseInt(a.val(),10),f=parseInt(e.find("input[name=per-page]").val(),10),i=e.find("input[name=routeInfoJson]").val();c=parseInt(c,10);if(isNaN(c)||isNaN(b)||isNaN(d)){return false}if((c<1)||(c>b)){vBulletin.error("error","please_enter_a_valid_page_number");return false}if((c==d)&&!h){return false}var Z={setCurrentPage:c,setPerPage:f,getPagingInfo:h,options:{},routeInfoJson:i,isAjaxTemplateRenderWithData:true,};F("#pendingFilters input:checked").each(function(){Z.options[this.name]=this.value});vBulletin.AJAX({call:"/ajax/render/privatemessage_pendingpost_main",data:Z,success:function(m){F("#privateMessageContainer .main-pane .pending-posts-container").html(m.template);var l=c-1,k=0;if(c<b){k=c+1}a.val(c);e.find("input[name=next-page]").val(k);e.find("input[name=prev-page]").val(l);e.find(".pendingpostsNext").toggleClass("h-disabled",!k);e.find(".pendingpostsPrev").toggleClass("h-disabled",!l);e.find(".pendingpostsPageTo").val(c);if(h){var n=F("#privateMessageContainer .main-pane .pending-posts-container .pending-posts-pageinfo"),j=parseInt(n.find(".totalpages").val(),10);g.val(j);e.find("div.pendingpostsPageCount").text(j);F(".folder-list .folder-item.pending-posts .count",$pmWidget).text(j)}},error_phrase:"unable_to_contact_server_please_try_again"})}F("#pmBtnMarkRead").off("click").on("click",function(){markMessages(F(this).text(),"setRead","read",1,false)});F("#pmBtnMarkUnRead").off("click").on("click",function(){markMessages(F(this).text(),"setRead","read",0,false)});F("#pmBtnDelete").off("click").on("click",function(a){var Y=(typeof (messageDetailPage)!="undefined"&&messageDetailPage),Z=getSelectedMessages(),b=F(this).text();if(Z.length>0){openConfirmDialog({title:vBulletin.phrase.get("messages_header"),message:vBulletin.phrase.get("are_you_sure_move_to_trash"),iconType:"warning",onClickYes:function(){markMessages(b,"toTrashcan",false,false,Y,Z)}})}});F(".pmBtnDeletePermanently").off("click").on("click",function(Z){var Y=getSelectedMessages(),a=F(this).text();if(Y.length>0){openConfirmDialog({title:vBulletin.phrase.get("messages_header"),message:vBulletin.phrase.get("are_you_sure_permanently_delete_messages"),iconType:"warning",onClickYes:function(){markMessages(a,"deleteMessages",false,false,false,Y)}})}});F(".pmBtnUndelete").off("click").on("click",function(Y){markMessages(F(this).text(),"undeleteMessage",false,false,false)});F("#reportBtnMarkOpen").off("click").on("click",function(Y){markReports(F(this).text(),"openClose","op","open")});F("#reportBtnMarkClosed").off("click").on("click",function(Y){markReports(F(this).text(),"openClose","op","closed")});F("#reportBtnDelete").off("click").on("click",function(Y){markReports(F(this).text(),"bulkdelete",false,false)});$pmWidget.off("click",".split-button .move-button-set button").on("click",".split-button .move-button-set button",startMove);F("#pmBtnForward").off("click").on("click",startForward);F("#pmInfoClose").off("click").on("click",function(Y){F("#pmInfoDialog").dialog("close")});F("#privatemessagePageto, #sentItemsPageTo").bind("keydown blur",gotoPage);F(".btnPmCancel").off("click").on("click",function(){openConfirmDialog({title:vBulletin.phrase.get("cancel"),message:vBulletin.phrase.get("all_changes_made_will_be_lost_would_you_like_to_continue"),iconType:"warning",onClickYes:function(){history.back()}})});F(".pmRequestAccept").off("click").on("click",acceptRequest);F(".pmRequestDeny").off("click").on("click",denyRequest);F("#pmBtnReply").off("click").on("click",function(){var a=F(".js-pm-content-entry-container .js-editor"),Z=a.attr("id"),Y=vBulletin.ckeditor.editorExists(Z)?vBulletin.ckeditor.getEditor(Z):null;F("body,html").animate({scrollTop:F(".js-pm-content-entry-container").offset().top},"slow",function(){(Y||a[0]||F()).focus()})});F("#pmFloatingBarContent .toolbar-filter").off("click").bind("click",function(Z){var Y=F(this),a=F(".filter-wrapper",Y).toggleClass("selected");F(".arrow .vb-icon",Y).toggleClass("vb-icon-triangle-down-wide vb-icon-triangle-up-wide");Y.closest(".toolbar-wrapper").find(".toolbar-filter-overlay").slideToggle("slow",function(){var b="pm_filter",d=this;if(F(d).is(":visible")){F("body").off("click."+b).bind("click."+b,function(f){if(F(f.target).closest(".toolbar-filter-overlay").length==0&&F(f.target).closest(".toolbar-filter").length==0){F("body").off("click."+b);Y.triggerHandler("click")}});var c={};if(!vBulletin.isScrolledIntoView(d,c)){F("html,body").animate({scrollTop:"+="+Math.abs(c.bottom)},"fast")}}else{F("body").off("click."+b)}})});F(".list-controls .select-all").off("click").on("click",function(Y){F(".privateMessageActionCheck").prop("checked",true)});F(".list-controls .select-none").off("click").on("click",function(Y){F(".privateMessageActionCheck").prop("checked",false)});if(typeof messageDetailPage!="undefined"&&messageDetailPage){F("#pmBtnBackToMessage").off("click").on("click",function(Z){if(pmParentFolderId){location.href="{0}/privatemessage/list/{1}/1".format(pageData.baseurl,pmParentFolderId)}else{var Y=F(".nav-pane .folder-list .folder-item.special-folder.messages a").attr("href");location.href=Y}})}function J(Y){H(Y)}F("#notificationFilters").trigger("reset").find(".filter-options input").off("click").on("click",A);F("#pmBtnNotificationDismissAll").off("click").on("click",dismissNotifications);F("#pmBtnNotificationDismissPage").off("click").on("click",dismissNotifications);F("#iconNotificationNext").off("click").on("click",function(Y){Y.preventDefault();pmPageNum=parseInt(pmPageNum);if(pmPageNum<pmPages){J(pmPageNum+1)}});F("#iconNotificationPrevious").off("click").on("click",function(Y){Y.preventDefault();pmPageNum=parseInt(pmPageNum);if(pmPageNum>1){J(pmPageNum-1)}});F("#notificationContent").on("click",".js-notification-dismiss",dismissSingleNotification);F("#notificationContent").on("click",".js-notification-others-dialog",toggleOthersDialog);if(F("#notificationContent").length==0){F("ul.pm-notification-list").on("click",".js-notification-dismiss",dismissSingleNotification);F("ul.pm-notification-list").on("click",".js-notification-others-dialog",toggleOthersDialog)}F("#notificationPageto").bind("keydown blur",function(Z){var a=F(this);if(Z.type=="blur"||(Z.type=="keydown"&&Z.keyCode==13)){var Y=Number(a.val());if(!isNaN(Y)&&Y!=pmPageNum&&Y>0&&Y<=pmPages){J(Y)}else{a.val(pmPageNum)}return false}return true});searchAuthorAutocomplete=new vBulletin_Autocomplete(F(".privatemessage_author"),{apiClass:"user"});F(document).off("click",".pmNotifDlgLink").on("click",".pmNotifDlgLink",B);F("#pmSearch").submit(function(){var a=F(this),Z=a.find("[name=searchJSON]"),b=a.find("[name=q]"),Y={};Y.keywords=b.val();Y.type="vBForum_PrivateMessage";Y.ignore_protected=0;Z.val(JSON.stringify(Y));return(b.val().length>3)});var L=false;F(document).off("click",".view-post").on("click",".view-post",function(){var a=F(this),f=F(this).closest(".list-item"),Z=parseInt(f.data("nodeId"),10),e=parseInt(f.data("nodeContenttypeId"),10),b=parseInt(f.data("userId"),10),d=f.data("postType"),c=F("ul.conversation-list li.list-item",$pmWidget).index(f)+1,Y=f.closest("ul.conversation-list").find("li.list-item").length;L=false;U(Z,e,c,Y,b,d)});function W(Z){var Y;if(F(".pending-post-overlay:visible").length){Y=O(Z,1);if(!Y){Y=O(Z,-1)}}if(Y){K(Y)}else{F(".pending-post-close").trigger("click")}}function X(Y){F(Y).each(function(){F(".pending-posts-container .list-container .list-item[data-node-id={0}]".format(this)).remove()})}F(document).off("click",".pending-post-approve").on("click",".pending-post-approve",function(){var a=[],f,e=F(this),c=e.closest(".pending-post-overlay").find("li.list-item");if(c.length==0){c=e.closest("li.list-item")}if(c.length!=0){a.push(parseInt(c.data("nodeId"),10));f=c.data("postType")}else{if(e.closest("#pmFloatingBarContent").length){F(".pending-posts-container .list-item .privateMessageActionCheck:checked").each(function(){c=F(this).closest("li.list-item");a.push(parseInt(c.data("nodeId"),10))});if(a.length==0){return false}f="selected_posts"}else{return false}}var d={nodeid:a,approved:1,data:{}},b=F(".title-field",c),Z=F(".text-field",c),Y=F(".notes-field",c);if(b.length){d.data["title"]=b.val()}if(Z.length){d.data["rawtext"]=Z.val()}if(Y.length){d.data["reason"]=Y.val()}vBulletin.AJAX({call:"/ajax/api/node/setApprovedPost",data:d,error_phrase:"unable_to_contact_server_please_try_again",success:function(g){L=true;W(c);X(g)}})});F(document).off("click",".pending-post-delete").on("click",".pending-post-delete",function(){var Z=[],d,b=[],c=F(this);var a=c.closest(".pending-post-overlay").find("li.list-item");if(a.length==0){a=c.closest("li.list-item")}if(a.length!=0){Z.push(parseInt(a.data("nodeId"),10));d=a.data("postType");b.push(parseInt(a.data("userId"),10))}else{if(c.closest("#pmFloatingBarContent").length){F(".pending-posts-container .list-item .privateMessageActionCheck:checked").each(function(){a=F(this).closest("li.list-item");Z.push(parseInt(a.data("nodeId"),10));b.push(parseInt(a.data("userId"),10))});if(Z.length==0||b.lenght==0){return false}d="selected_posts"}else{return false}}var Y=vBulletin.phrase.get("delete_x",vBulletin.phrase.get("posttype_"+d));vBulletin.inlinemod.delete_dialog(Z,function(e){L=true;W(a);X(e)})});function P(a){var Y=F(this).closest(".pending-post-overlay-container").find(".pending-post-overlay li.list-item"),Z=O(Y,a);if($elementInfo!==false){F("pending-post-overlay").dialog("close");K(Z)}}F(document).off("click",".pending-post-next").on("click",".pending-post-next",function(){P(1)});F(document).off("click",".pending-post-previous").on("click",".pending-post-previous",function(){P(-1)});F(document).off("click",".pending-post-close").on("click",".pending-post-close",function(){F(".pending-post-overlay").dialog("close");if(L){N(false,1,true)}});F(document).off("click",".pending-posts-paginator .pendingpostsPrev").on("click",".pending-posts-paginator .pendingpostsPrev",function(Z){Z.preventDefault();var Y=F(this).closest(".pending-posts-paginator").find(':input[type=hidden][name="prev-page"]').val();N(F(this),Y)});F(document).off("click",".pending-posts-paginator .pendingpostsNext").on("click",".pending-posts-paginator .pendingpostsNext",function(Z){Z.preventDefault();var Y=F(this).closest(".pending-posts-paginator").find(':input[type=hidden][name="next-page"]').val();N(F(this),Y)});F(document).off("keypress",".pending-posts-paginator .pendingpostsPageTo").on("keypress",".pending-posts-paginator .pendingpostsPageTo",function(Z){if(Z.keyCode==13){Z.preventDefault();var a=F(this),Y=parseInt(a.val(),10);if(isNaN(Y)){vBulletin.error("error","please_enter_a_valid_page_number");return false}N(a,Y)}});$pmWidget.filter(".private-message-toolbar").off("click",".message-filters .filter-options :input[type=radio]").on("click",".message-filters .filter-options :input[type=radio]",function(Z){var Y=F(this).closest("form.toolbar-filter-overlay");Y.attr("action",(Y.attr("action")+"?sortDir="+F(this).val()));Y.submit()});F("#pendingFilters").trigger("reset").find(".filter-options input").off("click").on("click",pendingFilter);vBulletin.truncatePostContent(F(".pm-message-list"));vBulletin.privateMessage.jsReady=true;F(document).trigger("vb-privatemessage-js-ready")})})(jQuery);isFolderNameValid=function(D,B,E){var C,G=$.trim(D.val()).toLowerCase();if(G==""){C="error_enter_folder"}else{if(G.length>50){C="error_foldername_maxlength"}else{$(".folder-list.custom-folder-list .folder-item .edit-folder-box",$pmWidget).each(function(){if(D.hasClass("edit-folder-box")&&D.get(0)==this){return true}if(G==this.value.toLowerCase()){C="error_folder_exists";return false}})}}if(E===true){var A=D.closest("#prompt-dialog"),F=A.find("div.error-msg-box");if(C){if(F.length==0){F=$("<div></div>").addClass("error-msg-box error");$(".dialog-content",A).before(F)}F.text(vBulletin.phrase.get(C)).removeClass("h-hide")}else{if(F.length!=0){F.addClass("h-hide").text("")}}}else{if(C){vBulletin.warning(B,C,function(){D.focus()})}}return !C};getSelectedMessages=function(B){var A=[];if(!B&&$("#privateMessageNodeid").val()){A.push($("#privateMessageNodeid").val())}else{A=$(".privateMessageActionCheck:checked").map(function(){return this.value}).get()}if(A.length==0){vBulletin.warning("error","please_select_messages")}return A};markMessages=function(G,A,F,E,B,C){if(!C){C=getSelectedMessages()}if(C.length>0){var D={nodeid:C.join(",")};if(F){D[F]=E}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/"+A,data:D,success:function(I){var J="mark_message"+((C.length>1)?"s":"")+"_status_text_",H={methodName:"for_move",toTrashcan:"for_delete",setRead:"for_"+(E?"read":"unread"),deleteMessages:"for_delete_permanently",};if(H[A]){J+=H[A]}else{J+="generic"}openAlertDialog({title:G,message:vBulletin.phrase.get(J),onAfterClose:function(){if(B){if(pmParentFolderId){location.replace("{0}/privatemessage/list/{1}/1".format(pageData.baseurl,pmParentFolderId))}else{var K=$(".nav-pane .folder-list .folder-item.special-folder.messages a").attr("href");location.replace(K)}}else{location.reload(true)}}})}})}return false};markReports=function(E,A,D,C){var F=getSelectedMessages();if(F.length>0){var B={nodeids:F.join(",")};if(D){B[D]=C}vBulletin.AJAX({call:"/ajax/api/content_report/"+A,data:B,success:function(){var H="mark_report"+((F.length>1)?"s":"")+"_status_text_",G={bulkdelete:"for_delete",openClose:"for_"+C,};if(G[A]){H+=G[A]}else{H+="generic"}openAlertDialog({title:E,message:vBulletin.phrase.get(H),onAfterClose:function(){if(A=="bulkdelete"){location.replace(pageData.baseurl+"/privatemessage/report/1")}else{location.reload(true)}}})},error_phrase:"pm_ajax_error_desc"})}return false};gotoPage=function(D){var E=$(this);if(D.type=="blur"||(D.type=="keydown"&&D.keyCode==13)){var B=Number(E.val()),A=$("#maxPageNum").val();if(!isNaN(B)&&B!=pmPageNum&&B>0&&B<=A){var C="";if(typeof folderid!="undefined"){C="/"+routeAction+"/"+folderid+"/"}else{switch(routeAction){case"report":C="/"+routeAction+"/";break;default:break}}if(C!=""){newpage=window.location.href.replace(C+pmPageNum,C+B);window.location=newpage}else{return true}}else{E.val(pmPageNum)}return false}return true};startMove=function(B){var A=this;if(typeof (messageDetailPage)!="undefined"&&messageDetailPage){goBack=true}else{goBack=false}$(".pmMoveToFolder").off("click").on("click",function(C){var E=parseInt(this.id.substr(7),10);if(E){var D=$(A).text();if(!D){D=$(A).closest(".move-button-set").find(".button-text").text()}markMessages(D,"moveMessage","newFolderid",E,goBack)}});$("#pmOpenNewFolderName").off("click").on("click",function(D){var C=getSelectedMessages();if(C.length>0){createNewFolder.apply(this,[D,function(G,F){var E=$(this).closest(".split-button").find(".button-text").text();markMessages(E,"moveMessage","newFolderid",G,goBack)}])}return false})};createNewFolder=function(D,C,B){var A=this;$promtDlg=openPromptDialog({title:vBulletin.phrase.get("add_folder"),message:vBulletin.phrase.get("folder_name"),buttonLabel:{okLabel:vBulletin.phrase.get("ok"),cancelLabel:vBulletin.phrase.get("cancel")},validation:{custom:function(E){return isFolderNameValid(E,"add_folder",true)},override:true},onClickOK:function(G){var F=$promtDlg.find(".error-msg-box");function E(){if(F.length==0){F=$("<div></div>").addClass("error-msg-box error");$(".dialog-content",$promtDlg).before(F)}F.text(vBulletin.phrase.get("pm_ajax_error_desc"))}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/createMessageFolder",data:{folderName:G},success:function(H){$promtDlg.dialog("close");if(F.length!=0){F.addClass("h-hide").text("")}if(typeof C=="function"){C.apply(A,[H,G])}},api_error:E,error:E,emptyResponse:E})},onAfterClose:function(){var E=$promtDlg.find(".error-msg-box");if(E.length!=0){E.text("").addClass("h-hide")}if(typeof B=="function"){B.apply(A)}}});return false};startForward=function(C){if($(".privateMessageDetail .js-post").length==1){var B=getSelectedMessages();window.location=pageData.baseurl+"/privatemessage/forward/"+B[0]}else{var A=function(D){$("#pmMoveBlock").toggleClass("h-hide",D);$("#pmBtnReply, #pmBtnDelete").toggleClass("h-hide-imp",D);$("#btnMove").closest(".split-button").toggleClass("h-hide-imp",D);$("#pmForwardPrompt, .pmViewCb").toggleClass("h-hide",!D);$("#pmBtnCancel").toggleClass("h-hide-imp",!D)};A(true);$("#pmBtnCancel").off("click").on("click",function(D){A(false);$("#pmBtnForward").off("click").bind("click",startForward);$(".conversation-content.private-message-detail").removeClass("show-subcontrols")});$(".conversation-content.private-message-detail").addClass("show-subcontrols");$("#pmBtnForward").off("click").bind("click",function(E){var D=getSelectedMessages(true);if(D.length>0){window.location=pageData.baseurl+"/privatemessage/forward/"+D.join(",")}})}};acceptRequest=function(B){var A=parseInt(B.target.id.substr(16));vBulletin.AJAX({call:"/ajax/api/content_privatemessage/acceptRequest",data:{nodeid:A},success:function(C){openAlertDialog({title:vBulletin.phrase.get("private_messages"),message:C,});$("#msgSummary_"+A).remove()}})};denyRequest=function(B){var A=parseInt(B.target.id.substr(14));vBulletin.AJAX({call:"/ajax/api/content_privatemessage/denyRequest",data:{nodeid:A},success:function(C){if(C.result){vBulletin.alert("private_messages",C.result,"")}$("#msgSummary_"+A).remove()}})};notificationFadeOut=function(A){A.animate({opacity:"0.0"},{duration:500,complete:function(){A.empty();A.animate({height:0,width:0,"padding-top":0,"padding-right":0,"padding-bottom":0,"padding-left":0,},{duration:100,complete:function(){A.remove()}})}})};notificationFadeIn=function(A,B,C){if(!A){return }$container=$(".js-notification-container");$temp=$(A).hide();$container.append($temp);$temp.fadeIn()};function getNotificationsFilterParams(){var A={},B=$("#notificationFilters");if(!B.length){return{}}B.find("input[type=hidden], input[type=radio]:checked").each(function(C){if(this.value!=""){A[this.name]=this.value}});if(typeof (pmPageNum)!="undefined"){A.page=parseInt(pmPageNum)}if(typeof (pmPerPage)!="undefined"){A.perpage=parseInt(pmPerPage)}return A}decrementNotificationCount=function(){var C=$(".inbox .count"),E=$(".notifications .count"),A=C.text(),B=E.text();A=A-1;if(A<=0){C.hide()}B=B-1;if(B<=0){E.hide()}C.text(A);E.text(B);var D=$(".js-header-count-contains-notifications");D.each(function(F,G){var H=$(G).text();H--;if(H<=0){$(G).addClass("h-hide-imp")}$(G).text(H)})};toggleOthersDialog=function(A){var B=$(A.currentTarget).closest("li.message-item");$othersBox=B.find(".js-others-wrapper");if($othersBox){var C=$othersBox.data("titlephrase")||"members_in_this_message";$(this).qtip({content:{title:{text:vBulletin.phrase.get(C),button:true,},text:$othersBox.html(),},position:{my:"top center",at:"bottom center",viewport:$(window)},show:{event:"click",solo:true},events:{visible:function(E,D){$(".pmBtnFollowRequest").off("click").on("click",sendFollowRequest)},},hide:{event:"unfocus",fixed:true},style:{classes:"ui-tooltip-shadow ui-tooltip-light ui-tooltip-notification-others"}});$(this).qtip("api").show()}};dismissSingleNotification=function(B){var D=$(B.currentTarget).closest("li.message-item"),A=D.data("notificationid");if(A==null){return }var E={};$(".pm-notification-list").find("li.message-item.notification-unread").each(function(F){var G=$(this).data("notificationid");if(G!=null){E[G]=G}});var C={readIds:A,idsOnPage:E,filterParams:getNotificationsFilterParams()};if(C.filterParams.readFilter!="unread_only"){C.skipFetch=true}D.find(".js-waiting-for-ajax-response").removeClass("h-hide");vBulletin.AJAX({call:"/ajax/api/notification/dismissNotification",data:C,success:function(H){var M=H.insertNotification||"",L=H.lastsenttime||-1,G=C.filterParams.sortDir;D.removeClass("notification-unread js-notification-dismiss-touch");D.find("button.js-notification-dismiss").remove();decrementNotificationCount();if(C.filterParams.readFilter=="unread_only"){notificationFadeOut(D);notificationFadeIn(M,L,G);if(typeof pmNotificationCount!=="undefined"){pmNotificationCount--;if(pmNotificationCount>=0){var I=$("#notificationPageto");if(C.filterParams.page>1){var F=(C.filterParams.page-1)*C.filterParams.perpage+1;if(pmNotificationCount<F){var J=C.filterParams.page-1;I.val(J);I.trigger("blur")}}if(pmPages>1){var K=(pmPages-1)*C.filterParams.perpage+1;if(pmNotificationCount<K){pmPages--;$("#notificationPageCount").text(pmPages);$("#maxPageNum").val(pmPages);vBulletin.privateMessage.updatePaginationLinks($("#notificationContent").parent(),I.val(),pmPages)}}}}}},complete:function(){D.find(".js-waiting-for-ajax-response").addClass("h-hide")},error_phrase:"error_dismissing_notification",})};dismissNotifications=function(C){if(C.currentTarget.id=="pmBtnNotificationDismissAll"){var A=parseInt($("div.folder-item.special-folder.notifications .count").text());if(isNaN(A)||A<=0){vBulletin.warning("dismiss_notification_all","nothing_to_dismiss");return }openConfirmDialog({title:vBulletin.phrase.get("dismiss_notification_all"),message:vBulletin.phrase.get("confirm_about_to_dismiss_x_notifications",A),iconType:"warning",onClickYes:function(E){vBulletin.AJAX({call:"/ajax/api/notification/dismissAllNotifications",data:{},success:function(){location.reload()},error_phrase:"error_dismissing_notification",})}})}else{if(C.currentTarget.id=="pmBtnNotificationDismissPage"){var D={};$(".pm-notification-list").find(".js-notification-dismiss").each(function(E){var F=$(this).data("notificationid");if(F!=null){D[F]=F}});if($.isEmptyObject(D)){vBulletin.warning("dismiss_notification_page","nothing_to_dismiss");return }var B={readIds:D,idsOnPage:D,filterParams:getNotificationsFilterParams(),skipFetch:true,};vBulletin.AJAX({call:"/ajax/api/notification/dismissNotification",data:B,success:function(){$(".pm-notification-list").find(".js-notification-dismiss").each(function(E){$(this).removeClass("notification-unread")});location.reload()},error_phrase:"error_dismissing_notification",})}}};sendFollowRequest=function(C){var B=$(this),A=Number(B.data("userid"));if(!isNaN(A)){vBulletin.AJAX({call:"/ajax/api/follow/add",data:{follow_item:A},success:function(E){var D;if(E=="1"){B.removeClass("b-button--secondary").addClass("isSubscribed");D="following"}else{if(E=="2"){B.addClass("subscribe_pending");D="following_pending"}}if(D){B.prop("disabled",true).find(".js-button__text-primary").html(vBulletin.phrase.get(D))}},error_phrase:"pm_ajax_error_desc",})}};var currentFilter="";pendingFilter=function(A){$(this).closest(".filter-options").find(":input[type=radio]").removeAttr("checked");$(this).attr("checked","checked");var B={options:{}};$("#pendingFilters input:checked").each(function(){B.options[this.name]=this.value});B.isAjaxTemplateRenderWithData=true;vBulletin.AJAX({call:"/ajax/render/privatemessage_pendingpost_main",data:B,success:function(C){$("#privateMessageContainer .pending-posts-container").html(C.template);pmPageNum=1;$("#pendingpostsPageTo").val(pmPageNum);$(".privatemessagePaging .pendingpostsPrev").addClass("h-disabled");data={folderid:folderid,page:1,perpage:pmPerPage};if(currentFilter!=""){data.about=currentFilter}vBulletin.AJAX({call:"/ajax/api/content_privatemessage/getFolderMsgCount",data:data,success:function(E){pmPageNum=E.pagenum;pmPages=E.pages;pmNotificationCount=E.count;var D=E.pages;if(D>0){$("#pendingpostsPageCount").html(D);$(".privatemessagePaging .pendingpostsNext").toggleClass("h-disabled",!(D>1))}$("#privatemessagePaging").toggleClass("h-hide",!(D>0))},emptyResponse:function(){$("#privatemessagePaging").addClass("h-hide")}})}})};