Event.observe(window, 'load', SetupComments, false);

function SetupComments()
{
	var Links = $('CommentList').getElementsByTagName('a');
	for (var i = 0, Link; Link = Links[i]; i++)
	{
		if (Link.parentNode.className)
		{
			if (Link.parentNode.className == 'AnswerTo')
			{
				Link.onclick = function()
				{
					MarkAsParentComment(this.href.replace(/.*?\#comment/, ''));
					MarkAsChildComment(this.parentNode.parentNode.id.replace('Comment', ''));
				}
			}
			else if (Link.parentNode.className == 'AnsweredBy')
			{
				Link.onclick = function()
				{
					MarkAsChildComment(this.href.replace(/.*?\#comment/, ''));
					MarkAsParentComment(this.parentNode.parentNode.id.replace('Comment', ''));
				}
			}
		}
	}
}

var CurrentChild = false;
var CurrentParent = false;

function MarkAsChildComment(ID)
{
	if (CurrentChild)
	{
		CurrentChild.className = CurrentChild.className.replace(' Child-Comment', '');
	}
	CurrentChild = $('Comment' + ID);
	CurrentChild.className += ' Child-Comment';
}

function MarkAsParentComment(ID)
{
	if (CurrentParent)
	{
		CurrentParent.className = CurrentParent.className.replace(' Parent-Comment', '');
	}
	CurrentParent = $('Comment' + ID);
	CurrentParent.className += ' Parent-Comment';
}