function checkData()
 {
  if (document.form.NameEdit.value == '')
   {
    alert('Не заполнено обязательное поле "Имя".');
    document.form.NameEdit.focus();
    return false;
   };
  if (document.form.ImageEdit.value == '')
   {
    alert('Не заполнено обязательное поле "Результат операции".');
    document.form.ImageEdit.focus();
    return false;
   };
  if (document.form.MessageMemo.value == '')
   {
    alert('Не заполнено обязательное поле "Текст".');
    document.form.MessageMemo.focus();
    return false;
   };
  document.form.AddButton.disabled = true;
  return true;
 };

function showPreview()
 {
  if (checkData())
   {
    document.form.AddButton.disabled = false;
    var message = removeExtraCRLF(document.form.MessageMemo.value);
    message = stringReplace(message,'\r\n','<Br>');
    message = stringReplace(message,'\n','<Br>');
    if (document.form.MarkComboBox)
     {
      var mark = document.form.MarkComboBox.value;
      if (mark.substr(0,7) != 'Оценка ')
       {
        if (mark.substr(0,1) == '0') mark = mark.substr(1,mark.length);
        message = message + '<Br><Br>' + 'Моя оценка: ' + mark.substr(0,mark.indexOf(' - ')) + '/10 (' + mark.substr(mark.indexOf(' - ')+3,mark.length) + ').';
       };
     };
    top.PreviewWindow = window.open('','PreviewWindow','width=640,height=480,resizable=yes,menubar=no,toolbar=no,location=no,directories=no,scrollbars=yes,status=no');
    top.PreviewWindow.document.write('<HTML><Head><Title>Предпросмотр сообщения</Title><Style>HTML{Font-Size:80%;}*{Font-Size:100%;}A{Color:#884600;Text-Decoration:None;}A:Active{}A:HOver{Color:#E48F4C;}A:Visited{}BlockQuote{Border-Left:1px Solid Gray;Color:Gray;Padding-Left:1em;}Body{Font-Family:Arial,Helvetica,Sans-Serif,Times;Background-Color:White;}</Style></Head><Body OnLoad="self.focus();"><Table Width="100%" Border=0 CellPadding=3 CellSpacing=0><TR BgColor="#EAEAEA"><TD NoWrap><B>'+getDateTime()+'</B></TD><TD Width="100%" NoWrap><B>'+document.form.NameEdit.value+'</B></TD></TR><TR><TD ColSpan=2>'+message+'</TD></TR></Table></Body></HTML>');
    top.PreviewWindow.document.close();
   };
 };

