jQuery.noConflict();
(function($) {
	eb.sortItems = function() {
		var items = $('#items .item:visible').get();
		items.sort(function(a, b) {
			var c1 = parseInt($(a).find('.time').html());
			var c2 = parseInt($(b).find('.time').html());
			
			if (c1 < c2) return -1;
			if (c1 > c2) return 1;
			return 0;
		});
		items.reverse();
		$(items).each(
			function() {
				$('#items').append(this);
			}
		);
	}
	
	eb.showItems = function() {
		$('#items .item').hide();
		if (this.id == 'all' && this.checked) {
			$('#filters .filter :checkbox').each(function() {
				this.checked = 'checked';
			});
		}
		$('#items .item .category').each(function() {
			var categoryId = $(this).html();
			if ($('#filters #' + categoryId + ':checked').length != 0) {
				$(this).parents('tr, li').show();
			}
		});
		$('#items .item').removeClass('first');
		$('#items .item:visible').eq(0).addClass('first');
	}
	
	$(document).ready(
		function() {
			eb.sortItems();
		  eb.showItems();
			$('#filters .filter :checkbox').click(eb.showItems);
		}
	);
})(jQuery);

