var data = new Array();
data[0] = '/content_files/slideshow/departments/library.jpg';
data[1] = '/content_files/slideshow/departments/firetruck.jpg';
data[2] = '/content_files/slideshow/departments/police.jpg';
var timer = new Ext.util.DelayedTask();
var current_image = 0;
Ext.onReady(function() {
if (Ext.get("slideshow")) {
var links = "";
// Create the bottom links for the slideshow
for (var i = 0; i < data.length; i++) {
links += '' + (i + 1) + '';
if (i != data.length - 1) {
links += ' | ';
}
}
Ext.get("slideshow_links").update(links);
rotate(Math.floor(Math.random() * data.length));
timer.delay(2000, play);
}
});
// Function to rotate the images
function rotate(image) {
current_image = image;
Ext.getDom("slideshow_image").src = data[image];
for (var i = 0; i < data.length; i++) {
Ext.get("link_" + i).update(i + 1);
}
Ext.get("link_" + image).update("" + (image + 1) + "");
}
function play() {
if (current_image == data.length - 1) {
current_image = 0;
} else {
current_image++;
}
rotate(current_image);
timer.delay(2000, play);
}