
function insertQuote(nickname, text, post_id)
{
	if (text != "")
	{
		var insert_text = "[QUOTE='" + nickname + ";" + post_id + "']" + text + "[/QUOTE]";
		insertQuotedTextOrNick(insert_text, post_id);
	}
}
function insertNick(nickname, post_id)
{
	var insert_text = vB_Editor[QR_EditorID].wysiwyg_mode ? '<b>' + nickname + '</b>, ' : '[B]' + nickname + '[/B], ';
	insertQuotedTextOrNick(insert_text, post_id);
}
function activateQuickReply(post_id)
{
	quick_reply = fetch_object('qr_quickreply');
	if (quick_reply.disabled == true)
	{
		qr_activate(post_id);
	}
}
function textIsNotEmpty(textToCheck)
{
	var textToCheck = textToCheck.toLowerCase();
	if (textToCheck != '' && textToCheck != '<p></p>' && textToCheck != '<p>&nbsp;</p>' && textToCheck != '<br />' && textToCheck != '<br>' && textToCheck != '&nbsp;' && textToCheck != '<b></b>' && textToCheck != '<b></b><br>')
	{
		return true;
	}
	else
	{
		return false;
	}
}
function insertQuotedTextOrNick(text, post_id)
{
	activateQuickReply(post_id);
	var originalText = vB_Editor[QR_EditorID].get_editor_contents();
	var delimiter = '';
	var delimiter_length = 0;
	if (textIsNotEmpty(originalText) == true)
	{
		if (vB_Editor[QR_EditorID].wysiwyg_mode)
		{
			delimiter = '<br>';
			delimiter_length = 4;
		}
		else
		{
			delimiter = '\n';
			delimiter_length = 2;
		}
	}
	else
	{
		originalText = '';
	}
	vB_Editor[QR_EditorID].wysiwyg_mode ? vB_Editor[QR_EditorID].check_focus() : document.vbform.message.focus();
	if (originalText == '')
	{
		vB_Editor[QR_EditorID].write_editor_contents('', false);
	}
	vB_Editor[QR_EditorID].insert_text(delimiter + text, delimiter_length + text.length, 0);
}
function catchSelection()
{
	if (window.getSelection)
	{
		selection = window.getSelection().toString();
	}
	else if (document.getSelection)
	{
		selection = document.getSelection();
	}
	else if (document.selection)
	{
		selection = document.selection.createRange().text;
	}
}
