function properPhone(id)
{
	var _inp;
	if (_inp = document.getElementById(id))
	{
		var _value = _inp.value;
		_inp.value = _value.replace(/(^0+)?[\D]+/g, "");
	}
	else
	{
		window.alert("Unknown element ID: " +id);
	}
}
function validEmail (email) {
  invalidChars = " /:,;"
  if (email=="") { return false }
  for (i=0; i<invalidChars.length; i++) {
    badChar = invalidChars.charAt(i)
    if (email.indexOf (badChar, 0) != -1) { return false }
  }
  atPos = email.indexOf ("@", 0)
  if ((atPos == -1) || (atPos == 0)) { return false }
  if (email.indexOf ("@", atPos+1) != -1) { return false }
  periodPos = email.indexOf (".", atPos)
  if ((periodPos == -1) || (periodPos == atPos+1)) { return false }
  if (periodPos+3>email.length == -1) { return false }
  return true
}
function sprawdz (form) {
properPhone('telefon');

  if (!(form.imie.value)) {
      alert ("\nBrak imienia i nazwiska osoby zamawiającej.");
      form.imie.focus()
      form.imie.select() 
      return false
  }
    if (!(form.nazwa.value)) {
      alert ("\nBrak nazwy firmy.");
      form.nazwa.focus()
      form.nazwa.select() 
      return false
  }
  if (!(form.ulica.value)) {
      alert ("\nBrak nazwy ulicy.");
      form.ulica.focus()
      form.ulica.select() 
      return false
  }
  if (!(form.kod.value)) {
      alert ("\nBrak kodu pocztowego.");
      form.kod.focus()
      form.kod.select() 
      return false
  }
  if (!(form.miejscowosc.value)) {
      alert ("\nBrak nazwy miasta.");
      form.miejscowosc.focus()
      form.miejscowosc.select() 
      return false
  }
  if (!(form.telefon.value)) {
    alert ("\nBrak lub zły numer telefonu.");
    form.telefon.focus()
    form.telefon.select() 
    return false
  }  
     
  if (!(validEmail(form.semail.value))) {
    alert ("\nBrak lub zły adres e-mail.");
    form.email.focus()
    form.email.select() 
    return false
  }
  


}

