title: Insert HTML after a selection
body: <p>I want to be able to double-click to select some text in a div, which then triggers a JavaScript function that inserts some HTML after the selected text, much like the 'edit/reply' feature in Google Wave.</p>
  
  <p>I have already established how to trigger a function on double-clicking, it is locating the selection and subsequently inserting HTML after it that is the problem.</p>