
$(document).ready(function() {
	// wywolanie drukowania
	$('a.print').bind('click', function(){
		window.print();
		return false;
	});
  
	// przycisk powrotu
	$('a.back').bind('click', function(){
		history.back();
		return false;
	});
	
	//naglowki Sifr
	$('h2.sifr, h3.sifr').sifr({
	font: '/theme/js/helveticaneuelight',
		color: '#fff'
	});
   
   // [ TOOLTIP od projektu do  ]
	$("#steps ul li a").mouseover(function(e){
	  var title = $(this).attr("title");
	  $(this).attr("title","");
	  $('body').prepend("<div id='tooltip'></div>");
	  $('#tooltip').html(title);
	  $('#tooltip').css("left",e.pageX);
	  $('#tooltip').css("top",e.pageY);
	}).mousemove(function(e){
	  $('#tooltip').css("left",e.pageX);
	  $('#tooltip').css("top",e.pageY);
	}).mouseout(function(){
	  var title2 = $('#tooltip').html();
	  $('#tooltip').remove();
	  $(this).attr("title",title2);
	});
   
   /* GALERIA */
	// Pokazywanie, ukrywanie calej galerii
	var wysokosc = $("#gallery_images_list li").height();
	var wysokosc_outer = $("#gallery_images_list li").outerHeight({margin:true});
	var ilosc = $("#gallery_images_list li").length;
	var na_stronie = 4;
	var ilosc_li = Math.ceil(ilosc / na_stronie);
	var start = 0;
	var koniec = na_stronie;
	var wysokosc_new = ilosc_li * wysokosc_outer;
	if ( ilosc <= na_stronie ) {
		$("#gallery_images").addClass("no_buttons");
		$('a#all_gallery_switcher').hide();
	}
	$('a#all_gallery_switcher').toggle(
		function () {
		    $(this).children("em").css("display","inline");
		    $(this).children("span").css("display","none");
			$("#gallery_images_list li").show();
			$("#gallery_images_list").height(wysokosc_new);
			$("#gallery_images").addClass("no_buttons");
		},
		function () {
		    $(this).children("span").css("display","inline");
		    $(this).children("em").css("display","none");
			$("#gallery_images_list li").hide();
			$("#gallery_images_list li").slice(start, koniec).show();
			$("#gallery_images_list").height(wysokosc);
			$("#gallery_images").removeClass("no_buttons");
		}
	);
	
	// Nastepna porcja zdjec
	$('#gallery_images a.next').click(function(){
		if (koniec < ilosc) {
			$('#gallery_images a.prev').removeClass("prev_disabled");
			$("#gallery_images_list li").hide();
			start = start + na_stronie;
			koniec = start + na_stronie;
			$("#gallery_images_list li").slice(start, koniec).fadeIn("slow");
			if (koniec >= ilosc) {
				$(this).addClass("next_disabled");
			}
		};
		return false;
	});
	
	// Poprzednia porcja zdjec
	$('#gallery_images a.prev').click(function(){
		if (start > 0) {
			$('#gallery_images a.next').removeClass("next_disabled");
			$("#gallery_images_list li").hide();
			start = start - na_stronie;
			koniec = koniec - na_stronie;
			$("#gallery_images_list li").slice(start, koniec).fadeIn("slow");
			if (start == 0) {
				$(this).addClass("prev_disabled");
			}
		};
		return false;
	});
	
	// Wyrzucanie akcji z poprzedni i nastepny
	$('#gallery_images a.prev_disabled, #gallery_images a.next_disabled').click(function(){
		return false;
	});
	
});

