
$move_by = 160;
$automat = 1;
$frame_left = 12;
$frame_no = 0;
$start_middle = 0;
$stav=0;

$(document).ready(function()
{
	$max_clicks = $("#znacky ul").children().size(); 
	/* Kudos to Rob MacKay [http://www.twitter.com/svgrob] for suggesting that we don't have to put a static style="width: 3960px" attribute in the div tag */
	$imgCont = $move_by * $max_clicks; 
	$test_clicks = $max_clicks - 5;
	
	$("#znacky ul").css({width : $imgCont});
	
	function dalej()
		{
			/* Set the new position & frame number */
			$new_frame_no = (($frame_no/1)+1);
			$new_left = (($frame_left/1) - $move_by);
			/* Check if we're moving too far over */
			if($new_frame_no > ($test_clicks-1))
				{		
					/* Move all the way right, to the beginning*/
					$new_left = 0;
					$new_leftik = $new_left+"px";
					$("#znacky ul").animate({left: $new_leftik}, 10);
					$new_left =-($move_by);
					$new_frame_no = 1;
				}				
			$new_left_attr = $new_left+"px";
			$("#znacky ul").animate({left: $new_left_attr}, 800 );
			$frame_left = $new_left;
			$frame_no = $new_frame_no;
		}

function slucka(){
  setTimeout(function() {
				dalej();	  
			   slucka();
               }, 2000);
  }
  slucka();
 });
