
(function(){var stream=rx.stream.show.stream;var nobump=stream.attr('nobump');$.fn.fadecommentbg=function(){return $(this).each(function(){$(this).find('.latest').animate({backgroundColor:'white'},30000,function(){$(this).removeClass('latest');});});};stream.bind('NewItem',function(e,u,cb){var elm=$(u.html);if(u.full){elm.addClass('new').prependTo(stream);cb&&cb(elm);}else{var item=stream.children('.shareitem[sid='+u.sid+']');var pc=elm.attr('propcount');item.addcomment(elm);if(pc)item.updateprops(parseInt(pc));parseInt(elm.attr('propdone'))&&stream.trigger('propd',[item]);parseInt(elm.attr('superpropdone'))&&stream.trigger('propd',[item,true]);if(nobump){item.fadecommentbg();item.updatecomments();}else{item.attr('stamp',elm.find('.timestamp').attr('stamp'));cb&&cb(item);}}});stream.bind('RemoveItem',function(e,d){var item=$('.shareitem[sid='+d.sid+']');function cb(){$(this).remove();item.updatecomments();}
item.find('.convo[index='+d.index+']').animate({opacity:'hide'},{queue:false,duration:'normal',complete:cb});});function fullremoveitem(e,u){stream.children('.shareitem[sid='+u.sid+']').remove();}
stream.bind('FullRemoveItem',fullremoveitem);stream.bind('GroupRemoveItem',function(e,u){if(rx.stream.show.streamtype=='home')return;fullremoveitem(e,u);});stream.bind('bump',function(e,elm,cb){elm.removeClass('old').fadecommentbg();elm.updatecomments();if(elm.hasClass('new')){var stamp=parseFloat(elm.attr('stamp'));var before;var items=stream.children('.shareitem:not(.new,.old)');items.each(function(){before=$(this);if(stamp>parseFloat(before.attr('stamp')))return false;before=null;});if(before)elm.insertBefore(before)
else elm.insertAfter(items.eq(items.length-1));elm.removeClass('new');var viewheight=window.innerHeight||$(window).height();if(elm.offset().top>viewheight)cb&&cb();else elm.streamIn('normal',cb);}else if(stream.children().eq(0).attr('sid')!=elm.attr('sid')){elm.bump(stream,0,cb);}else cb&&setTimeout(cb);var ritems=stream.find('.shareitem:not(.new,.old):gt('+(rx.stream.show.render.perpage-1)+')');if(ritems.length){ritems.addClass('old');stream.trigger('morestate',[true]);}});stream.bind('rendermore',function(e,more,cb){for(var i=0;i<more.length;i++)
stream.append(more[i]);cb&&cb();});stream.bind('morestate',function(e,visible){$('.controls .more').toggleClass('hidden',!visible);});stream.bind('bumpqueueupdate',function(e,count){if(!count)stream.children('.old').remove();});stream.bind('propd',function(e,item,sup){var name=sup?'superprops':'props';function cb(){var $this=$(this);$this.parents('.actionmenu').removeClass('dropdown');$this.remove();}
item.find('.action-'+name).fadeOut('normal',cb);});var zool=stream.find('.zool');if(zool.length)stream.one('bump',function(){zool.remove();delete zool;});})();