function CheckContactForm() {
  if ( !check_nonempty(document.ContactForm.inp_name) ||
       !check_nonempty(document.ContactForm.inp_email) ||
       !check_nonempty(document.ContactForm.inp_text) )
  {
    alert("Не заполнено обязательное поле");
    return false;
  }

  if ( !check_email(document.ContactForm.inp_email) )
  {
    alert("Неверный формат e-mail адреса");
    return false;
  }
}

function check_nonempty(obj) {
  var val = obj.value;
  if (val.replace(/(^\s*)|(\s*$)/g, "") == "") return false;
  return true;
}

function check_email(obj) {
  var nn;
  nn = /^[\w\.-]+@[\w\.-]+\.\w\w+$/;
  if ( !obj.value.match(nn) ) return false;
  return true;
}

function is_number(c) {
  if ("0123456789".indexOf(c) != -1) return true;
  else return false;
}

function ImagePopup(imgPath, title, alt) {
  var winTop = Math.round(screen.availHeight / 2) - 280;
  var winLeft = Math.round(screen.availWidth / 2) - 280;
  var winFeatures = "width=560,height=560,";
  winFeatures = winFeatures + "left=" + winLeft + ",";
  winFeatures = winFeatures + "top=" + winTop + ",";
  winFeatures = winFeatures + "resizable=1,";
  winFeatures = winFeatures + "scrollbar=0,";
  winFeatures = winFeatures + "status=0";
  var win = window.open("", "Просмотр", winFeatures);
  var winDoc = win.document;

  if (title == undefined) title = "Просмотр";
  if (alt   == undefined) alt   = "";
  var content = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />' +
     '<title>' + title + '</title><link href="main.css" rel="stylesheet" type="text/css" /></head>' +
     '<body class="body-2"><table cols="1"><tr>&nbsp;</td></tr>' +
     '<tr><td><img alt="' + alt + '" id="image" src="' + imgPath + '" /></td></tr>' +
     '<tr><td>&nbsp;</td></tr>' +
     '<tr><td height="20px"><a href="javascript:self.close()" class="popup">Закрыть окно</a></td></tr>' +
     '</table></body></html>';
  win.document.write(content);
  win.document.close();
  win.focus();
}