  function galeria(fid, gid, ln){
    url = "galeria.php?fid="+fid+"&gid="+gid+"&ln="+ln;
    specs = "toolbar=no,directories=no,menubar=no,scrollbars=yes,width="+(800)+",height="+(600);
    open(url, "", specs);
  }  
  
  function druk(id){
    url     = 'druk.php?cid='+id;
    opcje   = "toolbar=no,directories=no,menubar=yes,scrollbars=yes,width=600,height=400";
    window.open(url, '', opcje);
  }

  function polec(cid, ctype, url, ln){
    url   = "polec.php?cid="+cid+"&ctype="+ctype+"&url="+url+"&ln="+ln;
	  specs = "toolbar=no,directories=no,menubar=no,scrollbars=auto,width=400,height=280";
    open(url, "", specs);
  }

  function bignews(gal,plik,szer,wys){
    url = "biger.php?rodz=news&id="+gal+"&nz="+plik+"&s="+szer+"&w="+wys;
    specs = "toolbar=no,directories=no,menubar=no,scrollbars=auto,width="+szer+",height="+wys;
    open(url, "", specs);
  }

  function big(plik, szer, wys){  
    url   = "big.php?id="+plik+"&wys="+wys+"&szer="+szer;
    
    if(szer>700) szer = 700;
    if(wys>500) wys = 500;
    
	  specs = "toolbar=no,directories=no,menubar=no,scrollbars=yes,width="+(szer+24)+",height="+(wys+24);
    open(url, "", specs);
  }
  
  
  function big_opis(plik, szer, wys, opis){
    url   = "big.php?id="+plik+"&wys="+wys+"&szer="+szer+"&opis="+opis;
    
    if(szer>700) szer = 700;
    if(wys>500) wys = 500;
    
	  specs = "toolbar=no,directories=no,menubar=no,scrollbars=auto,width="+(szer+24)+",height="+(wys+64);
    open(url, "", specs);
  }

  function search(){
    f = document.forms['search_form'];
    f.q.value = trim(f.q.value);
    if(f.q.value.length == 0){
      alert('Proszę podać słowa do wyszukania');
    } else {
      /*
      if(f.where[2].checked){
        url = 'http://www.google.com.pl/search?q='+f.q.value;
        win = window.open(url, "", "");
      } else if(f.where[0].checked){
      */
        f.kryt.value = 1;
        // f.action = 'index.php';
        f.submit();
      /*
      } else if(f.where[1].checked){
        f.kryt.value = 1;
        f.action = 'http://www.bip.powiat.wloclawski.pl/';
        f.submit();
      }
      */
    }
  } // search

  
  function trim(t){
    while(t.charAt(t.length-1) == ' '){
      t = t.substr(0, t.length-1);
    }
    while(t.charAt(0) == ' '){
      t = t.substr(1, t.length);
    }
    return t;
  } // trim


// window.onload=initClouds;

var galleryId = null;		
$(function() {
	   
	var idBoxGallery = $("#gallery ul.tabs-nav li").length;
	var idBoxGallery1 = idBoxGallery + 1
	var rotateTime = 4000;
	var rotateTimeInterval = 8000;
	if (idBoxGallery > 1) {
		function rotateGallery() {
			var current = parseInt($('#gallery ul.tabs-nav li.active').text());
			var next = (current + 1) % idBoxGallery1;
			if (0 == next) {
				next += 1;
			}
			$('#gallery ul.tabs-nav li').removeClass('active');
			$('.galleryPhoto' + next).addClass('active');
			$('div.galleryPhoto' + next).css("display","block");
			$('div.galleryPhoto' + current).css("display","none");
			window.clearInterval(galleryId);
			galleryId = window.setInterval(rotateGallery, rotateTime);		
		}
		
			galleryId = window.setInterval(rotateGallery, rotateTime);
		
		$('#gallery ul.tabs-nav li').click(function () {
			window.clearInterval(galleryId);
			galleryId = window.setInterval(rotateGallery, rotateTimeInterval);
			var current = parseInt($(this).text());
			$('#gallery ul.tabs-nav li').removeClass('active');
			$(this).addClass('active');
			$('div.galleryPhoto').css("display","none");
			$('div.galleryPhoto' + current).css("display","block");
			return false;
		});
	} else {
		$('#gallery ul.tabs-nav li').css("display","none");
	};

});
