function do_koszyka(theForm, magazyn){

  if(theForm.sztuki.value=="" || theForm.sztuki.value=="0" || isNaN(theForm.sztuki.value))
  {
    theForm.sztuki.style.backgroundColor='#F20404';
    theForm.sztuki.focus();
    return (false);
  }else{
    theForm.sztuki.style.backgroundColor='';
  }
  
  if(theForm.sztuki.value>magazyn)
  {
    alert("Ilość zamawianych sztuk jest większa niż stan magazynowy.");
    theForm.sztuki.value="1";
    return (false);
  }
  
  return (true);
}

function sprawdzDane(theForm){


  if(theForm.imie.value=="")
  {
    theForm.imie.style.backgroundColor='#F20404';
    theForm.imie.focus();
    return (false);
  }else{
    theForm.imie.style.backgroundColor='';
  }

  if(theForm.nip.value=="")
  {
    theForm.nip.style.backgroundColor='#F20404';
    theForm.nip.focus();
    return (false);
  }else{
    theForm.nip.style.backgroundColor='';
  }
  
  if(theForm.adres.value=="")
  {
    theForm.adres.style.backgroundColor='#F20404';
    theForm.adres.focus();
    return (false);
  }else{
    theForm.adres.style.backgroundColor='';
  }
  
  if(theForm.miejscowosc.value=="")
  {
    theForm.miejscowosc.style.backgroundColor='#F20404';
    theForm.miejscowosc.focus();
    return (false);
  }else{
    theForm.miejscowosc.style.backgroundColor='';
  }
  
  if(theForm.kod_pocztowy.value=="")
  {
    theForm.kod_pocztowy.style.backgroundColor='#F20404';
    theForm.kod_pocztowy.focus();
    return (false);
  }else{
    theForm.kod_pocztowy.style.backgroundColor='';
  }
  
  if(theForm.telefon.value=="")
  {
    theForm.telefon.style.backgroundColor='#F20404';
    theForm.telefon.focus();
    return (false);
  }else{
    theForm.telefon.style.backgroundColor='';
  }

  return (true);
}

function sprawdzDaneKoszyk(theForm,status,ilosc){

 /*for(var i=0;i<ilosc;i++){
  var name="theForm.ilosc"+i;
  alert(name.value);
 }*/

if(status=="0"){
  if(theForm.imie.value=="")
  {
    theForm.imie.style.backgroundColor='#F20404';
    theForm.imie.focus();
    return (false);
  }else{
    theForm.imie.style.backgroundColor='';
  }

  /*if(theForm.nip.value=="")
  {
    theForm.nip.style.backgroundColor='#F20404';
    theForm.nip.focus();
    return (false);
  }else{
    theForm.nip.style.backgroundColor='';
  } */

  if(theForm.adres.value=="")
  {
    theForm.adres.style.backgroundColor='#F20404';
    theForm.adres.focus();
    return (false);
  }else{
    theForm.adres.style.backgroundColor='';
  }

  if(theForm.miejscowosc.value=="")
  {
    theForm.miejscowosc.style.backgroundColor='#F20404';
    theForm.miejscowosc.focus();
    return (false);
  }else{
    theForm.miejscowosc.style.backgroundColor='';
  }

  if(theForm.kod_pocztowy.value=="")
  {
    theForm.kod_pocztowy.style.backgroundColor='#F20404';
    theForm.kod_pocztowy.focus();
    return (false);
  }else{
    theForm.kod_pocztowy.style.backgroundColor='';
  }

  if(theForm.telefon.value=="")
  {
    theForm.telefon.style.backgroundColor='#F20404';
    theForm.telefon.focus();
    return (false);
  }else{
    theForm.telefon.style.backgroundColor='';
  }

  if(theForm.email.value=="")
  {
    theForm.email.style.backgroundColor='#F20404';
    theForm.email.focus();
    return (false);
  }else{
    theForm.email.style.backgroundColor='';
  }

  if(theForm.email.value != "")
   {
	
	   if (!email_validate(theForm.email.value))
	  {
	    alert("Proszę podać poprawny adres e-mail.");
   		 theForm.email.focus();
		 return (false);
	  }
   }
	
    if (theForm.zgoda.checked == false)
     {
     alert("Wyrażam zgodę na przechowywanie i przetwarzanie moich danych...");
     return (false);
     }

 }


  return (true);
}

 function email_validate(src)
{
  var regex = /^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
  return regex.test(src);
}




