function servePostForm()
{
	d = document;
	errors = "";
	
	if (d.getElementById('fpostform').authorName.value == "") errors += "Введите ваше имя.\n";
	if (d.getElementById('fpostform').message.value == "") errors += "Введите сообщение.\n";

	if (errors != "") alert(errors);
	else d.getElementById('fpostform').submit();
}

function showHelp()
{alert("Теги:\n[b] жирный [/b]\n[i] курсив [/i]\n[u] подчёркнутый [/u]\n[s] зачёркнутый [/s]\n\nАдреса, начинающиеся с http://, преобразуются в ссылки автоматически.")}

function toggleSmilies()
{
	d = document;
	if (d.getElementById("smiliesSwitch").value == "Показать смайлы")
	{
		d.getElementById("smilies").style.display='block';
		d.getElementById("smiliesSwitch").value = "Спрятать смайлы";
	}
	else
	{
		d.getElementById("smilies").style.display = "none";
		d.getElementById("smiliesSwitch").value = "Показать смайлы";
	}
}

function updateCursorPos(elem)
{if (elem.createTextRange) elem.cursorPos = document.selection.createRange().duplicate();}

function insertSmile(text)
{
	var textarea = document.getElementById('message');
	text = " " + text + " ";
	if (textarea.createTextRange && textarea.cursorPos)
	{
		cursorPos = textarea.cursorPos;
		if (cursorPos.text.charAt(cursorPos.text.length - 1) == " ") cursorPos.text = cursorPos.text + text + ' '
		else cursorPos.text = cursorPos.text + text;
	}
	else textarea.value += text;
	
	textarea.focus();
}
