var timer = null;
function change(){
/*Change these values according to your needs*/
if(typeof(step) == "undefined"){
newElem = document.createElement('img');
linkPause = document.createElement('a');
namePause = document.createTextNode("Pause");
linkPause.appendChild(namePause);
linkPause.setAttribute("onclick", "pause()");
linkPause.style.position = "absolute";
slideDiv = document.getElementById('slideshow'); //Name of the division that the slideshow will occur on
slideDiv.appendChild(newElem);
slideDiv.appendChild(linkPause);
extention = "jpg";
imgPath = "images/"
numImg = 2; //How many images you want to add in slideshow. Slides start from 1 and are limited with this variable
}
((typeof(step) != "undefined" && step<=numImg) ? step = step : step = 1);
newElem.src = imgPath + step + "." + extention;
step++;
timer = setTimeout("change()", 2000);
}
function pause(){
clearTimout(timer);
}
Basically create a variable that is going to hold the numeric value for your timer. Then when you pause, clearout the timer, essentially pausing it. If you need it to start again, call the change function.