function insertAtCursor(myField, myValue) 
{
	//IE support
	if (document.selection) 
	{
		myField.focus();
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	//MOZILLA/NETSCAPE support
	else if (myField.selectionStart || myField.selectionStart == '0') 
	{
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue 
		+ myField.value.substring(endPos, myField.value.length);
	} 
	else 
	{
		myField.value += myValue;
	}
}

browser = navigator.appName;
if (browser == "Netscape")
{
	function emoticon(text)
	{
		insertAtCursor(document.reactieform.reactie, text) 
	}
}
else 
{
	function getSel()
	{
		if (document.selection) txt = document.selection.createRange().text;
		else return;
		return txt;
	}
	function emoticon(text)
	{
		getSel();
		insertAtCursor(document.reactieform.reactie, text) 
	}
}

function wrapText(el, openTag, closeTag) { 
	if (el.setSelectionRange) 
	{// W3C/Mozilla 
		el.value = el.value.substring(0,el.selectionStart) 
		+ openTag 
		+ el.value.substring(el.selectionStart,el.selectionEnd) 
		+ closeTag 
		+ el.value.substring(el.selectionEnd,el.value.length); 
	}    else if (document.selection && document.selection.createRange) 
	{// IE code goes here 
		el.focus(); //or else text is added to the activating control 
		var range = document.selection.createRange(); 
		range.text = openTag + range.text + closeTag; 
	} 
} 