function CheckMessage()
{
 var oForm = document.forms['f_message'];

try
{
/*
 if (oForm.elements['new_author'].value == '')
 {
  alert('Представьтесь, пожалуйста!');
  oForm.elements['new_author'].focus();
  return false;
 }
*/
 if (oForm.elements['new_title'].value == '')
 {
  alert('Укажите тему сообщения!');
  oForm.elements['new_title'].focus();
  return false;
 }
 if (oForm.elements['new_title'].value.length > 100)
 {
  alert('Тема сообщения не может быть длиннее 100 символов!');
  oForm.elements['new_title'].focus();
  return false;
 }

 if (oForm.elements['new_body'].value.length < 5)
 {
  alert('Сформулируйте Ваше сообщение более развернуто!');
  oForm.elements['new_body'].focus();
  return false;
 }
/*
 if (oForm.elements['random'].value == '')
 {
  alert('Вы не указали контрольное число!');
  oForm.elements['random'].focus();
  return false;
 }
*/
}
catch(e)
{
 alert(e.description);
 return false;
}
 return true;
}

function CheckMessage2()
{
 var oForm = document.forms['f_message'];

 if (oForm.elements['new_title'].value == '')
 {
  alert('Укажите тему сообщения!');
  oForm.elements['new_title'].focus();
  return false;
 }
 if (oForm.elements['new_title'].value.length > 100)
 {
  alert('Тема сообщения не может быть длиннее 100 символов!');
  oForm.elements['new_title'].focus();
  return false;
 }

 if (oForm.elements['new_body'].value.length < 5)
 {
  alert('Сформулируйте Ваше сообщение более развернуто!');
  oForm.elements['new_body'].focus();
  return false;
 }

 return true;
}

function InsertSmile(img)
{
 var s = new String(img.src), arr;

 arr = s.split('/');
 s = arr[arr.length-1];
 arr = s.split('.');
 s = '[SM]' + arr[0] + '[/SM]';

 document.getElementsByName('new_body')[0].focus();

 if (document.selection)
 {
   var x = document.selection.createRange();
   x.text = s;
   x.select();
 }

 return s;
}

function OnLoadBody()
{
 var icnt, ip;

 if (document.forms['f_message'].elements['cur_page'].value == 'forum_ask')
 {
  if (document.getElementsByName('msg_count')[0].value != '')
  {
   icnt = parseInt(document.getElementsByName('msg_count')[0].value);
   ip   = parseInt(document.forms['f_message'].elements['p'].value);
   if (icnt > 19)
     document.forms['f_message'].elements['p'].value = ip + 1;
  }
 }
}
