function openW(strona,width_,height_,sc){
         new_window = window.open(strona,'strona','width='+width_+',height='+height_+',toolbars=no,resizeble="no",scrollbars='+sc);
}

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,3})$/)!=null;
}

function IsEmpty(pole) {
  if (pole=='') 
  	return true
	else
	return false
}

function sprawdz()
{
if (IsEmpty(document.getElementById('f1').value)) {
    alert('Proszę podać nazwę firmy.');
    Focus(document.getElementById('f1'));
    return false;
  }
if (IsEmpty(document.getElementById('f2').value)) {
    alert('Proszę podać imię i nazwisko.');
    Focus(document.getElementById('f2'));
    return false;
  }
if (!IsEmailCorrect(document.getElementById("f5").value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(document.getElementById("f5"));
    return false;
  }
return true;
}

function newsletterwypisz()
{
if (!IsEmailCorrect(document.getElementById('newsletterform').mail.value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(form.mail);
    return false;
  }
document.getElementById('newsletterform').opcja.value="wypisz";
document.getElementById('newsletterform').submit();
}

function newsletterdodaj()
{
if (!IsEmailCorrect(document.getElementById('newsletterform').mail.value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(form.mail);
    return false;
  }
document.getElementById('newsletterform').submit();
}

function sprawdz_newsletter(form)
{
if (!IsEmailCorrect(form.mail.value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(form.mail);
    return false;
  }
return true;
}

function sprawdz_pola(form)
{
if (IsEmpty(form.imie.value)) {
    alert('Proszę podać imię');
    Focus(form.imie);
    return false;
  }
if (IsEmpty(form.nazwisko.value)) {
    alert('Proszę podać nazwisko');
    Focus(form.nazwisko);
    return false;
  }  
if (IsEmpty(form.ulica.value)) {
    alert('Proszę podać ulicę');
    Focus(form.ulica);
    return false;
  }  
if (IsEmpty(form.numer_domu.value)) {
    alert('Proszę podać numer domu');
    Focus(form.numer_domu);
    return false;
  }  
if (IsEmpty(form.miejscowosc.value)) {
    alert('Proszę podać miejscowość');
    Focus(form.miejscowosc);
    return false;
  }  
if (IsEmpty(form.kod_pocztowy.value)) {
    alert('Proszę podać kod pocztowy');
    Focus(form.kod_pocztowy);
    return false;
  } 
if (form.elements[6].selectedIndex==0) {
    alert('Proszę wybrać województwo');
    return false;
  } 
if (!IsEmailCorrect(form.mail.value)) {
    alert('Proszę podać poprawny adres e-mail');
    Focus(form.mail);
    return false;
  }
if (form.haslo.value.length<3) {
    alert('Prosze podać hasło\n Hasło musi posiadać conajmniej 3 znaki');
    Focus(form.haslo);
    return false;
  }
if (form.haslo.value!=form.haslo_pow.value) {
    alert('Podane hasła powinny być identyczne');
    Focus(form.haslo);
    return false;
  }   

if (form.faktura.checked==true) {	
	if (IsEmpty(form.nip.value)) {
    	alert('Proszę podać NIP');
    	Focus(form.nip);
    	return false;
  	  }
	if (IsEmpty(form.nazwa_firmy.value)) {
    	alert('Proszę podać nazwę firmy');
    	Focus(form.nazwa_firmy);
    	return false;
  	  }
	if (IsEmpty(form.faktura_imie.value)) {
    	alert('Proszę podać imię');
    	Focus(form.faktura_imie);
    	return false;
  	  }
	if (IsEmpty(form.faktura_nazwisko.value)) {
    	alert('Proszę podać nazwisko');
    	Focus(form.faktura_nazwisko);
    	return false;
  	  }
	if (IsEmpty(form.faktura_ulica.value)) {
    	alert('Proszę podać ulicę');
    	Focus(form.faktura_ulica);
    	return false;
  	  }
	if (IsEmpty(form.faktura_numer_domu.value)) {
    	alert('Proszę podać numer domu');
    	Focus(form.faktura_numer_domu);
    	return false;
  	  }
	if (IsEmpty(form.faktura_miejscowosc.value)) {
    	alert('Proszę podać miejscowość');
    	Focus(form.faktura_miejscowosc);
    	return false;		
  	  }
	if (IsEmpty(form.faktura_kod_pocztowy.value)) {
    	alert('Proszę podać kod pocztowy');
    	Focus(form.faktura_kod_pocztowy);
    	return false;
  	  }	
	if (form.elements[18].selectedIndex==0) {
    	alert('Proszę wybrać województwo');
    	return false;
  	  } 
  }
  
return true;
}

function kopiuj(form)
{
document.zamowienie.faktura_imie.value=document.zamowienie.imie.value;
document.zamowienie.faktura_nazwisko.value=document.zamowienie.nazwisko.value;
document.zamowienie.faktura_ulica.value=document.zamowienie.ulica.value;
document.zamowienie.faktura_numer_domu.value=document.zamowienie.numer_domu.value;
document.zamowienie.faktura_miejscowosc.value=document.zamowienie.miejscowosc.value;
document.zamowienie.faktura_kod_pocztowy.value=document.zamowienie.kod_pocztowy.value;
document.zamowienie.elements[17].value=document.zamowienie.elements[6].value;
}

