/* Tumblr Notes Plugin by Matthew Buchanan v2.02
   Requires jQuery 1.2.6 or higher
   See http://matthewbuchanan.name for installation guide */

$(function() {
	$("a.notes-button").each(function() {
		var noteCount = parseInt($(this).html().substring(0,$(this).html().indexOf(" ")));
		if (noteCount > 0) $(this).show();
	});
	$("a.notes-button").click(function(event) {
		event.preventDefault();
		var node = $("#notes-"+$(this).attr("rel"));
		node.find(".loading").append('<img src="http://tumblr.manasto.info/themes/manasto_square/images/ajax-loader.gif" alt="Loading..." />');
		node.slideToggle();
		$.ajax({ url: $(this).attr("href")+"&jsonp=1&noimages=1", dataType: "jsonp", success: function(data){
			node.find(".loading").fadeOut(500,function(){
				node.find(".notes-loader").html(data).find("ol.notes li:last").append("</span>").end().slideDown();
			});
		} });
	});
});