var lastReply = 0;

function replyTo(id)
{
	if(lastReply)
	{
		if(lastReply == id) return false;
		$('#replyForm_'+lastReply).clone().appendTo('#replyForm_' + id);
		$('#replyForm_'+lastReply).empty();	
	}else
	{
		$('#commentForm').clone().appendTo('#replyForm_' + id);
		$('#originalForm').empty();
	}
	
	$('#reply_id').attr('value', lastReply = id);
		
	$('#add_comment').focus();
	return false;
}

function deleteComment(id, prefix, entry_id){
	$('#commentBlock'+id+' div').addClass('comment2delete');
	if(1 || confirm('?')){
		$.ajax({
			url: '/ajax/deleteComment.php',
			type: 'post',
			dataType: 'text',
			data: 'id='+id+'&prefix='+prefix+'&entry_id='+entry_id,
			success: function(data){
				if(data == 'OK'){
				$('#commentBlock'+id).fadeOut('slow');
				if(cc=$('#ecc'+entry_id).html())
					$('#ecc'+entry_id).text(cc-1);
				}else{
					alert(data);
				}
			},
			error: function(){
				alert("Can't delete comment");
			}
		});
	}else $('#commentBlock'+id).removeClass('comment2delete');
	return false;
}