	
	function rotate() {	
	
		var num = parseInt($("span.selected:first").attr("id"));
		num = num + 1;
		
		if (num == 6) {num = 1;}
				
		var filename = $("span[id="+num+"]").attr("rel");
		
		$("img.slideshow-bg").attr("src", filename);
		$("img.slideshow").fadeOut(1000);
		
		myTimer = $.timer(1000, function(){
			$("img.slideshow").attr("src", filename);
			$("img.slideshow").fadeIn(1);
		});		
		
		$("span.selected").attr("class", "pending");
		$("span[id="+num+"]").attr("class", "selected");
	
	};

$(function() {
    
	$("span").click(function() {
		var myTimer = {};
		var filename = $(this).attr("rel");
		
		$("img.slideshow-bg").attr("src", filename);
		$("img.slideshow").fadeOut(1000);
		
		myTimer = $.timer(1000, function(){

			$("img.slideshow").attr("src", filename);
			$("img.slideshow").fadeIn(1);
			
		});		
		
		$("span.selected").attr("class", "pending");
		$(this).attr("class", "selected");

		
	});
	
	// tu urobime automaticke rotovanie
	
	/*	
	for (i = 0; i <= 5; i++){
	
		$("span.selected").attr("class", "pending");
		$("span[id="+i+"]").attr("class", "selected");
		$("div.content").text(i);	
		
		$.timer(1000,function(){
				alert('A Delayed Hello!');
		});
	
	}
	*/
	
	
	
	setInterval('rotate()', 5000);
	
	
	
});
