$(document).ready(function () {
	
	// comment submit
	$("#commentbttn").live("click", function() {
		$("#commentform fieldset").hide();
		$.ajax({
			type: "POST", 
			url: "/comments/edit/",
			data: $("#commentform fieldset form").serialize(),
			beforeSend: function(){ // on send actions
				$("#commentform .loading").fadeIn("fast");
			},
			complete: function(){ // on complete actions
				$("#commentform .loading").hide();
			},
			success: function(html){ // success store returned data in html
				$("#commentform .data").html(html);
		 	}
		 });	
	});
	
	// load reply/edit form
	$("#commentlist .actionlink").live("click", function() {
		$("#commentform .loading").fadeIn("fast");
		$("#commentform .data").hide();
		$.get(this.rel, function(response) {
			$("#commentform .data").html(response).fadeIn("fast");
			$("#commentform .loading").hide();
			window.location.hash = '#commentform';
		});	
	});
	
});
