 function trim (str) {
     str = str.replace(/^\s+/, '');
     for (var i = str.length; --i >= 0;) {
          if (/\S/.test(str.charAt(i))) {
               str = str.substring(0, i + 1);
               break;
          }
     }
     return str;
}


	function CF_Quote(otextarea, oauthor) {
 		var otext = document.getElementById(otextarea);
 		var otextCommentArea = document.getElementById("comment");
  		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 += "[quote][b]" + oauthor + "[/b] пишет:\n" + sel + "[/quote]\n";
				else otextCommentArea.value += "[quote][b]" + oauthor + "[/b] пишет:\n" + trim(otext.innerText) + "[/quote]\n";
		  }
		  else {
			  if (sel != "") otextCommentArea.value += "[quote][b]" + oauthor + "[/b] пишет:\n" + sel + "[/quote]\n";
				else otextCommentArea.value += "[quote][b]" + oauthor + "[/b] пишет:\n" + trim(otext.textContent) + "[/quote]\n";
		  }
		  otextCommentArea.focus();
		}

function CF_Reply(oauthor)
{
  var otextCommentArea = document.getElementById("comment");
  otextCommentArea.value += "[b]" + oauthor + "[/b]:\n";
  otextCommentArea.focus();
}


