﻿/*----------------------------------------------------------------------------

Author:			Adam Szwarc
Last Updated:	10/10/2006

This code may be viewed for learning purposes only.

Copyright (c) 2006 Adam L. Szwarc - All rights reserved.
------------------------------------------------------------------------------*/

var iPic = 0;
var iMax = 0;
var iTimer = 3000;
var imgArray;
var timerID = 0;

function ALS_changePhoto(iPic) 
{ 
    document.getElementById("picture").src = imgArray[iPic];
    document.getElementById("photonum").innerHTML = "Photo " + ( iPic + 1 ) + " of " + ( iMax + 1 );
}

function ALS_nextPhoto()
{
    ALS_stopSlideshow();
    if( iPic == iMax ) iPic = 0;
    else iPic++;
    
    ALS_changePhoto(iPic);
}

function ALS_previousPhoto()
{
    ALS_stopSlideshow();
    if( iPic == 0 ) iPic = iMax;
    else iPic--;
    
    ALS_changePhoto(iPic);
}

function ALS_firstPhoto()
{
    ALS_stopSlideshow();
    iPic=0;
    ALS_changePhoto(iPic);
}

function ALS_lastPhoto()
{
    ALS_stopSlideshow();
    iPic=iMax;
    ALS_changePhoto(iPic);
}

function ALS_slideshow()
{
    if( document.getElementById("picture").complete == true ) {
    
        iPic++;
        if( iMax < iPic ) iPic = 0;
        ALS_changePhoto(iPic);
    }
        
    timerID = setTimeout( "ALS_slideshow()", iTimer );     
}

function ALS_stopSlideshow()
{
    if( timerID != 0 ) {
    
        clearTimeout( timerID );     
        timerID = 0;
    }
}

window.onload = ALS_slideshow;
