I have some code, mashed together with a lot of ignorance. I've done a terrible job of pairing it down until it does what I want. It works, but it's really messy and I think I might be complicating things.
I have a series of images, each one has a small version (1.gif) and a hidden, preloaded, large version (_1.gif). Click the small version and the large version replaces it. Click the large and it swaps back to the small version.
var lastMove;
lastMove = new Date();
function preload(arr) {for (var i=0; i<arr.length; i++) (new Image()).src = arr[i];}
var index = 0;
var picsA = ["1.gif", "_1.gif"];
preload(picsA); picNumberA = 0;
function showNextPicA() {if (new Date() - lastMove < 200) return false; if (picNumberA == (picsA.length -1)) {picNumberA = 0;} else {picNumberA = picNumberA + 1;}document.getElementById('placeholderA').src = pics1[picNumberA];}
var picsB = ["2.gif", "_2.gif"];
preload(picsB); picNumberB = 0;
function showNextPicB() {if (new Date() - lastMove < 200) return false; if (picNumberB == (picsB.length -1)) {picNumberB = 0;} else {picNumberB = picNumberB + 1;}document.getElementById('placeholderB').src = picsB[picNumberB];}
etc.
Is there a more efficient way of doing this? Perhaps even a way of seeking the large version automatically by adding that _ to the file name?
Thanks for reading, sorry for being so clumsy with this...