var szukajStart = '';
var count = 0;
var currentId = 0;
var scConfig = {
		ajaxloadingmsg: 'Ładowanie zawartości galerii', //customize HTML to show while fetching Ajax content
        galleryid: 'mygallery0', //id of carousel DIV
        beltclass: 'belt', //class of inner 'belt' DIV containing all the panel DIVs
        panelclass: 'panel', //class of panel DIVs each holding content
        autostep: {enable:false, moveby:1, pause:5000},
        panelbehavior: {speed:1000, wraparound:true, persist:false},
        defaultbuttons: {enable: true, moveby: 1, leftnav: ['img/galeria_button_left.gif', -40, 55], rightnav: ['img/galeria_button_right.gif', 8, 55]}, //-40 18
        statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
        contenttype: ['ajax', 'ajax/galeria.html'] //content setting ['inline'] or ['external', 'path_to_external_file']
     }
function switchPhoto(id, max) {
	$('#photo_' + id).hide();
	id = (id == max - 1 ? 0 : id + 1);
	$('#photo_' + id).fadeIn();
	setTimeout("switchPhoto("+id+", "+max+")", 10000);
}
function loadGallery (sciezka) {
 	scConfig.contenttype[1] = sciezka;
 	stepcarousel.getremotepanels($, scConfig);
    return false;
}
		function showSlide (slideNr) {
		    $('#nawigacjaPrzyciski span.podswietl').removeClass('podswietl');
		    $('#nawigacjaPrzyciski span:eq(' + slideNr + ')').addClass('podswietl');
		    $('#photoRotator .photoWrapper').hide();
		    if ($.browser.msie) {
		        $('#photoRotator .photoWrapper:eq(' + slideNr + ')').show();
		    } else {
		        $('#photoRotator .photoWrapper:eq(' + slideNr + ')').animate({"opacity": "show"}, 500);
		    }
		}
		var time = 0;
		var slideShow = false;
		function startSlideShow () {
		    slideShow = true;
		    nextSlide();
		}
		function nextSlide() {
		    var activeSlideNr = $('#nawigacjaPrzyciski span').index($('#nawigacjaPrzyciski span.podswietl'));
		    var slideCount = $('#photoRotator .photoWrapper').length;
		    var slideNr = ((activeSlideNr + 1) < slideCount) ?  activeSlideNr + 1 : 0;
		    showSlide(slideNr);
		    time = setTimeout(nextSlide,10000);
		}
		function newTimeout () {
		    slideShow = false;
		    clearTimeout(time);
		    time=setTimeout(nextSlide,10000);
		}
$(document).ready(function() {
	$("a[rel^='prettyPhoto']").prettyPhoto();
	szukajStart = $('#szukajSlowo').val();
	$('#szukajSlowo').focus(function() { if(this.value == szukajStart) this.value = ''; });
	$('#szukajSlowo').blur(function() { if(this.value == '') this.value = szukajStart; });
	$('.aBlank').click(function() { window.open($(this).attr('href'),'_blank'); return false; });
	
	$('#nawigacjaPrzyciski span').click(function () {
	var slideNr = $('#nawigacjaPrzyciski span').index(this);
	showSlide(slideNr);
	newTimeout();
	});
	startSlideShow();
});
