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,["following","following_pending","following_remove","showing_x_subscribers","showing_x_subscriptions","unable_to_contact_server_please_try_again"]);$(document).ready(function(){var A=$(".subscribeTabs").tabs({select:function(F,G){B.hideFilterOverlay()},show:function(F,G){if(G.tab.hash=="#subscriptionsTab"){if(B){}}else{if(G.tab.hash=="#subscribersTab"){}}}});var D=$(".subscriptions-tab",A);var C=$(".subscription-list",D);var E=new vBulletin.pagination({context:D,onPageChanged:function(F,G){B.updatePageNumber(F);if(!G){B.applyFilters(false,false,false,true)}}});var B=new vBulletin.conversation.filter({context:D,onContentLoad:function(){if(B.isFilterSelected("mostactive")){$(".subscription-list-header .last-activity .arrow .vb-icon",D).addClass("vb-icon-triangle-down-wide").removeClass("vb-icon-triangle-up-wide")}else{if(B.isFilterSelected("leastactive")){$(".subscription-list-header .last-activity .arrow .vb-icon",D).addClass("vb-icon-triangle-up-wide").removeClass("vb-icon-triangle-down-wide")}}},pagination:E});$(".subscriptionsContainer .content .follow_button").live({mouseenter:function(){var F=$(this);if(!F.hasClass("subcribe_pending")&&F.hasClass("subscribed_button")){F.data("hover-timer",setTimeout(function(){F.toggleClass("subscribed_button unsubscribe_button").toggleClass("special secondary").find(".button-text-primary").text(vBulletin.phrase.get("following_remove"))},100))}},mouseleave:function(){var F=$(this);clearTimeout(F.data("hoverTimer"));if(!F.hasClass("subcribe_pending")&&F.hasClass("unsubscribe_button")){F.toggleClass("subscribed_button unsubscribe_button").toggleClass("special secondary").find(".button-text-primary").text(vBulletin.phrase.get("following"))}}});$(".subscription-list-header .last-activity .arrow").live("click",function(){var F=$(".vb-icon",this).hasClass("vb-icon-triangle-down-wide")?"leastactive":"mostactive";$(this).closest(".tab").find(".conversation-toolbar-wrapper .toolbar-filter-overlay .filter-options input[name=filter_sort][value="+F+"]").click()});$(".subscription-list-header .subscription-name .arrow").live("click",function(){alert("Not yet implemented.")})});actionSubscribeButton=function(){var A=$(this);var E=parseInt(A.attr("data-follow-id"));var D=A.attr("data-type");if((D=="follow_members"||D=="follow_contents")&&E){var C="";if(A.hasClass("add")){C="add"}else{if(A.hasClass("delete")){C="delete"}}var B=pageData.baseurl+"/profile/follow_button?do="+C+"&follower="+E+"&type="+D;$.ajax({url:B,dataType:"json",success:function(F){if(F==true||F=="1"){if(C=="delete"){A.addClass("add subscribe_button secondary").removeClass("delete subscribed_button unsubscribe_button special").find(".button-text-primary").text(vBulletin.phrase.get("follow"))}else{A.addClass("delete subscribed_button special").removeClass("add subscribe_button secondary").find(".button-text-primary").text(vBulletin.phrase.get("following"))}}else{if(F.errors){console.log(F.errors);openAlertDialog({title:vBulletin.phrase.get("following"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}else{if(F==2){A.addClass("subscribe_pending secondary").removeClass("special").prop("disabled",true).find(".button-text-primary").text(vBulletin.phrase.get("following_pending"))}}}},error:function(){openAlertDialog({title:vBulletin.phrase.get("following"),message:vBulletin.phrase.get("unable_to_contact_server_please_try_again"),iconType:"error"})}})}};