
	$(function(){

        $('.editComment').click(function(){

			$.blockUI({ message: "<div id='editCommentForm'><h1>Por favor aguarde...</h1></div><div id='loadingThis'></div>" });

			$.ajax({

				url: "/comments/edit/" + $(this).attr('id') + '/' + + $(this).attr('title'),
			  	cache: false,

			  	success: function(html){

			  		$("#editCommentForm").html(html);

			        $('#saveComment').click(function() {

			        	if ($("#EditedCommentBody").val() != "") {

			        		$('#editCommentForm').hide();
			        		$('#loadingThis').html('<img src=/img/icons/ajax2.gif  >');

							$.ajax({

								type: "POST",
								url: "/comments/edit/" ,
								data: "data[Comment][id]=" + $("#CommentId").val() +
								       "&data[Comment][body]=" + $("#EditedCommentBody").val() +
								       "&data[Comment][number]=" + $("#CommentNumber").val(),
							  	cache: false,
							  	success: function(html){
									$.unblockUI();
							  		$("#comment_" + $("#CommentId").val()).html(html);
							  		window.location = "#c" + $("#CommentNumber").val();
								}

							})

						} else {
							alert("Digite algum comentario!");
						}

			        });

			  	}

			});

        });

	});