<!--
var helped = 0;
var pasted = 0;
var caretPos;

function quote() {
	var text = '';

	if (document.getSelection) {
		text = document.getSelection();
	} else if (document.selection) {
		text = document.selection.createRange().text;
	} else if (window.getSelection) {
		text = window.getSelection();
	}

	if (text == '') {
		if (helped != 1 && pasted != 1) {
			helped = 1; alert("Выделите текст и нажмите 'Цитировать'");
		}
		return false;
	} else {
		pasted = 1;
	}

	text = "<blockquote><B>Цитата:</B><BR>" + text + "</blockquote>";

	var t = document.all.msg;
	if (bw.ie && caretPos){
		caretPos.text = text;
		t.focus();
	} else {
//		caretPos.text = text;
		t.value += text;
		t.focus();
	}
	return false;
}

var bw = new checkBrowser();

function checkBrowser() {
	this.agent=navigator.userAgent;
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.win=this.agent.indexOf('Windows')>-1;
	this.mac=this.agent.indexOf("Mac")>-1;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie5=(this.ver.indexOf('MSIE 5')>-1 && this.dom)?1:0;
	this.ie6=(this.ver.indexOf('MSIE 6')>-1 && this.dom)?1:0;
	this.ie4mac=(this.ie4 && this.mac);
	this.ie5mac=(this.ie5 && this.mac);
	this.ns4=(document.layers && !this.dom)?1:0;
	this.ns6=(this.dom && parseInt(this.ver) >= 5)?1:0;
	this.ie=(this.ie4 || this.ie5 || this.ie6 || this.ie4mac || this.ie5mac);
	this.ns=(this.ns4 || this.ns6);
	this.w3c=(this.ie5 || this.ie6 || this.ns6 || this.ie5mac);
	this.bw=(this.ie4 || this.ie5 || this.ie6 || this.ns4 || this.ns6);
	return this;
}

function saveCaret(textarea){
	if (textarea.createTextRange) {
		caretPos = document.selection.createRange().duplicate();
	}
}
// -->
