//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";
//}
var cfmParent='';
var cfmCommentTextareaWidth = 0;

function movecfm(Id){
	var cfm = document.getElementById(vcommentform);

	if(cfm == null){
	  	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 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.");
		return;
	}

	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.");
		return;
	}

	if(Id){
		replyId.value = Id;

		if(cfmParent == '')
			cfmParent = cfm.parentNode;
		if (cfmCommentTextareaWidth == 0)
			cfmCommentTextareaWidth = document.getElementById("comment").offsetWidth - 10;

		var OId = document.getElementById("comment-"+Id);

		// retrieve width of the comment
		elementWidth = OId.offsetWidth;

		cfm.parentNode.removeChild(cfm);
		OId.appendChild(cfm);

		reRootElement.style.display = "block";
		cfm.style.display = "block";

		// 1. focus on the comment; 2. adjust width of comment box
		commentEl = document.getElementById("comment");
		if (commentEl)	{
			commentEl.focus();
			commentEl.style.width = (elementWidth - 30) + "px";
		}
	}else{
		replyId.value = "0";

		reRootElement.style.display = "none";

		cfm.parentNode.removeChild(cfm);
		cfmParent.appendChild(cfm);

		commentEl = document.getElementById("comment");
		if (commentEl)	{
			commentEl.focus();
			commentEl.style.width = cfmCommentTextareaWidth + "px";
		}
	}
	return;
}