var slideCache = new Array();
function RunSlideShowWithLinks(pictureID,linkID,imageLinks,displaySecs)
{
        var separator = imageLinks.indexOf(";");
        var nextImage = imageLinks.substring(0,separator);

               //                                        alert ("1 " + imageLinks.length);
             //   alert ("2 "  + indexes.length);
           // alert ("3 "  + indexes[1]);

             //          alert ("4 "  + imageLinks[1]);

        if (slideCache[nextImage] && slideCache[nextImage].loaded)
        {
                var futureImages= imageLinks.substring(separator +1,imageLinks.length) + ';' + nextImage;
                separator = futureImages.indexOf(";");

               // var indexes_future= indexes.substring(separator +1,indexes.length) + ';' + nextImage;
               // separator = indexes_future.indexOf(";");

                var nextLink = futureImages.substring(0,separator);
                futureImages= futureImages.substring(separator+1,imageLinks.length) + ';' + nextLink;

                var picture=document.getElementById(pictureID);
                if (picture.filters)
                {
                        picture.style.filter="blendTrans(duration=3)";
                        picture.filters.blendTrans.Apply();
                }
                picture.src = nextImage;


             //   alert(linkID + " " +  nextLink);
                document.getElementById(linkID).href = nextLink;
          

                if (picture.filters)
                {
                        picture.filters.blendTrans.Play();
                }
                setTimeout("RunSlideShowWithLinks('"+pictureID+"','"+linkID+"','"+futureImages+"',"+displaySecs+")",
                        displaySecs*1500);
                // Identify the next image to cache.
                separator = futureImages.indexOf(";");
                nextImage = futureImages.substring(0,separator);
        } else {
                setTimeout("RunSlideShowWithLinks('"+pictureID+"','"+linkID+"','"+imageLinks+"',"+displaySecs+")",250);
        }
        // Cache the next image to improve performance.
        if (slideCache[nextImage] == null) {
                slideCache[nextImage] = new Image;
                slideCache[nextImage].loaded = false;
                slideCache[nextImage].onload = function(){this.loaded=true};
                slideCache[nextImage].src = nextImage;
        }
}

