function CheckProbe(f)
{
	for(i=0; i<f.elements['sonda'].length; i++)
	{
		if(f.elements['sonda'][i].checked)
		{
			f.submit();
			return false;
		}
	}
	alert('Nie zaznaczono żadnej opcji !!!');
	return false;;
}


okno=null;
function OpenWindow(plik,_width,_height,sbars)
{
				if (_width==null) _width=100;
				if (_height==null) _height=100;
				
				yes = 1;	no = 0;

				//musza byc:
				_fullscreen = yes;
				_toolbar = no; //pasek narzedzi
				_location = no; //pasek adresu
				_directories = no; //pasek
				_menubar = no; //pasek menu
				_status = no; //stopka

			 if (sbars==null) 
			 {
				 _scrolling = no;
				 _scrollbars = no;
			 }
			 else 
			 {
				 _scrolling = yes;
				 _scrollbars = yes;
			 }

			 _resizable = no;

				_top = screen.availHeight;	//polozenie na ekranie - dol ekranu
				_left = screen.availWidth;	//polozenie na ekranie - dol ekranu
				_top = (_top-_height)/2;		//wysrodkowanie w poziomie
				_left = (_left-_width)/2; 	//wysrodkowane w pionie

				//budowa stringu
				_features = "'fullscreen=" + _fullscreen + ",toolbar=" + _toolbar + ",location=" + _location + ",directories=" + _directories + ",menubar=" + _menubar + ",status=" + _status + ",scrolling=" + _scrolling + ",scrollbars=" + _scrollbars + ",resizable=" + _resizable + ",width=" + _width + ",height=" + _height + ",top=" + _top + ",left=" + _left + "'";

				if (okno!=null) 
				{
					okno.close();
				}
				okno=window.open(plik,'cms',_features);

				okno.focus();
}

//sprawdzenie czy obrazek nie ma większego rozmiaru od dopuszczalnego, jeśli tak to ustawiam maksymalną szerokość
function checkImageSize(image,width)
{
	if(image.width > width)
		image.width = width;
}

//sprawdzenie formularza logowania
function check_logowanie(form)
{
				if (form.login.value=='')
				{
					window.alert('Brak identyfikatora ! Proszę wpisać login.')
					form.login.focus();
					return false;
				} else
				if (form.haslo.value=='')
				{
					window.alert('Brak hasła ! Proszę wpisać hasło.')
					form.haslo.focus();
					return false;
				} else
				{
					form.btOk.disabled = 1;
					form.btOk.value = 'Logowanie...';
					return true;
				}
}

//funkcja otwierające nowe okno z obrazkiem i jego opisem
function ShowImage(id)
{
  //tworzenie okna
  okienko=window.open("image.php?id=" + id,"obraz","width=300,height=400,top=10,left=150,scrollbars=0");
	return false;
}

//sprawdzanie formularza komentarza
function CheckComment()
{
	var noSpaceLen = 60;
	if (document.getElementById('tresc').value=='' || document.getElementById('tresc').value.length < 5)
	{
		window.alert('Proszę podać treść komentarza (min 5 znaków) !');
		document.getElementById('tresc').focus();
		return false;
	}
	if(CheckTextSpace(document.getElementById('tresc').value, noSpaceLen) == false)
	{
		window.alert('Text powinien zawierać spację przynajmniej jedną na ' + noSpaceLen + ' znaków !!');
		document.getElementById('tresc').focus();
		return false;
	}
	if (document.getElementById('nick').value=='')
	{
		window.alert('Proszę podać swój podpis !');
		document.getElementById('nick').focus();
		return false;
	}
	document.getElementById('btOk').disabled = 1;
	document.getElementById('btOk') = 'wysyła...';
	return true;
}

//sprawdzanie długości treści pola textarea
function CheckLength(len)
{
	if(document.getElementById('tresc').value.length > len)
	{
		alert('Treść komentarza nie może być większa niż ' + len + ' znaków');
		document.getElementById('tresc').value = document.getElementById('tresc').value.substr(0, 500); 
		return false;
	}
	return true;
}

function checkEmail(mail)
{
  var dobryEmail=/^[^@]+@([a-z0-9\-]+\.)+[a-z]{2,4}$/i;
  if (dobryEmail.test(mail))
    return true;
  else 
  {
    alert('"' + mail + '" - to nie jest poprawny adres e-mail !');
    return false;
  }
}

//sprawdzanie formularza kontaktu
function CheckMainForm()
{
	if (document.getElementById('informacja').value=='' || document.getElementById('informacja').value.length < 5)
	{
		window.alert('Proszę podać treść informacji (min 5 znaków) !');
		document.getElementById('informacja').focus();
		return false;
	}
	if (document.getElementById('email').value=='')
	{
		window.alert('Proszę podać swój adres e-mail !');
		document.getElementById('email').focus();
		return false;
	}
	if(checkEmail(document.getElementById('email').value) == false)
	{
		document.getElementById('email').focus();
		return false;
	}
	return true;
}

//sprawdzanie formularza ogłoszenia
function CheckNoticeForm()
{
	var noSpaceLen = 50;
	if (document.getElementById('tytul').value=='')
	{
		window.alert('Proszę podać tytuł ogłoszenia !');
		document.getElementById('tytul').focus();
		return false;
	}
	if (document.getElementById('opis').value=='' || document.getElementById('opis').value.length < 5)
	{
		window.alert('Proszę podać treść ogłoszenia (min 5 znaków) !');
		document.getElementById('opis').focus();
		return false;
	}
	if(CheckTextSpace(document.getElementById('opis').value, noSpaceLen) == false)
	{
		window.alert('Text powinien zawierać spację przynajmniej jedną na ' + noSpaceLen + ' znaków !!');
		document.getElementById('opis').focus();
		return false;
	}
	if (document.getElementById('telefon').value=='')
	{
		window.alert('Proszę podać dane kontaktowe (telefon, email itp.) !');
		document.getElementById('telefon').focus();
		return false;
	}
	return true;
}

//sprawdzanie czy są spacje w wystarczającej szerokości
function CheckTextSpace(t,len)
{
	var last = 0;
	for(i=0; i<t.length; i++)
	{
		if(t.charAt(i) == ' ')
		{
			if(i-last > len)
			{
				return false;
			}else
				last = i;
		}
	}
	if(t.length-1 - last > len)
		return false;
	return true;
}


