
var forum = {
	/* COMMENT TREES */	
	initCommentsTree: function(jsonData, rootId, auth) {
		var oResults = eval(jsonData);
		var comNode = new Array();

		comNode[rootId] = new YAHOO.widget.TextNode("Kommentarer", tree[rootId].getRoot(), true);
		//comNode[rootId] = new YAHOO.widget.TextNode("Kommentarer", tree.getRoot(), false);

		for (commentIndex in oResults) {
			var newComment = oResults[commentIndex];
			var fromStr = '<div class="metainfo"><em>' + newComment.fields.author; //+ " " + newComment.fields.group;
			if (newComment.fields.group != null){
				fromStr += " på vegne af " + newComment.fields.group; 
			}
			fromStr += "</em></div>"
			var iconStr = "";
			if (auth) {
				var objString =  "{formUrl: '/forum/entry/save/?category_id="+newComment.fields.category+"&parent_id="+newComment.pk+"', tiny: false}";
				iconStr =  ' <img onclick="javascript:pop.manualShowPop('+ objString +');" src="/site_media/images/icon_addlink.gif"/>';
				//var newComContent = '<span class="commentHead">'+ newComment.fields.header+'</span> <img onclick="javascript:pop.manualShowPop('+ objString +');" src="/site_media/images/icon_addlink.gif"/><div class="comment_message">'+ newComment.fields.message+'</div>';
			} else {
				//var newComContent = '<span class="commentHead">'+ newComment.fields.header+'</span><div class="comment_message">'+ newComment.fields.message+'</div>';
			}
			var newComContent = '<span class="commentHead">'+ newComment.fields.header+'</span>'+iconStr+fromStr+'<div class="comment_message">'+ newComment.fields.message+'</div>';

			comNode[newComment.pk] = new YAHOO.widget.HTMLNode(newComContent, comNode[newComment.fields.parent], true, true);
		}
	}, 
	fold: function(rootId) {
		var mDiv = document.getElementById("message"+rootId); 
		if (mDiv.style.display == "none"){
			mDiv.style.display = ""; 
			document.getElementById("fold"+rootId).innerHTML = "Fold sammen";
		} else {
			mDiv.style.display = "none"; 
			document.getElementById("fold"+rootId).innerHTML = "Fold ud";
		}
	}
};
