
function reply(authorId, commentId, commentBox) {
	// 评论者名字
	var author = document.getElementById(authorId).innerHTML;
	// 拼接成 '@评论者名字' 链接
	var insertStr = '<a href="#'+commentId+'">@'+author.replace(/\t|\n/g, "")+'</a> \n';
 
	// 追加到评论输入框
	appendReply(insertStr, commentBox);
}

function appendReply(insertStr, commentBox) {
	// 如果指定的输入框存在, 将它设为目标区域
	if(document.getElementById(commentBox) && document.getElementById(commentBox).type == 'textarea') {
		field = document.getElementById(commentBox);
	// 否则提示不能追加, 并退出操作
	} else {
		alert("The comment box does not exist!");
		return false;
	}
 
	// 如果一次评论中重复回复, 提示并退出操作
	if (field.value.indexOf(insertStr) > -1) {
		alert("You've already appended this reply!");
		return false;
	}
 
	// 如果输入框内无内容 (忽略空格, 跳格和换行), 将输入框内容设置为需要追加的字符串
	if (field.value.replace(/\s|\t|\n/g, "") == '') {
		field.value = insertStr;
	// 否则清除多余换行, 并将字符串追加到输入框中
	} else {
		field.value = field.value.replace(/[\n]*$/g, "") + '\n\n' + insertStr;
	}
 
	// 聚焦评论输入框
	field.focus();
}