var ParentNum;
var CommentTable;
var ParentColumn;

var Comment =
{
	chCommentForm : function (id)
	{
		$(id).style.display = ($(id).style.display == 'block') ? 'none' : 'block';  
	},
    
	clearForm : function (F)
	{
		if(F.value == '댓글을 입력하세요')
			F.value = '';
    },

	saveComment : function (F)
	{
		if(form.checkValue(F.COMMENT_CONTENT, 1, '댓글이 입력되지 않았습니다.'))
		{
			$(F).send({
				onComplete : function (Msg)
				{
					if(Msg == "OK")
						Comment.ListLoad();
					else
						alert(Msg);
				} 
			});
		}
		
		return false;  
	},

	removeComment : function (Num)
	{
		if(!confirm('댓글을 삭제 하시겠습니까?')) return;
		var Result = Ajax.exec('/_Component/Comment/saveComment.php?Mode=DELETE',
							{ "COMMENT_NUM" : Num , "COMMENT_TABLE" : CommentTable} );
		if(Result.text == "OK")
		{
			this.ListLoad();
		}
		else alert(Result.text);
	},
		blindComment : function (Num,CommentTable,PARENT_COLUMN)
	{
		if(!confirm('댓글을 블라인드 처리 하시겠습니까?')) return;
		var Result = Ajax.exec('/_Component/Comment/blindComment.php?Mode=blind',
							{ "COMMENT_NUM" : Num , "COMMENT_TABLE" : CommentTable, "PARENT_COLUMN" : PARENT_COLUMN} );
		if(Result.text == "OK")
		{
			alert("블라인드 처리되었습니다");
			this.ListLoad();
		}
		else alert(Result.text);
	},
	blindComment_re : function (Num,CommentTable,PARENT_COLUMN)
	{
		if(!confirm('블라인드를 해제 하시겠습니까?')) return;
		var Result = Ajax.exec('/_Component/Comment/blindComment.php?Mode=blind_re',
							{ "COMMENT_NUM" : Num , "COMMENT_TABLE" : CommentTable, "PARENT_COLUMN" : PARENT_COLUMN} );
		if(Result.text == "OK")
		{
			alert("블라인드가 해제 되었습니다.");
			this.ListLoad();
		}
		else alert(Result.text);
	},

	ListLoad : function()
	{
		var Top = document.documentElement.scrollTop;
		var Param = 
		{
			'PARENT_COLUMN' : ParentColumn,
			'COMMENT_TABLE' : CommentTable,
			'PARENT_NUM' : ParentNum,
			'onComplete' : function () 
				{ 
					document.documentElement.scrollTop = Top; 
					User.setNickBar();
				}
		}
		
		if($('CommentArea')) AutoRun.setComponent($('CommentArea'), 'Comment', "CommentList.php", Param);
	}
}

addEvent(window, 'load', Comment.ListLoad);
