This is a javascript-based slideshow. You can jump forwards and backwards, to the beginning and the end, or run an automatic slide show. While the slideshow is running the next images is preloaded in the background. This slideshow is used for all picture-galleries on this site.
Source Code:
<!--
Copyright (c) 2006, Christoph Breidert, all rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name Christoph Breidert nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<html>
<head>
<title>Test Slideshow</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<script type="text/javascript">
images = new Array("snowspeeder.jpg", "falcon.jpg", "at_at.jpg", "xwing.jpg");
i = 0;
tmpimage = new Image();
max = images.length-1;
run=1;
timeout = 5;
function next(){
slideshowStop();
if(i<max)
i++;
else
return;
//show next image
document.getElementById("image").src=images[i];
setCurrentNumber();
//preload next image
preloadNext();
}
function previous(){
slideshowStop();
if(i>0)
i--;
else
return;
//show previous image
setCurrentNumber();
document.getElementById("image").src=images[i];
}
function first(){
slideshowStop();
setCurrentNumber();
//show first image
i = 0;
setCurrentNumber();
document.getElementById("image").src=images[i];
}
function last(){
slideshowStop();
//show last image
i = max;
setCurrentNumber();
document.getElementById("image").src=images[i];
}
function slide(){
if(i<max)
i++;
else {
run=0;
return;
}
//show next image
setCurrentNumber();
document.getElementById("image").src=images[i];
preloadNext();
}
function slideshowNext(){
if(run==0)
return;
slide();
setTimeout("slideshowNext()", timeout * 1000);
}
function slideshowStop(){
run=0;
}
function slideshowStart(){
tmp = document.getElementById("timeout").value;
if(tmp>0)
timeout = tmp;
else {
alert("Please set timeout in seconds (1-9)");
return;
}
run=1;
setTimeout("slideshowNext()", timeout * 1000);
}
function setCurrentNumber(){
c = i+1;
m = max+1;
document.getElementById("counter").innerHTML="Image number "+c+" of "+m;
}
function preload(){
ni = i+1;
tmpimage.src=images[ni]
ni = ni+1;
document.getElementById("status").innerHTML="Preloading image number "+ni;
}
function preloadNext(){
//preload next image afer 3 seconds
if(i+1<max) setTimeout("preload()", 3000);
}
</script>
</head>
<body>
<table>
<tr>
<td colspan="2">
<a href="javascript:first()"><<</a>
<a href="javascript:previous()"><</a>
<a href="javascript:next()">></a>
<a href="javascript:last()">>></a>
<a href="javascript:slideshowStart()">Start Slideshow</a>
<a href="javascript:slideshowStop()">Stop Slideshow</a>
Timeout <input id="timeout" name="timeout" type="text" size="1" maxlength="1" value="5"/>s (1-9)
</td>
</tr>
<tr><td colspan="2"> </td></tr>
<tr>
<td id="counter"> </td>
<td id="status" style="text-align:right;"> </td>
<script type="text/javascript">setCurrentNumber();
preloadNext();
</script>
</tr>
<tr>
<td colspan="2"><img id="image" src="snowspeeder.jpg"/></td>
</tr>
</table>
</body>
</html>