/* Tumblr Notes Plugin by Matthew Buchanan v1.01
   Requires jQuery 1.2.6 or higher
   See http://matthewbuchanan.name for installation guide */

function preloadNotes() {

	$(".notes-button").each(function() {
		var button = $(this);
		var node = $("#notes-"+$(this).attr("rel"));
		// add &noimages=1 after &jsonp=1 to strip images from the notes file
		$.ajax({ url: $(this).attr("name")+"&jsonp=1&noimages=1", dataType: "jsonp", success: function(data){
			node.html(data);
			var num = node.find("ol li").size()-1;
			if( num > 14 ) button.addClass("fave");
			if( num > 1 ) {
				button.prepend(num+"&nbsp;").fadeIn();
			} else if( num > 0 ) {
				button.html("1&nbsp;Note").fadeIn();
			}
			//node.append("<p><a href='#' class='notes-hide'>Hide Notes</a></p>");
			//node.find(".notes-hide").click(function(event) {
				//event.preventDefault();
				//node.slideToggle();
			//});
		} });
	});
}

$(document).ready(function() {
	preloadNotes();
});