$(document).ready(function(){var A="mostactive";$(".followers .content .follow_button").live("click",actionSubscribeButton);$(".subscribers-tab .pagenav-controls .pagenav-form .arrow").live("click",function(H){var F=$(this);var B=F.closest(".subscribers-tab");if(!F.hasClass("disabled")){H.preventDefault();var C=F.attr("href");var I=B.find(".subscribers-pagination");var E=parseInt(I.find(":input[name=subscribers-per-page]").val());var D=(I.find(":input[name=userid]").length>0)?parseInt(I.find(":input[name=userid]").val()):false;var G={follower:D,page:C,perpage:E};if(A){G.filter_sort=A}$.ajax({url:pageData.baseurl+"/profile/followersPagination",data:(G),dataType:"json",success:function(J){if(J.total>0&&J.template){B.find(".subscribersContent .followers .content").html(J.template)}if(J.pagenavTemplate){B.find(".conversation-toolbar .toolbar-pagenav").html(J.pagenavTemplate)}B.find(".subscribers-totalcount span").html(J.total)},error:function(){openAlertDialog({title:vBulletin.phrase.get("followers"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}});$(".subscribers-tab form.pagenav-form :input[type=text][name=page]").live("keypress",function(G){if(G.keyCode==13){G.preventDefault();var F=$(this);var E=parseInt(F.val());var B=F.closest("form.pagenav-form").find(".pagetotal");var C=0;if(B){C=parseInt(B.text(),10)}if((C>0)&&(E>C)){E=C}else{if(E<1){E=1}}var H=F.closest(".subscribers-tab");if(typeof (parseInt(E,10))=="number"&&parseInt(E,10)==E){var K=H.find(".subscribers-pagination");var I=parseInt(K.find(":input[name=subscribers-per-page]").val());var D=(K.find(":input[name=userid]").length>0)?parseInt(K.find(":input[name=userid]").val()):false;var J={follower:D,page:E,perpage:I};if(A){J.filter_sort=A}$.ajax({url:pageData.baseurl+"/profile/followersPagination",data:(J),dataType:"json",success:function(L){console.log("followersPagination successful. response: "+JSON.stringify(L));if(L.total>0&&L.template){H.find(".subscribersContent .followers .content").html(L.template)}H.find(".subscribers-totalcount span").html(L.total);if(L.pagenavTemplate){H.find(".conversation-toolbar .toolbar-pagenav").html(L.pagenavTemplate)}},error:function(){openAlertDialog({title:vBulletin.phrase.get("followers"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}}});$(".subscribersContent .subscribers_sortBy").live("click",function(){var D="";var F=$(this);var G=F.parents(".subscribersContent").find(".subscribers-pagination");if(F.hasClass("sortAsc")){D="mostactive"}else{D="leastactive"}var E=parseInt(G.find(":input[name=subscribers-page]").val());var C=parseInt(G.find(":input[name=subscribers-per-page]").val());var B=(G.find(":input[name=userid]"))?parseInt(G.find(":input[name=userid]").val()):false;$.ajax({url:pageData.baseurl+"/profile/followers_pagination",data:({follower:B,page:E,perpage:C,filter_sort:D}),dataType:"json",success:function(I){console.log("followers_pagination successful. response: "+JSON.stringify(I));var H=F.closest(".subscribers-tab");if(I.total>0&&I.template){F.parents(".followers").find(".content").html(I.template)}if(I.pagenavTemplate){H.find(".conversation-toolbar .toolbar-pagenav").html(I.pagenavTemplate)}if(D=="mostactive"){F.addClass("sortDesc");F.removeClass("sortAsc");A="mostactive"}else{if(D=="leastactive"){F.addClass("sortAsc");F.removeClass("sortDesc");A="leastactive"}}H.find(".subscribers-totalcount span").html(I.total);F.toggleClass("vb-icon-triangle-up-wide vb-icon-triangle-down-wide")},error:function(){openAlertDialog({title:vBulletin.phrase.get("followers"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})})});