
$(document).ready(function(){
	
	rotate = function(){		
		var dl = $("#fotki img").length;
		$("#fotki img").each(function(n){
			var zi = $(this).css('z-index');
			if (zi=='20'+dl) {
				$(this).animate({'opacity':'0'},'slow',function(){
					$(this).css('z-index','201');
					$(this).css('opacity','1');					
				});									
			}
			$(this).css('z-index',(Number(zi)+1));
		});
	}

	var int_id;
	//int_id=setInterval(rotate,6000);
	
	//$('#fotki').bind('mouseover',function(){clearInterval(int_id);});
	//$('#fotki').bind('mouseout',function(){int_id=setInterval(rotate,6000);});
	
	$('#slider').nivoSlider({
		effect:'fade',
		directionNav:false,
		controlNav:false,
		slices:15,
		pauseTime:6000
	
	});
	
	$("#gal_next").bind("click",function(e){
		var poz_id = $("#gal_pasek > a:eq(7)").attr("id").substr(4);
		/*poz_id = poz_id.substr(4);*/
		
		$.ajax({
			type: "GET",
			url: "ajax.php",
			data: "module=gallery&dir=down&id_poz="+poz_id,
			dataType: "html",
			success: function (data, textStatus) {
				if(data.length>0){
					$("#gal_prev").attr("src","./images/st_lewa.gif");
					$("#gal_pasek > a:first").remove();
					$("#gal_pasek").append(data);
				}
				else $("#gal_next").attr("src","./images/st_prawa_deact.gif");
			}
		});
		e.preventDefault();
	});
	
	$("#gal_prev").bind("click",function(e){
		var poz_id = $("#gal_pasek > a:first").attr("id").substr(4);
		
		$.ajax({
			type: "GET",
			url: "ajax.php",
			data: "module=gallery&dir=up&id_poz="+poz_id,
			dataType: "html",
			success: function (data, textStatus) {
				if(data.length>0){
					$("#gal_next").attr("src","./images/st_prawa.gif");
					$("#gal_pasek > a:last").remove();
					$("#gal_pasek").prepend(data);
				}
				else $("#gal_prev").attr("src","./images/st_lewa_deact.gif");
			}
		});
		e.preventDefault();
	});
	
	
});
function okno(pole) {

 mywin=window.open(pole,'Note','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=5,height=5');

}
