This question has already been answered:
How to make first i increase from 0 to 67, and then again decrease to zero at each step of the cycle?
function swap_image(){ $("#main__welcome___block--first__animation").attr("src", "static/main_photo/"+i+".jpg"); if(i < 80) i++; else i = 1; initial = setTimeout("swap_image()", 60); }