I finally adapted it myself by a lot of trial and error.
For anybody that is interested here is the adapted code:
Code:
<script language="JavaScript" type="text/javascript">
<!--
//adapted version of 'preloaded slideshow script' by Jason Moon - http://www.dynamicdrive.com/dynamicindex14/preloadslide.htm
//original version could only go from beginning to end and back
//this version goes to the first picture if your at the last picture and click next, identical behavior for the first picture
function CacheImage(ImageSource)
{
var ImageObject = new Image();
ImageObject.src = ImageSource;
return ImageObject;
}
function ShowSlide(Direction)
{
if (SlideReady)
{
if ((CurrentSlide == -1) && (Slides.length > 1))
{
Slides[Slides.length-1] = CacheImage(Slides[Slides.length-1]);
}
if ((CurrentSlide == 0) && (Direction == -1))
{
NextSlide = Slides.length + Direction
document.images['Screen'].src = Slides[NextSlide].src;
CurrentSlide = Slides.length-1
}
else
{
NextSlide = CurrentSlide + Direction;
if ((NextSlide >= 0) && (NextSlide < Slides.length))
{
document.images['Screen'].src = Slides[NextSlide].src;
CurrentSlide = NextSlide++;
if (Direction == 1) CacheNextSlide();
}
else if (NextSlide == Slides.length)
{
document.images['Screen'].src = Slides[Slides.length-NextSlide].src;
CurrentSlide = 0;
}
return true;
}
}
}
function Download()
{
if (Slides[NextSlide].complete)
{
SlideReady = true;
}
else setTimeout("Download()", 100);
return true;
}
function CacheNextSlide()
{
if ((NextSlide < Slides.length) && (typeof Slides[NextSlide] == 'string'))
{
SlideReady = false;
Slides[NextSlide] = CacheImage(Slides[NextSlide]);
Download();
}
return true;
}
function StartSlideShow()
{
CurrentSlide = -1;
Slides[0] = CacheImage(Slides[0]);
SlideReady = true;
ShowSlide(1);
}
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
var Slides = new Array('image01.jpg','image02.jpg','imageN.jpg');
//-->
</script>
I sepperated the var Slides from the rest of the code so that all the functions can be put in an external JS-file.
HTML Code:
<img id="Screen" name="Screen"> //the img-tag where the pictures apear
<a onclick="ShowSlide(-1)">previous</a>
<a onclick="ShowSlide(1)">next</a>
Bookmarks