function Insert(qname,text){ if (text!=""){ qname=qname.replace(/[\[\]]/g, "|"); paste("[code]"+text+"[/code]\n", 0); } else { alert('Виділіть текст для цитування'); }} function paste(text,flag){ if ((document.selection)&&(flag)) { document.addform.message.focus(); document.addform.document.selection.createRange().text = text; } else document.addform.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; }