
jQuery.fn.bump=function(container,position,callback){return this.each(function(){var item=$(this);var cloneitem=item.clone();var source=item.wrap('<div></div>').parent();var destination=$('<div></div>');if(!position)position=0;destination.insertBefore(container.children().eq(position));var width=item.width();var height=item.outerHeight();var soffset=source.offset();var doffset=destination.offset();source.css({width:width,height:height});destination.css({width:width,height:0});var dur=700;var p={position:'absolute',top:soffset.top,left:soffset.left,width:width,height:item.height()};cloneitem.appendTo(document.body).css(p);item.hide().insertAfter(destination);source.animate({height:0},dur,function(){source.remove();});destination.animate({height:height},dur);cloneitem.animate({top:doffset.top},dur,'easeInOutCirc',function(){item.css('display','');destination.remove();cloneitem.remove();callback&&callback();});});};jQuery.fn.addcomment=function(comment){return this.each(function(){var item=$(this);var conversation=item.find('.conversation,.miniconversation');var comments=conversation.find('.comments');if(comments.find('[index='+comment.attr('index')+']').length)return;comments.removeClass('hidden').append(comment);conversation.show();});};jQuery.fn.updatecomments=function(){return this.each(function(){var item=$(this);var conversation=item.find('.conversation');var comments=conversation.find('.comments');var collapsed=comments.find('.collapsed');if(!collapsed.length){if(comments.find('.convo').length)comments.removeClass('hidden');else comments.addClass('hidden');return;}
var showall=conversation.find('.show-all');var caction=showall.find('a');while(comments.children('.convo').length<3){if(collapsed.children().length)
collapsed.children().filter(':last').insertAfter(collapsed);else break;}
while(comments.children('.convo').length>3)
comments.children('.convo').eq(0).appendTo(collapsed);if(rx.stream.show.streamtype!='item')
collapsed.children().length?showall.show():showall.hide();var clen=conversation.find('.convo').length;comments.toggleClass('hidden',!clen);item.attr('conversation')?caction.html('hide comments'):caction.html('show all '+clen+' comments');});};jQuery.fn.updateviews=function(count){return this.each(function(){var viewcount=$(this).find('.views');viewcount.html('view'.countify(count));viewcount.parent().removeClass('hidden');});};jQuery.fn.updateprops=function(count){return this.each(function(){var propcount=$(this).find('.props');propcount.html('prop'.countify(count));if(count)
propcount.parents('.stat,.stats').removeClass('hidden');});};jQuery.fn.updatetime=function(time){return this.each(function(){$(this).find('.timestamp').each(function(){var t=$(this);t.html(rx.util.fuzzytime(parseFloat(t.attr('stamp')),time));});});};(function(){var ns=rx.namespace('stream.show.render');var stream=rx.stream.show.stream;var notify=rx.stream.show.notify;ns.running=false;ns.queue=[];ns.disabled=true;ns.render=function(items){for(var i=0;i<items.length;++i){stream.trigger(items[i].type,[items[i],function(bumpelm){ns.queue.push(bumpelm);stream.trigger('bumpqueueupdate',ns.queue.length);}]);}
if(!ns.running)ns.dobump();};ns.dobump=function(){if(!ns.disabled&&ns.queue.length){ns.running=true;stream.trigger('bump',[ns.queue.shift(),function(sleep){if(!notify.hasfocus()){notify.flash('NEW STREAM ITEMS!');notify.sound('blermp');}
if(sleep)setTimeout(ns.dobump,sleep);else ns.dobump();}]);}else ns.running=false;stream.trigger('bumpqueueupdate',ns.queue.length);};stream.bind('pause',function(){ns.disabled=true;});stream.bind('resume',function(){stream.trigger('resetui');ns.disabled=false;if(!ns.running)ns.dobump();if(stream.msg){rx.stream.message.remove(stream.msg);stream.msg=null;}});stream.bind('queuerender',function(e,items){ns.render(items);});stream.bind('more',function(e,items){ns.perpage+=items.length;stream.trigger('rendermore',[items]);});function fullremoveitem(e,data){for(var i=ns.queue.length-1;i>=0;--i){if(ns.queue[i].is('[sid='+data.sid+']'))ns.queue.splice(i,1);}
stream.trigger('bumpqueueupdate',ns.queue.length);}
stream.bind('FullRemoveItem',fullremoveitem);stream.bind('GroupRemoveItem',function(e,data){if(rx.stream.show.streamtype=='home')return;fullremoveitem(e,data);});stream.bind('timeupdate',function(e,time){ns.servertime=time;});setInterval(function(){$('.shareitem').updatetime(ns.servertime);},10000);})();