
function hide_archived(note_id) {
	$('#note-' + note_id + " .note-contents").slideUp('slow', function() {

		// clear the "archive" onclick and replace with a "show" onclick
		$('#archive-link-' + note_id).unbind('click').click(function() {
			show_archived(note_id);
			return false;
		}).text('Show');
	});
}

function show_archived(note_id) {
	$('#note-' + note_id + " .note-contents").slideDown('slow', function() {

		// clear the "show" onclick and replace with a "hide" onclick
		$('#archive-link-' + note_id).unbind('click').click(function() {
			hide_archived(note_id);
			return false;
		}).text('Hide');
	});
}

$(document).ready(function() {

	$('.archive-link').each(function() {
		if ($(this).hasClass('archived')) {

			$(this).click(function() {
				var note_id = $(this).attr('id').substr("archive-link-".length);
				show_archived(note_id);
				return false;
			}).text('Show');

		}
		else {
			$(this).click(function() {
				$.get(
					$(this).attr('href'),
					{},
					function(data) {
						hide_archived(data);
					}
				);

				return false;
			});
		};
	});
});
