Disclaimer: I am trying to learn javascript. I am not a clever man.
So, I made a Jquery image slider. And I was proud. It works. It loads images, and it displays them one-after-another, day-in, day-out. Life was good.
Then I wanted to add navigation to the slider, and darkness fell upon my little kingdom.
When I click on one of the buttons, I call my LoadSlide function passing on the appropriate index LoadSlide(NewIndex). And then it runs the function, but it also continues running the function with the standard LoadSlide(index+1) argument. So without clicking any buttons it runs like so:
slide1 -> (6500ms) -> slide2 -> (6500ms) -> slide3 -> (6500ms) -> slide1 ...
And then I click a button (slide 2), and another loop starts in parallel:
slide1 -> (6500ms) -> slide2 -> (6500ms) -> slide3 -> (6500ms) -> slide1 ...
[click] slide2 -> (6500ms) -> slide3 -> (6500ms) -> slide1 -> (6500ms)...
Please advise me, keepers of the lore. Thou shall enjoy many maidens and endless measures of ale, if this dragon is slain.
Pitiful code is here: http://jsfiddle.net/V6svT/2/