function createTags() {
	$("div.entry").each( function() {
		var tags = $( "div.tags", $(this) ).text().split(", ");
		tags.sort();

		// Create links text
		var txt = new Array();
		for (j in tags) txt.push('<a href="#" onclick="return showTags(\'' + tags[j] + '\');">' + tags[j] + '</a>');

		// Append links
		$( "div.taglinks", $(this) ).append( txt.join(', ') );
	});
}

function showTags(tag) {
	$("div.entry:hidden > div.taglinks:contains('" + tag + "')").parent().fadeIn();
	$("div.entry:visible > div.taglinks:not(:contains('" + tag + "'))").parent().fadeOut();
	return false;
}

$(document).ready( function() {
	createTags();
});

