﻿/*
Company: SolutionSet
Author: Jonathan Porter [jporter@solutionset.com]

Description: Sets up automatic transitions for images.  Utilizes scripts by
             brothercake (http://www.brothercake.com/).
*/

/* Takes a string array of image locations and caches those images for
   transition. */
function cacheImages(images)
{
    var imageCache = [];
    
    for(var i=0; i<images.length; i++)
    {
        imageCache[i] = new Image;
        imageCache[i].src = images[i];
    }
}

var transition = { 'clock' : null, 'current' : 0 };
function transitionImages(id, images, duration)
{
    transition.images = images;
    transition.id = id;
    transition.clock = setInterval('doTransition()', duration);
}

/* Does image transition. Set-up to use brothercake crossfade script.  Modify
   to use other transitions. */
function doTransition()
{
    if (ixf.clock == null)
    {
        var nextImage = transition.current + 1;
        if (nextImage >= transition.images.length)
            nextImage = 0;
        crossfade(document.getElementById(transition.id), transition.images[nextImage], '2');
        transition.current = nextImage;
    }
}
