function openBox(pop_id)
{
  popw = 500; poph = 360;
  winprop = "scrollbars=yes,resizable=yes,status=no,menubar=no,width=" + popw + ",height=" + poph;
  xpos = (screen.width - popw) / 2; ypos = (screen.height - poph) / 2;

  if (navigator.appName.indexOf('icrosoft') == -1)
    winprop = winprop + ",screenX=" + xpos + ",screenY=" + ypos;
  else
    winprop = winprop + ",left=" + xpos + ",top=" + ypos;
  pophnd = window.open('box.php?id=' + pop_id, name, winprop);
  pophnd.focus();
}

function checkField(field, mesg)
{
  if (field.value != '') return true;
  alert(mesg);
  return false;
}

function checkFormMail(form)
{
  var exclude = /[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
  var check = /@[\w\-]+\./;
  var checkend = /\.[a-zA-Z]{2,3}$/;
  var mesg = "";

  if (form.name.value == '') mesg += "Devi inserire il tuo nome.\n";

  if (((form.email.value.search(exclude) != -1) ||
       (form.email.value.search(check)) == -1) ||
       (form.email.value.search(checkend) == -1) ||
       (form.email.value == ''))
    mesg += "Devi inserire una e-mail valida!\n";

  if (form.subject.value == '') mesg += "Devi inserire un soggetto.\n";

  if (form.xmessage.value == '') mesg += "Devi inserire un messaggio!\n";

  if (mesg.length) {
    alert(mesg);
    return false;
  }

  return true;
}

function checkLogin(form)
{
  if ((form.uid.value != '') && (form.pwd.value  != '')) return true;
  alert('Devi inserire uno username ed una password!');
  return false;
}
