function Focus(control) {
  control.focus();
  control.select();
}

function IsEmailCorrect(email) {
  return email.match(/^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@([a-zA-Z0-9-]+\.)+([a-zA-Z]{2,4})$/)!=null;
}

function IsEmpty(pole) {
  if (pole=='') 
  	return true
	else
	return false
}

function formularz_sprawdz(form)
{
if (IsEmpty(form.firm.value)) {
    alert('Proszę podać nazwę firmy');
    Focus(form.firm);
    return false;
  }
if (IsEmpty(form.name.value)) {
    alert('Proszę podać imię i nazwisko');
    Focus(form.name);
    return false;
  }
if (IsEmpty(form.position.value)) {
    alert('Proszę podać stanowisko');
    Focus(form.position);
    return false;
  }
if (!IsEmailCorrect(form.email.value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(form.email);
    return false;
  }
if (IsEmpty(form.city.value)) {
    alert('Proszę podać miasto');
    Focus(form.city);
    return false;
  }
if (IsEmpty(form.phone.value)) {
    alert('Proszę podać telefon');
    Focus(form.phone);
    return false;
  }
if (IsEmpty(form.msg.value)) {
    alert('Proszę podać treść zapytania');
    Focus(form.msg);
    return false;
  }
return true;
}