
function CommentHandling() { }

CommentHandling.init = function(article)
{
	CommentHandling.check_form();
	
	//$('.roundInput').corner("3px");
	
	$('#commentNameInput').bind("change", function(e) { CommentHandling.check_form(); });
	$('#commentTextInput').bind("change", function(e) { CommentHandling.check_form(); });
	$('#commentNameInput').bind("keyup", function(e) { CommentHandling.check_form(); });
	$('#commentTextInput').bind("keyup", function(e) { CommentHandling.check_form(); });
	
	$('#commentForm').bind("submit", function(e)
	{
		e.preventDefault();
		
		var args = $('#commentForm').serialize();
		
		close_dialog('#commentsDialog');
		
		jQuery.getJSON("functions/post_comment.php?" + args, function(data)
		{
			if (data.Status.Success)
			{
				open_comments(article);
			}
			else
			{
				alert(data.Status.Error);
			}
		});
	});
}

CommentHandling.check_form = function()
{
	if ($('#commentNameInput').attr("value") == "" || $('#commentTextInput').attr("value") == "")
	{
		$('#commentSubmit').attr("disabled", "disabled");
	}
	else
	{
		$('#commentSubmit').removeAttr("disabled");
	}
}

