<!--
function addTag(theTag) {
	if (document.selection) // IE
		var range = document.selection.createRange();
	else if (document.getSelection()) // Netscape
		var range = document.getSelection().createRange();
	else if (window.getSelection()) // Mozilla
		var range = window.getSelection().createRange();
	if ( range.text != "" )
		range.text = buildTag(theTag, range.text);
	else
		addDirective(buildTag(theTag, ""));
}

function addDirective(theDirective) {
	if (theDirective.indexOf("[") != 0)
		theDirective = "[" + theDirective + "]";
	var currElement = document.theForm.currentElement.value;
	if (checkCurrentElement())
		document.getElementById(currElement).value = document.getElementById(currElement).value + theDirective;
}

function addLink() {
	//var theLink = prompt("Ange URL för länken", "http://");
	//var theName = prompt("Ange text/namn för länkgen", "Ny länk");
	if (checkCurrentElement()) {
		var theLink = prompt("Specify URL for the link", "http://");
		var theName = prompt("Specify text/name for the link", "New link");
		addDirective(buildTag("link", theName, theLink));
	}
}

function moreSmileys() {
	window.open("AddSmiley.htm", "AddSmiley", "location=no,toolbars=no,width=260,height=200");
}

function setElement(theElement) {
	if (document.theForm.currentElement)
		if (theElement)
			document.theForm.currentElement.value = theElement.id;
		else
			document.theForm.currentElement.value = "";
}

function buildTag(theTag, theText, theArg) {
	return "[" + theTag + ((theArg) ? ":" + theArg : "") + "]" + theText + "[/" + theTag + "]";
}

function checkCurrentElement() {
	var currElement = document.theForm.currentElement.value;
	if (currElement != "")
		return true;
	else
		//alert("Ingen text eller fält valt för editering.");
		alert("No text or field selected for editing.");
		return false;
}
//-->
