function Validator(theForm)
{

  if (theForm.user.value.replace(/(^\s*)|(\s*$)/g, "") == "")
  {
    alert("Поле \"Ваше имя\" пустое!");
    theForm.user.focus();
    return (false);
  }

  if (theForm.subject.value.replace(/(^\s*)|(\s*$)/g, "") == "")
  {
    alert("Поле \"Тема сообщения\" пустое!");
    theForm.subject.focus();
    return (false);
  }

  if (theForm.securitycode)
  {
  	if (theForm.securitycode.value.replace(/(^\s*)|(\s*$)/g, "") == "")
	{
	    alert("Поле \"Код\" пустое!");
	    theForm.securitycode.focus();
	    return (false);
	}
  }

  if (theForm.content.value.replace(/(^\s*)|(\s*$)/g, "") == "")
  {
    alert("Поле \"Сообщение\" пустое!");
    theForm.content.focus();
    return (false);
  }


  document.frmMsg.target='';

  return (true);
}

function AddSmile(code)
{
if (code != "") {
	if (document.selection) {

		document.frmMsg.content.focus();

		var txtContent = document.frmMsg.content.value;
		var str = document.selection.createRange();

		if (str.text == "") {
			str.text = code;
		} else if (txtContent.indexOf(str.text) != -1) {
			str.text = code + str.text;
		} else {
			document.frmMsg.content.value = txtContent + code;
		}
	}
	else
	{
		document.frmMsg.content.value = document.frmMsg.content.value + code;
	}
}

}

function AddCode(code1, code2)
{
	if (document.selection) {
			document.frmMsg.content.focus();

			var txtContent = document.frmMsg.content.value;
			var str = document.selection.createRange();

			if (str.text == "") {
				str.text = code1 + code2;
			} else if (txtContent.indexOf(str.text) != -1) {
				str.text = code1 + str.text + code2;
			} else {
				document.frmMsg.content.value = txtContent + code1 + code2;
			}
	}
	else
	{
		document.frmMsg.content.value = document.frmMsg.content.value + code1 + code2;
	}
}