var timer = null;
var idx = 0;
function nextImage() {
if (timer) {
clearTimeout(timer);
}
if (idx >= rotator_images.length)
idx = 0;
var html = "";
html += "
";
html += "";
document.getElementById('rotating-image').innerHTML = html;
rotatorControls();
idx++;
timer = setTimeout('nextImage()', 5000);
}
function prevImage() {
idx = idx - 2;
if (idx < 0) {
idx = rotator_images.length - 1;
}
// does the rest of what we need
nextImage();
}
function selectImage(i) {
idx = i;
nextImage();
}
function rotatorControls() {
if (!document.getElementById)
return;
lyr = document.getElementById('rotator-controls');
controls = '';
if (lyr) {
for(i = 0 ; i < rotator_images.length; i++ ) {
if (i == idx) {
controls += '' + (i + 1) + '';
} else {
controls += '' + (i + 1) + '';
}
}
lyr.innerHTML = controls;
}
}
function rotatorInit() {
for (i=0; i < rotator_images.length; i++) {
new Image().src = rotator_images[i];
}
nextImage();
}
Event.observe(window, 'load', rotatorInit);