function valid()
{
  var error = 0; var errormsg='Обнаружены ошибки:\n';
  var regmailindex = new RegExp('^[0-9]+$','g');
  var regemail = new RegExp('^[0-9A-Za-z-@\.]+$','g');

  if(document.bill.name.value.length < 1) { error = 1; errormsg = errormsg + '\n- Не указаны Фамилия И.О.'; }
  if(document.bill.org.value.length < 1) { error = 1; errormsg = errormsg + '\n- Не указана Организация'; }
  if(document.bill.address.value.length < 1) { error = 1; errormsg = errormsg + '\n- Не указан Обратный адрес'; }
  if((!regmailindex.test(document.bill.mailindex.value)) || (document.bill.mailindex.value.length != 6)) { error = 1; errormsg = errormsg + '\n- Неверно задан почтовый индекс'; }
  if(document.bill.phone.value.length < 1) { error = 1; errormsg = errormsg + '\n- Не указан Контактный телефон'; }
  if((!regemail.test(document.bill.email.value)) || (document.bill.email.value.length < 1)) { error=1; errormsg = errormsg + '\n- Не указан Ваш e-mail адрес (или указан некорректно)'; }

  if(error == 0) { document.bill.submit(); }
  else { errormsg = errormsg + '\n\nКорректно заполните все поля формы и попробуйте снова.'; alert(errormsg); }
}

function recalculate()
{
  var bucks = 30;

  pricearray = document.bill.price.options[document.bill.price.options.selectedIndex].value.split('|');
//  document.bill.priceshow.value = Math.ceil(pricearray[1]*bucks) + " р.";
  document.bill.priceshow.value = Math.ceil(pricearray[1]) + " р.";

  versarray = document.bill.vers.options[document.bill.vers.options.selectedIndex].value.split('|');
//  document.bill.versshow.value = Math.ceil((pricearray[1]*versarray[1] - pricearray[1])*bucks) + " р.";
  document.bill.versshow.value = Math.ceil(pricearray[1]*versarray[1] - pricearray[1]) + " р.";

  updarray = document.bill.upd.options[document.bill.upd.options.selectedIndex].value.split('|');
//  document.bill.updshow.value = Math.ceil(pricearray[1]*versarray[1]*updarray[1]*bucks)*updarray[2] + " р.";
  document.bill.updshow.value = Math.ceil(pricearray[1]*versarray[1]*updarray[1] + Math.ceil(updarray[2]))*updarray[3] + " р.";

  delivarray = document.bill.deliv.options[document.bill.deliv.options.selectedIndex].value.split('|');
  document.bill.delivshow.value = Math.ceil(delivarray[1]) + " р.";

//  document.bill.itogoshow.value = Math.ceil(pricearray[1]*bucks) + Math.ceil((pricearray[1]*versarray[1] - pricearray[1])*bucks) + Math.ceil(pricearray[1]*versarray[1]*updarray[1]*bucks)*updarray[2] + Math.ceil(delivarray[1]) + " р.";
  document.bill.itogoshow.value = Math.ceil(pricearray[1]) + Math.ceil(pricearray[1]*versarray[1] - pricearray[1]) + Math.ceil(pricearray[1]*versarray[1]*updarray[1] + Math.ceil(updarray[2]))*updarray[3] + Math.ceil(delivarray[1]) + " р.";
}
