function addsmile( id, content )
{
	var ar = document.getElementById(id);

	content = ' ' + content + ' ';
	
	/* IE */
	if (document.selection) {
		ar.focus();
		cursor = document.selection.createRange();
		cursor.text = content;
		
	} else if (ar.selectionStart || ar.selectionStart == "0") { /* Gecko-based engines: Mozilla, Camino, Firefox, Netscape */
		var startPos  = ar.selectionStart;
		var endPos    = ar.selectionEnd;
		var body      = ar.value;
		ar.value = body.substring(0, startPos) + content + body.substring(endPos, body.length);
		
	} else { /* Worst case scenario: browsers that don't know about cursor position, Safari, OmniWeb, Konqueror */
		ar.value += content;
	}
}

function addbbcode( id, type )
{
	var ar = document.getElementById(id);

	var content = ' [' + type + ']' + '[/' + type + ']';
	
	/* IE */
	if (document.selection) {
		ar.focus();
		cursor = document.selection.createRange();
		cursor.text = '[' + type + ']' + cursor.text + '[/' + type + ']';
		
	} else if (ar.selectionStart || ar.selectionStart == "0") { /* Gecko-based engines: Mozilla, Camino, Firefox, Netscape */
		var startPos  = ar.selectionStart;
		var endPos    = ar.selectionEnd;
		var body      = ar.value;
		ar.value = body.substring(0, startPos) + '[' + type + ']' + body.substring(startPos, endPos) + '[/' + type + ']' + body.substring(endPos, body.length);
		
	} else { /* Worst case scenario: browsers that don't know about cursor position, Safari, OmniWeb, Konqueror */
		ar.value += content;
	}
}