 var index = 0, size = 0, timeout = 0;
     function move_to(i){
         index = i;
         clearTimeout(timeout);
         next_move();
     }

     function next_move(){
               $("#samples li").hide();
               $("#samples .pagination span").removeClass("selected");
               $("#samples .pagination span").eq(index).addClass("selected");
               $("#samples li").eq(index).show();
               $("#samples li").eq(index).find("img").hide().fadeIn();
               index ++;
               if(index >= size)  index = 0;
               timeout = setTimeout("next_move()",5000);
           }

    $(function(){
                index = 1;
                size = $("#samples li").length;
                var span = ""; 
                for(var i = 0; i < size; i ++){ 
                        if(i == 0)
                         span += "<span class='selected' onclick='move_to(" + i + ")' ></span>";
                        else
                         span += "<span onclick='move_to(" + i + ")' ></span>";
                }

                $("#samples .pagination").html(span);
                 timeout = setTimeout("next_move()",5000);
               

    });
