	function insertSmiley(smileyName,areaId) {

		areaObj = document.getElementById(areaId);
		surroundText2(smileyName,' ', areaObj);
		return true;

	}

	function insertSimpleTag(tagName, areaId) {

		areaObj = document.getElementById(areaId);
		surroundText2('[' + tagName + ']', '[/' + tagName + ']', areaObj);
		return true;

	}


	function insertPromptTag(tagName, areaId, promptQuestion, promptValue, attributeName, attributeValNeeded) {

		areaObj = document.getElementById(areaId);
		promptAnswer = window.prompt(promptQuestion,promptValue);

		if(promptAnswer == null || promptAnswer == '') {
			return false;
		}

		var textLeft = '[' + tagName;
		var textRight = '[/' + tagName + ']';

		if(attributeValNeeded == true) {
			if(attributeName != null && attributeName != '') {
				textLeft = textLeft + ' ' + attributeName + '="' + promptAnswer + '"]';
			} else {
				textLeft = textLeft + '="' + promptAnswer + '"]';
			}
		} else {
			textLeft = textLeft + ']' + promptAnswer;
		}

		if(tagName == 'url') {
			surroundText(textLeft, textRight, areaObj, promptAnswer);
		} else {
			surroundText2(textLeft, textRight, areaObj);
		}

		return true;
	}


	function surroundText(text1, text2, areaObj, promptAnswer) {

		areaObj.focus();

		if(areaObj.selectionStart == null) {
	
		    var sel = document.selection.createRange();
		    if(sel.text == null || sel.text == '') {
		        sel.text = text1 + promptAnswer + text2;
		    } else {
		        sel.text = text1 + sel.text + text2;
		    }
	
		} else {

		    var selection = areaObj.value.substring(areaObj.selectionStart,areaObj.selectionEnd);

		    if(selection == null || selection == '') {
			areaObj.value = areaObj.value.substring(0,areaObj.selectionStart) +
			text1 + promptAnswer +
			text2 + areaObj.value.substring(areaObj.selectionEnd);
		    } else {
			areaObj.value = areaObj.value.substring(0,areaObj.selectionStart) +
			text1 + selection +
			text2 + areaObj.value.substring(areaObj.selectionEnd);
		    }

		}
	}

	function surroundText2(text1, text2, areaObj) {

		areaObj.focus();

		if(areaObj.selectionStart == null) {	

		    var sel = document.selection.createRange();
		    sel.text = text1 + sel.text + text2;	

		} else {

		    areaObj.value = areaObj.value.substring(0,areaObj.selectionStart) +
		    text1 + areaObj.value.substring(areaObj.selectionStart,areaObj.selectionEnd) +
		    text2 + areaObj.value.substring(areaObj.selectionEnd);
		}
	}