function Insert(text){

  insertText("[quote]" + text + "[/quote]\n");
}

function ins(text) {

  insertText("[b]" + text + "[/b]");
}

function insertText(text) {

	var textArea = document.REPLIER.Post;

	if (text != "") {

		if (textArea.caretPos) {

			textArea.caretPos.text = text;
		}
		else if (textArea.selectionStart > -1) {

			var start = textArea.selectionStart;
			var end = textArea.selectionEnd;
			var code = text

			var before_str = textArea.value.substring(0, start);
			var after_str = textArea.value.substring(end, textArea.value.length);

			textArea.value = before_str + code + after_str;

			textArea.selectionStart = start + code.length;
			textArea.selectionEnd = textArea.selectionStart;
		}
		else {

			textArea.value += text;
		}
	}
	
  textArea.focus();
}

function get_selection() {

	if (document.getSelection) {
	
		selection = document.getSelection();
	}
	else if (window.getSelection) {
	
		selection = window.getSelection();
	}
	else if (document.selection) {
	
		selection = document.selection.createRange().text;
	}
	else {
	
		alert("Неподдерживаемый браузер");
		
		selection = "";
	}
}