
(function($){$next_page=2;$.fn.paginate=function(options){var element=this;var pagination=$('div.pagination:last');if(pagination.is(':hidden'))return false;var extra_data="";if($('#timeline_options_form').length){extra_data='&'+$('#timeline_options_form :input:not(:hidden)').fieldSerialize();}
if(location.href.substring((location.href.length-1))=='/'){var base_url=location.href.substring(0,(location.href.length-1))}else{var base_url=location.href;}
$.ajax({url:base_url+'/page/'+$next_page,data:'token='+$token+extra_data,dataType:'json',beforeSend:function(){$('.older',pagination).css('visibility','hidden');spinner_id=spinner($('.older',pagination),'before','more');},error:function(xhr,error_type){var error_message=throw_error(error_type,xhr);$(spinner_id).fadeOut(250,function(){spinner_callback(spinner_id);handle_error(error_message);});},success:function(xhr){$(spinner_id).fadeOut(250,function(){spinner_callback(spinner_id);$(pagination).prev().append(xhr.html);$('li.activity.first:last').removeClass('first');if(xhr.max==1){$('a.older',pagination).hide();}else{$('a.older',pagination).removeAttr('style');}
$next_page=xhr.next_page;});}});return this;};})(jQuery);$(function(){if($('div.pagination a.older').length){$('div.pagination a.older').click(function(){$('ul#items').paginate();return false;});}
$('ul#items li div.comment a.content').each(function(){var parent=$(this).parent();$(parent).bind('mouseenter',function(){$(this).css({'text-decoration':'underline'});$(this).css('cursor','pointer');}).bind('mouseleave',function(){$('a:first',this).removeAttr('style');$(this).removeAttr('style');}).bind('click',function(){var go_to_url=$('a:first',this).attr('href');if(go_to_url.length>5)
window.location=go_to_url;});});$('#timeline_options_form :input').change(function(){var checkbox=this;if($(checkbox).attr('type')=='checkbox')
$(checkbox).hide();var spinner_id=spinner(this,'after','filter_'+this.value);var query_string=$('#timeline_options_form').formSerialize();var post_to=$('#timeline_options_form').action;$.ajax({url:post_to,data:query_string,dataType:'json',error:function(xhr,error_type){var error_message=throw_error(error_type,xhr);$(spinner_id).fadeOut(250,function(){spinner_callback(spinner_id);if($(checkbox).is(':hidden'))
$(checkbox).show();handle_error(error_message);});},success:function(xhr){$(spinner_id).fadeOut(250,function(){spinner_callback(spinner_id);if($(checkbox).is(':hidden'))
$(checkbox).show();$('ul#items').html(xhr.html);$('.rel_timestamp').timeago();if(xhr.max==1){$('div.pagination a').hide();}else{$('div.pagination a').show();}
$next_page=2;});}});});$(window).unload(function(){$(':checkbox').removeAttr('checked');});});function expand(element,topic_activity_id){$.post('/topic_activities/excerpt/'+topic_activity_id,{token:$token},function(xhr){var blocks='<div class="blocks">'+xhr.blocks+'</div>';if($(element).parents('div.wrap').hasClass('no_avatar')){$(element).parent().hide().next().show().parent().addClass('expanded_gap').prepend(blocks).hide().slideDown(250,function(){var paragraph=$(this).prev();if($('a',paragraph).length){var content=$('a',paragraph).html();$('a',paragraph).parent().unbind('mouseenter mouseleave').removeAttr('style');paragraph.html(content);}});}else{$(element).parent().hide().next().show().parent().addClass('expanded expanded_gap').prepend(blocks).hide().slideDown(250,function(){var paragraph=$(this).prev();if($('a',paragraph).length){var content=$('a',paragraph).html();$('a',paragraph).parent().unbind('mouseenter mouseleave').removeAttr('style');paragraph.html(content);}});}},'json');return false;}
function delete_topic_activity(topic_activity_id,element_type){$.ajax({url:'/topic_activities/destroy/'+topic_activity_id,data:'token='+$token+'&topic_activity[confirmed]=true',dataType:'json',beforeSend:function(){if(!confirm(confirm_delete_topic_activity)){return false;}},error:function(xhr,error_type){var error_message=throw_error(error_type,xhr);handle_error(error_message);},success:function(xhr){if(typeof(element_type)=='string'&&element_type=='reply'){var element='li#topic_activity_'+topic_activity_id+'_reply';var reply=true;}else{var element='li#activity-'+topic_activity_id;var reply=false;}
if($(element).length){$(element).fadeOut(250);}else{var element=$('#topic_activity_'+topic_activity_id);if(!reply&&element.length){if(xhr.redirect_to)
window.location=xhr.redirect_to;}else{var element=$('#topic_activity_'+topic_activity_id+'_reply');if(reply&&element.length){$(element).fadeOut(250);}}}}});return false;}
function toggle_tag(element){var target=$(element).parents('.fmc_tag').next();if($(target).is(':visible')){$(target).slideUp(250,function(){$(element).parents('.toggle_close').removeClass('toggle_close').addClass('toggle_open');});}else{$(target).slideDown(250,function(){$(element).parents('.toggle_open').removeClass('toggle_open').addClass('toggle_close');});}
return false;}