﻿function CF_Quote(id, oauthor) {
  var otext = document.getElementById('commentlist-' + id);
  var otextCommentArea = document.getElementById("comment");

  oauthor = '<a href="#comment-' + id + '" title="Перейти к комментарию этого автора">' + oauthor + '</a>';
  if (window.getSelection)
	 var sel = window.getSelection();
  else if (document.getSelection)
	 var sel = document.getSelection();
  else if (document.selection)
	 var sel = document.selection.createRange().text;
  if (otext.innerText){
	  if (sel != "") otextCommentArea.value += "<b>" + oauthor + "</b> писал(а):\n<blockquote>" + sel + "</blockquote>\n"; 
		else otextCommentArea.value += "<b>" + oauthor + "</b> писал(а):\n<blockquote>" + otext.innerText + "</blockquote>\n";
  }
  else { 
	  if (sel != "") otextCommentArea.value += "<b>" + oauthor + "</b> писал(а):\n<blockquote>" + sel + "</blockquote>\n"; 
		else otextCommentArea.value += "<b>" + oauthor + "</b> писал(а):\n<blockquote>" + otext.textContent + "</blockquote>\n";
  }
  otextCommentArea.focus();
}

function CF_Reply(id, oauthor) {
  var otextCommentArea = document.getElementById("comment");

  oauthor = '<a href="#comment-' + id + '" title="Перейти к комментарию этого автора">' + oauthor + '</a>';
  otextCommentArea.value += "<b>@ " + oauthor + "</b>:\n";
  otextCommentArea.focus();
}
