
function storeCaret(textEl) { 
   if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate(); 
} 
 
function emoticon(text) { 
   var txtarea = document.bb.text; 
   text = '' + text + ''; 
   if (txtarea.createTextRange && txtarea.caretPos) { 
      var caretPos = txtarea.caretPos; 
      caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == '' ? text + '' : text; 
      txtarea.focus(); 
   } else { 
      txtarea.value  += text; 
      txtarea.focus(); 
   } 
} 
