function insertBB( target, opentag, closetag ) 
{ 
   var field = document.getElementById( target ); 
    
   if( document.selection ) 
   { 
      field.focus(); 
      insertionpoint = document.selection.createRange(); 
      insertionpoint.text = opentag + insertionpoint.text + closetag; 
   } 
   else if( field.selectionStart || field.selectionStart == 0 ) 
   { 
      field.value = field.value.substring( 0, field.selectionStart ) + opentag + field.value.substring( field.selectionStart, field.selectionEnd ) + closetag + field.value.substring( selectionEnd, field.value.length ); 
   } 
   else 
   { 
      field.value += opentag + field.value + closetag; 
   } 
} 