function smile( last_txt_object, code )
{
	if (last_txt_object.createTextRange && last_txt_object.caretPos)
	{
		var caretPos = last_txt_object.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + code;
	}
	else 
	{
		if (navigator.appVersion.indexOf('MSIE') != -1)
			ieWr(last_txt_object, code);
		else
			mozillaWr(last_txt_object, code);
	}
	last_txt_object.focus();
}

function mozillaWr(obj, text)
{
	var selLength = obj.textLength;
	var selEnd = obj.selectionEnd;
	
	var s2 = (obj.value).substring(0, selEnd)
	var s3 = (obj.value).substring(selEnd, selLength);
	obj.value = s2 + text + s3;
	
	obj.selectionEnd = selEnd + text.length;
	return;
}


function ieWr( obj, text )
{
	var isClose = false;
	
	obj.focus();
	var sel = document.selection;
	var rng = sel.createRange();
	rng.colapse;
	if((sel.type == "Text" || sel.type == "None") && rng != null)
	{
		rng.text = rng.text + text;
	}
}
