(function()
{
	var moduleName = 'claromentis.project';

	angular.module(moduleName)
		.controller("taskCommentsCtrl", ["$scope", projectCommentsController]);

	function projectCommentsController($scope)
	{
		$scope.comments_count = comments_count;
		$scope.$root.$broadcast('setDiscussionTabCount', $scope.comments_count);

        // Currently broken (and in Discuss), I think we need to use document events, not Angular ones to work cross-application

        /*$scope.OnCommentAdded = function(event, args)
        {
            $scope.comments_count++;
            $scope.$root.$broadcast('setDiscussionTabCount', $scope.comments_count);
        };

        $scope.OnCommentDeleted = function(event, args)
        {
            if ($scope.comments_count > 0)
            {
                $scope.comments_count--;
                $scope.$root.$broadcast('setDiscussionTabCount', $scope.comments_count);
            }
        };

        // We don't distinguish between a comment or a reply. Just count it
        $scope.$on('cla.comments.comment_added', $scope.OnCommentAdded);
        $scope.$on('cla.comments.reply_added', $scope.OnCommentAdded);

        $scope.$on('cla.comments.comment_deleted', $scope.OnCommentDeleted);
        $scope.$on('cla.comments.reply_deleted', $scope.OnCommentDeleted);*/
	}
}());
