function loadCommentForm(a, url) {
	$.get(url, {}, function(html) {
		var li = a.parents("li:first");
		var form = li.after("<h3>Add Comment</h3>").next().after(html).next();
		a.hide();
		form.get(0).scrollIntoView(true);
		form.find(":input:first").get(0).focus();
		function initForm() {
			form.find("button[@name='cancel']").click(function() {
				form.fadeOut("fast", function() { a.fadeIn("fast"); form.prev("h3").remove().end().remove() });
				$("#preview").fadeOut("fast", function() { $(this).remove(); });
				return false;
			});
			form.find("button[@name='preview']").click(function() {
				var data = form.find("input, textarea").serialize();
				$.post(url, data + "&preview=1", function(html) {
					html = html.replace(/^<!DOCTYPE[^>]+\s*/, "");
					var elem = $(html);
					form.find("table").replaceWith(elem.find("table"));
					li.next("h4").remove();
					var preview = elem.find("#preview").insertBefore(li.prev("#preview").remove().end());
					if (preview.length) {
						preview.get(0).scrollIntoView(true);
					}
					initForm();
				});
				this.blur();
				return false;
			});
		}
		initForm();
	});
}
