function queryspr(uchwyt)
{
	if (uchwyt.query.value.length < 3) 
	{
		alert('Szukane wyrażenie musi mieć min. trzy znaki!');
		return false;
	}
	else
	{
		return true;
	}
}

function kontaktspr(uchwyt)
{
	if (uchwyt.imie.value.length < 1) 
	{
		alert('Pole \'imie i nazwisko\' nie może być puste.');
		return false;
	}
	if (uchwyt.telefon.value.length < 1) 
	{
		alert('Pole \'telefon\' nie może być puste.');
		return false;
	}
	if (uchwyt.email.value.length < 1) 
	{
		alert('Pole \'email\' nie może być puste.');
		return false;
	}
	if (uchwyt.tresc.value.length < 1) 
	{
		alert('Pole \'tresc\' nie może być puste.');
		return false;
	}
	else
	{
		return true;
	}
}

function uzytkownikspr(uchwyt)
{
	$error = 0;
	$errortxt = 'Nie zostały wypełnione wszystkie wymagane pola:\n';
	
	if (uchwyt.lo.value.length < 6) 
	{
		$errortxt = $errortxt + '- login musi posiadać minimum 6 znaków\n';
		$error = 1;
	}
	if (uchwyt.ha.value.length < 6) 
	{
		$errortxt = $errortxt + '- hasło musi posiadać się składać z minimum 6 znaków\n';
		$error = 1;
	}
	if (uchwyt.em.value.length < 3) 
	{
		$errortxt = $errortxt + '- poprawny adres email\n';
		$error = 1;
	}
	if (uchwyt.im.value.length < 1) 
	{
		$errortxt = $errortxt + '- imię\n';
		$error = 1;
	}
	if (uchwyt.na.value.length < 1) 
	{
		$errortxt = $errortxt + '- nazwisko\n';
		$error = 1;
	}
	if (uchwyt.te.value.length < 1) 
	{
		$errortxt = $errortxt + '- telefon\n';
		$error = 1;
	}
	if (uchwyt.ul.value.length < 1) 
	{
		$errortxt = $errortxt + '- adres osoby lub firmy -> ulica\n';
		$error = 1;
	}
	if (uchwyt.kp.value.length < 5) 
	{
		$errortxt = $errortxt + '- adres osoby lub firmy -> kod pocztowy\n';
		$error = 1;
	}
	if (uchwyt.mi.value.length < 2) 
	{
		$errortxt = $errortxt + '- adres osoby lub firmy -> miasto\n';
		$error = 1;
	}
	if ( (uchwyt.ra.value == 1) && (uchwyt.ni.value.length < 8) )
	{
		$errortxt = $errortxt + '- NIP (niezbędny do faktury)\n';
		$error = 1;
	}
	if (uchwyt.regulamin.checked != true) 
	{
		$errortxt = $errortxt + '- musisz zaakceptować warunki regulaminu\n';
		$error = 1;
	}
	
	if ($error == 1)
	{
		alert($errortxt);
		return false;
	}
	else
	{
		return true;
	}
	
}



function profilspr(uchwyt)
{
	$error = 0;
	$errortxt = 'Nie zostały wypełnione wszystkie wymagane pola:\n';
	
	if ( (uchwyt.ha.value.length > 0) && (uchwyt.ha.value.length < 6) )
	{
		$errortxt = $errortxt + '- nowe hasło musi posiadać się składać z minimum 6 znaków\n';
		$error = 1;
	}
	
	if (uchwyt.im.value.length < 1) 
	{
		$errortxt = $errortxt + '- imię\n';
		$error = 1;
	}
	if (uchwyt.na.value.length < 1) 
	{
		$errortxt = $errortxt + '- nazwisko\n';
		$error = 1;
	}
	if (uchwyt.te.value.length < 1) 
	{
		$errortxt = $errortxt + '- telefon\n';
		$error = 1;
	}
	if (uchwyt.ul.value.length < 1) 
	{
		$errortxt = $errortxt + '- adres osoby lub firmy -> ulica\n';
		$error = 1;
	}
	if (uchwyt.kp.value.length < 5) 
	{
		$errortxt = $errortxt + '- adres osoby lub firmy -> kod pocztowy\n';
		$error = 1;
	}
	if (uchwyt.mi.value.length < 2) 
	{
		$errortxt = $errortxt + '- adres osoby lub firmy -> miasto\n';
		$error = 1;
	}
	if ( (uchwyt.ra.value == 1) && (uchwyt.ni.value.length < 8) )
	{
		$errortxt = $errortxt + '- NIP (niezbędny do faktury)\n';
		$error = 1;
	}

	if ($error == 1)
	{
		alert($errortxt);
		return false;
	}
	else
	{
		return true;
	}
	
}

function checkBasket( waga )
{
	indeksC = document.getElementById('formkoszp').value;
	indeksCD = document.getElementById('formkoszd').value;
	
	if ( ( waga > 25 ) && ( indeksCD != 2 ) && ( indeksCD != 5 ) )
	{
		alert("Waga produktów w koszyku przekracza 25kg, dlatego jedyna dostępna forma przesyłki to 'Usługa Standard UPS MULTI PACZKA' lub 'Odbiór osobisty'");
		return false;
	}

	if ( ( indeksC == 5 ) && ( indeksCD != 5 ) )
	{
		alert("Jako formę płatności wybrałeś płatność przy odbiorze, dlatego jako formę dostawy musisz wybrać odbiór osobisty!");
		return false;
	}

	if ( ( indeksC == 4 ) && ( document.getElementById('zagiel_block').value == 'true' ) )
	{
		alert("Zamówiono produkty za kwotę poniżej 100zł - nie można skorystać z systemu ratalnego Żagiel. Wybierz inną formę zapłaty.");
		return false;
	}

	zagielC = document.getElementById('zagiel_zgoda').checked;


	
	if ( ( indeksC == 4 ) && ( !zagielC ) )
	{
		alert("Jako formę płatności wybrałeś system ratalny, ale nie zaznaczyłeś że zapoznałeś się z procedurą jego przyznania!");
		return false;
	}
	else
	{
		return true;
	}
}

function zapytajSpr(uchwyt, myTarget)
{
	if (uchwyt.imie.value.length < 1) 
	{
		alert('Pole \'imie i nazwisko\' nie może być puste.');
		return false;
	}
	if (uchwyt.telefon.value.length < 1) 
	{
		alert('Pole \'telefon\' nie może być puste.');
		return false;
	}
	if (uchwyt.email.value.length < 1) 
	{
		alert('Pole \'email\' nie może być puste.');
		return false;
	}
	if (uchwyt.tresc.value.length < 1) 
	{
		alert('Pole \'tresc\' nie może być puste.');
		return false;
	}
	else
	{
		Modalbox.show(myTarget, {title: 'Wysyłanie zapytania', width: 500, method: 'post', params: Form.serialize( 'zapytanieForm' ) } ); return false;
	}
}
