$(document).ready(
function(){


$("#kloc").click(function(){$('#kloc').stop().animate({top: "-225"},500);});


var klik=0;

//podmiana duzej fotki
$("img.more_foto").click(function(){
	klik=1;
	$('#more').stop().animate({top: "0"},500, function(){klik=0;});

	var male=$(this).attr('src');
	var duze =male.slice(0,(male.length-6))+"_d."+male.slice((male.length-3),male.length);

	$('#foto_duze').attr('src',duze);
	
});

//odpalenie wideo
$(".more_video").click(function(){
	video=true;
	$("#videoplayer, #videoplayer_bg").show();
	$("#ytvideo").attr('src', $(this).attr('rel'));
	return false;
});
$("#videoplayer_bg, #player_close").click(function() {
	if (video)
	{
		$("#videoplayer").hide();
		$("#ytvideo").attr('src', '#');
		video = false;
	}
})

$("#more").mouseenter(function(){$('#more').stop().animate({top: "-225"},500, function(){klik=0;});});

$("#more_img").click(function(){$('#more').stop().animate({top: "-225"},500, function(){klik=0;});});


$("#more").mouseleave(function(){
if(klik==0){
$('#more').stop().animate({top: "0"},500);
}
});


var ile_fot = $('#pole_ruch .more_foto, #pole_ruch .more_video').length;
var ktora = 2;

if(ile_fot<3){
$("#prawo_more").css("display", "none");
}


//sprawdza czy moze isc w prawo
$("#prawo_more").click(function(){
if(ktora<ile_fot){
  $('#pole_ruch').animate({left: "-=160"},500);
  ktora++;
  
  //ukrywanie przyciskow
  $("#lewo_more").css("display", "block");
  if(ktora==ile_fot){
  $("#prawo_more").css("display", "none");
  }

}
});


$("#lewo_more").click(function(){
if(ktora>2){
  $('#pole_ruch').animate({left: "+=160"},500);
  ktora--;
  
  $("#prawo_more").css("display", "block");
  if(ktora==2){
  $("#lewo_more").css("display", "none");
  }

}
});


});

