function ScreenSaverSpriteManager(intervalSpeed, Div1, Div2, ImageCount) {

    var self = this;
    //var iCount = 1;
    var opaq = null;
    
    var CurrentImgIndex = 1;            // index of img on page, 1 = far left, x = far right
    
    this.StartFade = function () {
    
        var newOut;
        var newIn;
       
        if(Div1.style.display != "none") { newOut = Div1; newIn = Div2; }
        else                             { newOut = Div2; newIn = Div1; }
        
        newIn.className = GetNextClassName(newOut);
        
        var fadeIn = new Fade(newIn, false);
        var fadeOut = new Fade(newOut, false);
        
        fadeIn.Start(true);
        fadeOut.Start(false);
        
    }
    
    // Get the next source for the img tag
    function GetNextClassName(div) {

        var arClassName = div.className.split("_")
        var imageIndex = parseInt(arClassName[1]) + 1;
        
        // if image index has passed the end of available tower images, reset it back to the beginning
        if(imageIndex > ImageCount) { imageIndex = 1; }
        
        return arClassName[0] + "_" + imageIndex.toString();
    }
    
    // start fading.
    function Begin() {
    
        opaq = setInterval(
                            function() {
                                if (ScreenSaverSpriteManager) { if(typeof(CollectGarbage) == "function") { CollectGarbage(); } self.StartFade();}
                      }, intervalSpeed);
                      
    }

    Begin();

}


