/***************************************************************************

BHU/js/entry.js

Handles entries and comments options.

***************************************************************************/

// Create comment object.

function commentCreate(id, aData) {
	var items = new Array("comment", "avatar", "info", "author", "date", "text");
	for(i in items) {
		eval("var " + items[i] + " = document.createElement('div');");
		eval(items[i]).className = "comment_" + items[i];
	}

	comment.id = id;
	comment.appendChild(info);
	info.appendChild(author);
	info.appendChild(date);
	comment.appendChild(avatar);
	comment.appendChild(text);

	if(id == "commentPreviewArea") {
		if(commentChecker.loadup.indexOf("\n") != -1) {
			var aData	= commentChecker.loadup.split("\n");
			date.id		= "commentPreview0";	
			text.id		= "commentPreview1";
		}
		else {
			author.id	= "commentPreview0";
			date.id		= "commentPreview1";	
			text.id		= "commentPreview2";
		}
	}

	if(aData) {
		// Author has avatar.
		if(aData[0]) {
			var avImg = document.createElement("img");
			if(!aData[0].match(/^http:/)) aData[0] = "users/" + aData[1] + "/avatar/" + aData[0];
			avImg.src = aData[0];
			avatar.appendChild(avImg);
		}
		var authorLink			= document.createElement("a");
		authorLink.href			= "?user:profile:" + aData[1];
		authorLink.innerHTML	= aData[2];
		author.appendChild(authorLink);
	}

	return comment;
}

/*	If comments exist, hide any submit buttons in the comments header.
	Option lists will click the buttons on change. */

if(document.getElementById("comments_head")) {
	comPageBtn	= document.getElementById("com_page_submit");
	comPPBtn	= document.getElementById("com_pp_submit");
	if(comPageBtn)	comPageBtn.style.display	= "none";
	if(comPPBtn)	comPPBtn.style.display		= "none";
}
