// Nick in quick relpay and quote selected text
function Insert(nickname, text)
  {
   if (text!="")
      paste("[quote=\""+nickname+"\"]"+text+"[/quote]\n", 0);
      document.post.message.focus();
   }
function paste(text, flag)
  {
   if ((document.selection)&&(flag))
    {
      document.post.message.focus();
      document.post.document.selection.createRange().text = text;
 }
   else document.post.message.value += text;
}

function get_selection() 
{
   if (document.getSelection)
   {
    selection = document.getSelection();
    selection = selection.replace(/\r\n\r\n/gi, "_doublecaret_");
    selection = selection.replace(/\r\n/gi, " ");
       while (selection.indexOf("  ") !=-1) selection = selection.replace(/  /gi, "");
    selection = selection.replace(/_doublecaret_/gi, "\r\n\r\n");
  } 
  else
      selection = document.selection.createRange().text;
}
function catchSelection()
{
    if (window.getSelection)
    {
        selection = window.getSelection().toString();
    }
    else if (document.getSelection)
    {
        selection = document.getSelection();
    }
    else if (document.selection)
    {
        selection = document.selection.createRange().text;
    }
}
function insertnick(nickname)
  {
   if(document.selection)
   {
    document.post.message.focus();
    document.selection.createRange().text += '[b]' + nickname + '[/b],\n ';
  }
   else
   {
    document.post.message.focus();
    document.post.message.value+= '[b]' + nickname + '[/b],\n ';
  }
 }
