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 = yes; //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)/3;		//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;
}

//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;
}

//pokazanie odpowiedniej warstwy
function showDiv(lp,id)
{
	var items = document.getElementsByTagName('div');
	var divName = 'div' + lp + '_';
	var headerName = 'header' + lp + '_';
	
	for (x in items)
  {
		if(items[x].id)
		{
			if(items[x].id.substr(0, 6) == divName)
			{
				items[x].style.display = 'none';
				$(items[x].id.replace(divName, headerName)).className = 'b1';
			}
		}
  }	

	$(divName + '[' + id + ']').style.display = 'block';
	$(headerName + '[' + id + ']').className = 'b2';
	
  return false;
}

//sprawdzanie formularza relacji
function CheckStory()
{
  var noSpaceLen = 60;
  if (document.getElementById('tytul').value=='')
  {
    window.alert('Proszę podać tytuł relacji !');
    document.getElementById('tytul').focus();
    return false;
  }
  if (document.getElementById('tresc').value=='' || document.getElementById('tresc').value.length < 10)
  {
    window.alert('Proszę podać treść relacji (min 10 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;
  }
//  document.getElementById('btStoryOk') = 'wysyłanie...';
//  document.getElementById('btStoryOk').disabled = 1;
  return true;
}

//sprawdzanie formularza galerii
function CheckGallery()
{
  if (document.getElementById('tytul').value=='')
  {
    window.alert('Proszę podać tytuł galerii !');
    document.getElementById('tytul').focus();
    return false;
  }
  if (document.getElementById('autor').value=='')
  {
    window.alert('Proszę podać autora galerii !');
    document.getElementById('autor').focus();
    return false;
  }
//  document.getElementById('btStoryOk') = 'wysyłanie...';
//  document.getElementById('btStoryOk').disabled = 1;
  return true;
}

