/*
	Необходимые функции для работы форума

  [test] (c) 2004
*/
var sCurrentSelection = new String ("");

function Paste(sPasteString) {
  var textarea = document.reply.message;
	textarea.value = textarea.value + sPasteString;
};

function Quote () {
	if (sCurrentSelection != "") {
	  QuoteStr = "[quote]"+sCurrentSelection+"[/quote]";
	} else {
	  QuoteStr = prompt("Введите цитату",sCurrentSelection);
		if (QuoteStr != "null" && QuoteStr != "undefined") {
		  QuoteStr= "[quote]"+QuoteStr+"[/quote]";
		};
	};
	Paste(QuoteStr);
};

function InsertSelected () {
	if (sCurrentSelection != "") {
	  Paste("[i]"+sCurrentSelection+"[/i]");
	};
};

function SaveSelection () {
	if (document.getSelection) {
		sCurrentSelection = document.getSelection();
	} else {
	  sCurrentSelection = document.selection.createRange().text;
	};
	while (sCurrentSelection.indexOf("  ") !=-1) { // убираем двойные пробелы
	  sCurrentSelection = sCurrentSelection.replace(/  /gi, "") 
	};	
};

function PasteName(sName) {
  Paste("[b]"+sName+"[/b]\n");
};
