var tdTrendingNow={};
(function(){tdTrendingNow={items:[],item:function(){this.blockUid="";this.trendingNowAutostart="manual";this.trendingNowPosition=this.trendingNowTimer=0;this.trendingNowPosts=[];this._is_initialized=!1},init:function(){tdTrendingNow.items=[]},_initialize_item:function(a){!0!==a._is_initialized&&(a._is_initialized=!0)},addItem:function(a){if("undefined"===typeof a.blockUid)throw"item.blockUid is not valid";if("undefined"===typeof a.trendingNowPosts||1>a.trendingNowPosts.length)throw"item.trendingNowPosts is not valid";tdTrendingNow.items.push(a);
tdTrendingNow._initialize_item(a);tdTrendingNow.tdTrendingNowAutoStart(a.blockUid)},deleteItem:function(a){for(var b=0;b<tdTrendingNow.items.length;b++)if(tdTrendingNow.items[b].blockUid===a)return tdTrendingNow.items.splice(b,1),!0;return!1},itemPrev:function(a){for(var b,c=0;c<tdTrendingNow.items.length;c++)tdTrendingNow.items[c].blockUid===a&&(b=tdTrendingNow.items[c]);if(!(void 0!==a&&1>=b.trendingNowPosts.length)){if("manual"!==b.trendingNowAutostart){c=jQuery("#"+a);var d=3;"undefined"!==typeof c.data("timer")&&
""!==c.data("timer")&&(d=c.data("timer"));clearInterval(b.trendingNowTimer);b.trendingNowTimer=setInterval(function(){tdTrendingNow.tdTrendingNowChangeText([a,"left"],!0)},1E3*d)}tdTrendingNow.tdTrendingNowChangeText([a,"right"],!1)}},itemNext:function(a){for(var b,c=0;c<tdTrendingNow.items.length;c++)tdTrendingNow.items[c].blockUid===a&&(b=tdTrendingNow.items[c]);if(!(void 0!==a&&1>=b.trendingNowPosts.length)){if("manual"!==b.trendingNowAutostart){c=jQuery("#"+a);var d=3;"undefined"!==typeof c.data("timer")&&
""!==c.data("timer")&&(d=c.data("timer"));clearInterval(b.trendingNowTimer);b.trendingNowTimer=setInterval(function(){tdTrendingNow.tdTrendingNowChangeText([a,"left"],!0)},1E3*d)}tdTrendingNow.tdTrendingNowChangeText([a,"left"],!0)}},tdTrendingNowChangeText:function(a,b){var c=a[0];a=a[1];for(var d=[],e=0,g,f=0;f<tdTrendingNow.items.length;f++)tdTrendingNow.items[f].blockUid===c&&(g=f,d=tdTrendingNow.items[f].trendingNowPosts,e=tdTrendingNow.items[f].trendingNowPosition);if("undefined"!==typeof g&&
null!==g&&(c=e,f=d.length-1,!(1>f))){"left"===a?(e+=1,e>f&&(e=0)):(--e,0>e&&(e=f));tdTrendingNow.items[g].trendingNowPosition=e;d[c].css("opacity",0);d[c].css("z-index",0);for(var h in d)!0===d.hasOwnProperty(h)&&d[h].removeClass("td_animated_xlong td_fadeInLeft td_fadeInRight td_fadeOutLeft td_fadeOutRight");d[e].css("opacity",1);d[e].css("z-index",1);!0===b?(d[c].addClass("td_animated_xlong td_fadeOutLeft"),d[e].addClass("td_animated_xlong td_fadeInRight")):(d[c].addClass("td_animated_xlong td_fadeOutRight"),
d[e].addClass("td_animated_xlong td_fadeInLeft"))}},tdTrendingNowAutoStart:function(a){for(var b=0;b<tdTrendingNow.items.length;b++)tdTrendingNow.items[b].blockUid===a&&"manual"!==tdTrendingNow.items[b].trendingNowAutostart&&(tdTrendingNow.items[b].trendingNowTimer=tdTrendingNow.setTimerChangingText(a))},setTimerChangingText:function(a){var b=jQuery("#"+a),c=3;"undefined"!==typeof b.data("timer")&&""!==b.data("timer")&&(c=b.data("timer"));return setInterval(function(){tdTrendingNow.tdTrendingNowChangeText([a,
"left"],!0)},1E3*c)}};tdTrendingNow.init()})();
