$(document).ready(function(){$(".following .content .follow_button").live("click",actionSubscribeButton);$(".subscriptionsFilterImage").bind("click",applyFilter);$(".profFilterRow").live("click",filterClick);$("#profileErrorClose").bind("click",function(){$("#profileErrorDialog").dialog("close")});$(".subscriptionsContent .pagenav-controls .pagenav-form .arrow").live("click",function(F){var D=$(this);if(!D.hasClass("disabled")){F.preventDefault();var A=1;var G=D.attr("href").indexOf("page=");if(G){A=D.attr("href").charAt(G+5)}var E="";var H=D.parents(".subscriptionsContent").children(".subscriptions-pagination");var C=parseInt(H.children(":input[name=subscriptions-per-page]").val());var B=(H.children(":input[name=userid]"))?parseInt(H.children(":input[name=userid]").val()):false;if(filterType){E+="&type="+filterType}if(followingSortBy){E+="&filter_sort="+followingSortBy}E+="&page="+A+"&perpage="+C;$.ajax({url:pageData.baseurl+"/profile/following_filter?follower="+B+E,dataType:"json",success:function(I){if(I.total>0&&I.template){D.parents(".subscriptions-tab").find(".subscriptionsContent .following .content").html(I.template)}if(I.pagenavTemplate){H.find(".pagenavContainer").html(I.pagenavTemplate)}D.parents(".subscriptions-tab").find(".subscriptions-totalcount").html(vBulletin.phrase.get("showing_x_subscriptions",I.total))},error:function(){openAlertDialog({title:vBulletin.phrase.get("following"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}});$(".subscriptionsContent form.pagenav-form :input[type=text][name=page]").live("keypress",function(E){if(E.keyCode==13){E.preventDefault();var F=$(this);var C=parseInt(F.val());if(typeof (parseInt(C))=="number"&&parseInt(C)==C){var D="";if(filterType){D+="&type="+filterType}if(followingSortBy){D+="&filter_sort="+followingSortBy}var G=F.parents(".subscriptions-tab").find(".subscriptions-pagination");var B=parseInt(G.children(":input[name=subscriptions-per-page]").val());var A=(G.children(":input[name=userid]"))?parseInt(G.children(":input[name=userid]").val()):false;D+="&perpage="+B+"&page="+C;$.ajax({url:pageData.baseurl+"/profile/following_filter?follower="+A+D,dataType:"json",success:function(H){if(H.total>0&&H.template){F.parents(".subscriptions-tab").find(".subscriptionsContent .following .content").html(H.template)}if(H.pagenavTemplate){G.find(".pagenavContainer").html(H.pagenavTemplate)}F.parents(".subscriptions-tab").find(".subscriptions-totalcount").html(vBulletin.phrase.get("showing_x_subscriptions",H.total))},error:function(){openAlertDialog({title:vBulletin.phrase.get("following"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}}});$(".subscriptionsHeader #subscribed_"+filterType).addClass("filterSelected");$(".subscriptionsHeader .inlineSearchButton").live("click",function(A){A.preventDefault();alert("Not implemented yet")})});applyFilter=function(){$(".subscriptionsFilter").slideToggle("3000")};var filterType="follow_all";var followingSortBy="mostactive";var currentLocation=top.location.search.split("&");$.each(currentLocation,function(A,C){if(C.toLowerCase().indexOf("type")!==-1){var B=C.substr(C.toLowerCase().indexOf("type")+5,C.length);B=B.toLowerCase();if(B=="content"||B=="channel"||B=="member"||B=="all"){filterType=B}}});filterClick=function(E){var D=$(this);if(D.hasClass("jsPsuedoLink")&&!D.hasClass("filterSelected")){D.parent().children(".filterSelected").removeClass("filterSelected");switch(D.attr("data-filter")){case"subscribed_all":filterType="follow_all";D.addClass("filterSelected");break;case"subscribed_members":filterType="follow_members";D.addClass("filterSelected");break}var C="";if(filterType){C+="&type="+filterType}if(followingSortBy){C+="&filter_sort="+followingSortBy}var F=D.parents(".subscriptions-tab").find(".subscriptions-pagination");var B=parseInt(F.children(":input[name=subscriptions-per-page]").val());var A=(F.children(":input[name=userid]"))?parseInt(F.children(":input[name=userid]").val()):false;C+="&page=1&perpage="+B;$.ajax({url:pageData.baseurl+"/profile/following_filter?follower="+A+C,dataType:"json",success:function(G){if(G.total>0&&G.template){D.parents(".subscriptions-tab").find(".subscriptionsContent .following .content").html(G.template)}D.parents(".subscriptions-tab").find(".subscriptions-totalcount").html(vBulletin.phrase.get("showing_x_subscriptions",G.total));if(G.pagenavTemplate){F.find(".pagenavContainer").html(G.pagenavTemplate)}},error:function(){openAlertDialog({title:vBulletin.phrase.get("following"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}};