var addCommentParent;

function moveAddCommentBelow(theId, threadId, collapse)
{
	var addComment = document.getElementById(vcommentform);
	if(!addComment)
	{
	  	alert("ERROR:\nThreaded Comments can't find the '"+vcommentform+"' div.\nThis is probably because you have changed\nthe comments.php file.\nMake sure there is a tag around the form\nthat has the id 'addcomment'");
		return;
	}
	var comment = document.getElementById(theId);
	if(collapse)
	{
		for(var i = 0; i < comment.childNodes.length; ++i) {
			var c = comment.childNodes.item(i);
			if(typeof(c.className) == "string" && c.className.indexOf("collapsed")<0) {
				c.className += " collapsed";
			}
		}
	}
	addCommentParent = addComment.parentNode;

	addComment.parentNode.removeChild(addComment);

	comment.appendChild(addComment);
	if(comment.className.indexOf("alt")>-1) {
		addComment.className = addComment.className.replace(" alt", "");
	} else {
		addComment.className += " alt";
	}
    var replyId = document.getElementById("comment_reply_ID");
	if(replyId == null)
	{
		alert("Error:\nThere is no hidden form field called\n'comment_reply_ID'. This is probably because you\nchanged the comments.php file and forgot\nto include the field. Please take a look\nat the original comments.php and copy the\nform field over.");
	}
	replyId.value = threadId;
	var reRootElement = document.getElementById("reroot");
	if(reRootElement == null)
	{
		alert("Error:\nThere is no anchor tag called 'reroot' where\nthe comment form starts.\nPlease compare your comments.php to the original\ncomments.php and copy the reroot anchor tag over.");
	}
	reRootElement.style.display = "block";
	addComment.style.display = "block";
	var aTags = comment.getElementsByTagName("A");
	var anc = aTags.item(0).id;
	//document.location.href = "#"+anc;
	document.getElementById("comment").focus();
	//changeCommentSize(450);
}

function reRoot()
{
	var addComment = document.getElementById(vcommentform);
	var reRootElement = document.getElementById("reroot");
	reRootElement.style.display = "none";
	//var content = document.getElementById("content");
	var content = addCommentParent;
	addComment.parentNode.removeChild(addComment);
	content.appendChild(addComment);
	addComment.className = addComment.className.replace(" alt", "");
	document.location.href = "#addcommentanchor";
	document.getElementById("comment").focus();
	document.getElementById("comment_reply_ID").value = "0";
	//changeCommentSize(460);
}

function changeCommentSize(wid)
{
	var el = document.getElementById("comment");
	el.style.width = wid+"px";
}