Traffic Light

The below code is about traffic light, when yo click next the next traffic light come step my step (First red than red and amber, than green and last one is again amber )
This code work but can anyone please tell me how to change this code or add a code to this code make traffic light the traffic light automatically, like you don’t have to click on the next button.
After every 1 second the traffic light will changes by it’s on self.
please help me.
Answer me please ASAP

<title>JavaScript Rollover 1</title>
	imgArray = new Array (4);
    imgArray[0] = new Image;
	imgArray[0].src = "Red light.jpg";
	imgArray[1] = new Image;
	imgArray[1].src = "Red,Amber light.jpg";
	imgArray[2] = new Image;
	imgArray[2].src = "Green light.jpg";
	imgArray[3] = new Image;
	imgArray[3].src = "Amber light.jpg";
	index = 0;

    function doBack()
        if(index > 0)
	function doNext()
	if(index < 3)

<img src="Red light.jpg" name="slideshow" 
    width=200 height=400>
<p><h3 align="center"><a href=javascript:doBack()>Back</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<a href=javascript:doNext()>Next</a></h3>


Please post a link to the exercise. Thank you.

Edit. Never mind. It is not one of CC’s exercises.