//Copyright (c) 2009, RBB Architects Inc.
//All rights reserved.

//Page Object
var ThisPage = new Object();

//Shared Variables
ThisPage.CurrentImage = 2;
ThisPage.CurrentHolder = 2;

//Page Animation
ThisPage.Animate_Page = function() {
    //Variables
    var DisplayImage = "", ObjID = "";
    
    //Determine Image to Show
    ThisPage.CurrentImage++;
    if (ThisPage.CurrentImage > 5) {
        ThisPage.CurrentImage = 1;
    }
    DisplayImage = "Thumbnail" + ThisPage.CurrentImage + ".jpg";
    
    //Where to Show It
    ThisPage.CurrentHolder = (ThisPage.CurrentHolder == 2 ? 1 : 2);
    ObjID = "Image" + ThisPage.CurrentHolder;
    
    //Animate the current image out of view.
    InfoFind.Animation.Animate(ObjID, 1, "Opacity,100,0", null, null, 
        //Animate the next image to display into view.
        (function() {
            var img = InfoFind.HTML.ByID(ObjID);
            img.src = DisplayImage;
            InfoFind.Animation.Animate(ObjID, 1, "Opacity,0,100", null, null, 
                //Call main function again in 2 Seconds
                (function() {window.setTimeout(ThisPage.Animate_Page, 2000);})
            );
        })
    );
}
                
//Global Code that executes once the Page loads.
InfoFind.HTML.AddEvent(window, "load", ThisPage.Animate_Page);
