function emailaddy(name,site,domain,text)
{
	var addy = name + "@" + site + "." + domain;
	return '<a href="mailto:' + addy + '">' + text + '</a>';
}

function overlay(pageid)
{
	document.getElementById(pageid).style.visibility="visible";
}

function overlayoff(pageid)
{
	document.getElementById(pageid).style.visibility="hidden";
}


// Anti-spambot validation instructions
function whatsthis() {
	alert('In order to combat spambots, we are asking a question they would not know.  Enter the name of any main character from Planes of Eldlor, and your comment will be posted.  If you\'re stuck, check the cast page for names you can use.')
}

// Adding BBCode tags to the comment box - this is a pared down version of http://corpocrat.com/2008/08/15/free-wysiwyg-bbcode-editor-in-javascript/
function AddTags(tag1,tag2,obj) {
	textarea = document.getElementById(obj);
	// Code for IE
	if (document.selection) {
		textarea.focus();
		var sel = document.selection.createRange();
		sel.text = tag1 + sel.text + tag2;
	}
	else {  // Code for Mozilla Firefox
		var len = textarea.value.length;
		var start = textarea.selectionStart;
		var end = textarea.selectionEnd;
		var scrollTop = textarea.scrollTop;
		var scrollLeft = textarea.scrollLeft;
        var sel = textarea.value.substring(start, end);
		var rep = tag1 + sel + tag2;
        textarea.value =  textarea.value.substring(0,start) + rep + textarea.value.substring(end,len);
		textarea.scrollTop = scrollTop;
		textarea.scrollLeft = scrollLeft;
	}
}

function cReply(id) {
	var currentloc = document.getElementById("parent").value * 1;

	if (currentloc) {
		var comment = document.getElementById(currentloc).innerHTML;
		document.getElementById(currentloc).innerHTML = '<a href="javascript:cReply(' + currentloc + ')">Reply</a>';
		document.getElementById(currentloc).className = "cform_reply";
	}

	if (id) {
		if (!currentloc) {
			var comment = document.getElementById("commentbottom").innerHTML;
			document.getElementById("commentbottom").innerHTML = '<a href="javascript:cReply(0)" style="padding-top: 10px;">Add a fresh comment</a>';
		}
		document.getElementById(id).className = "cform_form";
		document.getElementById(id).innerHTML = comment;
		document.getElementById("comOrReply").innerHTML = 'Add a reply:';
	} else {
		document.getElementById("commentbottom").innerHTML = comment;
		document.getElementById("comOrReply").innerHTML = 'Add a comment:';
	}
	document.getElementById("parent").value=id;
}
