var ATLlastReply;

function atmoReplyCommentOnClick(parent_id, author) {
	atmoReplyCommentCancel();
	
	var replyId = 'reply-link-'+parent_id;
	var replyToLink = document.getElementById(replyId);
	var commentsForm = document.getElementById('comments-open');

	mtSignInOnClick();
	mtReplyCommentOnClick(parent_id, author);
	
	mtHide('comments-open-header');
	mtHide('comment-form-reply');
	mtShow('comments-replying');
	
	document.getElementById('comment-reply-cancel').style.display = "inline";
	
	replyToLink.parentNode.replaceChild(commentsForm, replyToLink);
	try { document.getElementById('comment-text').focus(); }catch(e){}
	ATLlastReply = replyToLink;
}

function atmoReplyCommentCancel(){
	var commentsForm = document.getElementById('comments-open');
	mtShow('comments-open-header');
		
	var checkbox = document.getElementById('comment-reply');
	var parent_id_field = document.getElementById('comment-parent-id');
	checkbox.checked = false;
	parent_id_field.value = 0;
	
	mtHide('comment-form-reply');
	mtHide('comment-reply-cancel');
	mtHide('comments-replying');
	
	if(ATLlastReply) {
		commentsForm.parentNode.replaceChild(ATLlastReply, commentsForm);
		document.getElementById('comments').appendChild(commentsForm);
		ATLlastReply = undefined;
	}
}