function addTraceFilterFunctions() {
	$("#post-filter li").click( function() {
		$("#post-filter li").removeClass("active");
		$(this).addClass("active");
		$("#post-items").addClass("faded");
		$.post("/get_traces", { filter: $(this).attr("filter"), after: false }, function(response) {
			handleTracesTabResponse(response);
			addMaps();
		});
	});
}

function findMoreTraces() {
	$("#more-traces-btn").click( function() {
		$(this).remove();
		$.post("/get_traces", { filter: $("#post-filter li.active").attr("filter"), after: $("#post-items > div").last().attr("trace") }, function(response) {
			handleMoreTracesResponse(response);
			addMaps();
		});
	});
}

function handleTracesTabResponse(response) {
	$("#post-items").html(response);
	$("#post-items").removeClass("faded");
	findMoreTraces();
}

function handleMoreTracesResponse(response) {
	$("#post-items").append(response);
	findMoreTraces();
}