written function for infinite image loop in main.html page