count_step = 5; // Pocet polozek na obratku ve slideru
count = 0; // Aktualni pocet 
loading = false; // Prubeh obratky

$(document).ready(function(){
	$("#footer .b_prev").click(function(){
		slider("left");
	});
	$("#footer .b_next").click(function(){
		slider("right");
	});
	setInterval("slider('right')", 10000);

	$(".phpwcmsArticleListEntry:eq(0)").before("<h1>Aktuality</h1>");
});

function slider(direction) {
	if (!loading) {
		loading = true;
		var width = $("#footer .canvas").width();
		var size = $("#footer .images .imageEntry").size();
		var actM = parseInt($("#footer .images").css("margin-left"));
		var newM = actM - width;
		if (direction == "left") {
			newM = actM + width;
			count -= count_step;
			if (actM == 0) {
				newM = 0;
				count = 0;
			}
		} else {
			count += count_step;
			if (count >= size) {
				newM = 0;
				count = 0;
			}
		}
		$("#footer .images").animate({marginLeft:newM+"px"},500, function(){ loading = false });
	}
}
