(function(B){window.vBulletin=window.vBulletin||{};B(document).off("click",".deletedItems-remove").on("click",".deletedItems-remove",function(){$button=B(this);var C,D=false;if($button.parents("#pmFloatingBarContent").hasClass("deletedItems-paginator")){C=getSelectedMessages()}else{C=[$button.parents(".list-item").data("nodeId")]}if(C.length>0){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/node/deleteNodes",data:{nodeids:C,hard:1},success:function(E){location.reload()}})}});B(".deletedItems-restore").off("click").on("click",function(E){$button=B(this);var C,D=false;if($button.parents("#pmFloatingBarContent").hasClass("deletedItems-paginator")){C=getSelectedMessages()}else{C=[$button.parents(".list-item").data("nodeId")]}if(C.length>0){vBulletin.AJAX({url:vBulletin.getAjaxBaseurl()+"/ajax/api/node/undeleteNodes",data:{nodeids:C},success:function(F){location.reload()}})}});B(document).off("click","#privatemessagePaging .deletedItemsPrev").on("click","#privatemessagePaging .deletedItemsPrev",function(D){D.preventDefault();var C=B(this).closest("#privatemessagePaging").find(':input[type=hidden][name="prev-page"]').val();A(B(this),C)});B(document).off("click","#privatemessagePaging .deletedItemsNext").on("click","#privatemessagePaging .deletedItemsNext",function(D){D.preventDefault();var C=B(this).closest("#privatemessagePaging").find(':input[type=hidden][name="next-page"]').val();A(B(this),C)});B(document).off("keypress","#privatemessagePaging .deletedItemsPageTo").on("keypress","#privatemessagePaging .deletedItemsPageTo",function(D){if(D.keyCode==13){D.preventDefault();var E=B(this);var C=parseInt(E.val(),10);if(isNaN(C)){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_a_valid_page_number"),iconType:"error"});return false}A(E,C)}});B("#deletedItemsFilters").trigger("reset").find(".filter-options input").off("click").on("click",function(C){deletedItemsFilter.apply(this)});function A(C,F,K){if(!C){C=B("#private-message-toolbar .deletedItems-paginator .deletedItemsPageTo");if(C.length==0){return false}}if(!K){K=0}var H=C.closest(".deletedItems-paginator");var J=B("#privateMessageContainer .main-pane .pending-posts-container");var E=H.find("#maxPageNum").filter(":input[type=hidden]").val();var G=parseInt(H.find(":input[type=hidden][name=pagenum]").val(),10);var I=parseInt(H.find(":input[type=hidden][name=per-page]").val(),10);F=parseInt(F,10);if(isNaN(F)||isNaN(E)||isNaN(G)){return false}if((F<1)||(F>E)){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("please_enter_a_valid_page_number"),iconType:"error"});return false}else{if((F==G)&&!K){return false}}var D={setCurrentPage:F,setPerPage:I,getPagingInfo:K,options:{}};B("#deletedItemsFilters input:checked").each(function(){D.options[this.name]=this.value});if(D.options.time){D.options.time={from:D.options.time}}B.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/render/privatemessage_deleteditems_main",type:"POST",data:D,dataType:"json",success:function(N){J.html(N);if(B(".deletedItems-list").length>0){}var M=0;var L=0;if(F<E){if(F>1){L=F+1;M=F-1}else{L=F+1}}else{M=F-1}H.find(":input[type=hidden][name=pagenum]").val(F);H.find(":input[type=hidden][name=next-page]").val(L);H.find(":input[type=hidden][name=prev-page]").val(M);if(L){H.find(".deletedItemsNext").removeClass("h-disabled")}else{H.find(".deletedItemsNext").addClass("h-disabled")}if(M){H.find(".deletedItemsPrev").removeClass("h-disabled")}else{H.find(".deletedItemsPrev").addClass("h-disabled")}H.find(".deletedItemsPageTo").val(F);if(K){var O=B("#privateMessageContainer .main-pane .pending-posts-container .pending-posts-pageinfo");H.find("#maxPageNum").filter(":input[type=hidden]").val(parseInt(O.find(".totalpages").val(),10));H.find(".deletedItemsPageCount").text(parseInt(O.find(".totalpages").val(),10));B(".folder-list .folder-item.pending-posts .count",$pmWidget).text(parseInt(O.find(".totalcount").val(),10))}},error:function(){openAlertDialog({title:vBulletin.phrase.get("error"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}deletedItemsFilter=function(D){$paginateButton=B("#private-message-toolbar .deletedItems-paginator .deletedItemsPageTo");if($paginateButton.length){A($paginateButton,1,true);return }var C={};B(this).closest(".filter-options-list").find("input:checked").each(function(){C[this.name]=B(this).val()});if(C.time){C.time={from:C.time}}B(this).attr("checked","checked");C.page=1;C.perpage=pmPerPage;var E={options:C};B.ajax({url:vBulletin.getAjaxBaseurl()+"/ajax/render/privatemessage_deleteditems_main",type:"post",dataType:"json",data:E,success:function(F){B("#privateMessageContainer .pending-posts-container").html(F);pmPageNum=1}})}})(jQuery);