



When leaving the page a cookie is used to remember which image was showing, when the page is revisited the slideshow starts from where it left off.
This is ideal for having the slideshow on more than one page and have the images continue instead of restarting from the beginning.
You can set the script to start from the previous image or continue with the next image by changing the value of variable adj
<script type="text/javascript">
<!--
//Jeff
// www.huntingground.freeserve.co.uk
csArr=["pic1.jpg","pic2.jpg","pic3.jpg","pic4.jpg","pic5.jpg"]
adj= 0 // 0 = continue // -1 = start from previous image
var preloadcsArr=new Array() // preloads images
for (i=0;i<=csArr.length-1;i++) {
preloadcsArr[i]=new Image()
preloadcsArr[i].src=csArr[i]
}
function getPicCount() {
count = getCookie(cookieName)
if(count==null){
count=0
}
showPic()
}
function showPic(){
if(document.getElementById&&document.all&&!window.opera){
document.getElementById("mypic").filters[0].Apply()
}
document.getElementById("mypic").src=csArr[count]
if(document.getElementById&&document.all&&!window.opera){
document.getElementById("mypic").filters[0].Play(2) // blend time, in seconds
}
setTimeout("showPic()",3000) // repeat
count++
if(count>csArr.length-1){
count=0
}
exp = new Date()
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
setCount=count+adj
setCookie(cookieName, setCount, exp)
}
cookieName="seq_img2"
expDays=365
function setCookie(name, value, expires, path, domain, secure){// An adaptation of Dorcht's function for setting a cookie.
if (!expires){expires = new Date()}
document.cookie = name + "=" + escape(value) +
((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
((secure == null) ? "" : "; secure")
}
function getCookie(name){
var arg = name + "="
var alen = arg.length
var clen = document.cookie.length
var i = 0
while (i < clen) {
var j = i + alen
if (document.cookie.substring(i, j) == arg)
return getCookieVal(j)
i = document.cookie.indexOf(" ", i) + 1
if (i == 0) break
}
return null
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset)
if (endstr == -1)
endstr = document.cookie.length
return unescape(document.cookie.substring(offset, endstr))
}
function deleteCookie(name,path,domain) { // An adaptation of Dorcht's function for deleting a cookie.
document.cookie = name + "=" +
((path == null) ? "" : "; path=" + path) +
((domain == null) ? "" : "; domain=" + domain) +
"; expires=Thu, 01-Jan-00 00:00:01 GMT"
}
// add onload="getPicCount()" to the opening BODY tag
//-->
</script>
<img id="mypic" src="blank.gif" width="200" height="200" style="filter:BlendTrans()">