var ssCnt; 
var ssImage=null;
var ssArray=null;
var ssPauseID=null;
var ssPlayID=null;
var ssPause=false;
var ssSrc=null;
// Loop Slideshow
function SS()
{
    if(ssImage!=null && !ssPause && $(ssImage)!=null)
    { 
        // if the count is out of bounds set it back
        if(ssCnt==ssArray.length) ssCnt=0;        
        // load the new slide
        $(ssImage).src=ssArray[ssCnt];
        // increment count
        ssCnt++;                  
    }
    setTimeout("SS()",3200);
}
setTimeout("SS()",1000);

// Start a new SlideShow
function startSS(imgID,arID,playID,pauseID)
{   
    if(ssImage!=imgID)
    {
        // revert to original image
        try{$(ssImage).src=ssSrc;}catch(err){}
        ssSrc=$(imgID).src;
        
        
        // play show
        ssPause=false;
        // switch last to pause mode
        PlayPauseSS();
        
        
        
        // new image id
        ssImage=imgID;
        
        // Split the image IDs into an array
        ssArray = $(arID).value.split(",");
        
        // start one image into new show
        ssCnt=1; 
        
        // set new play/pause ids
        ssPlayID=playID;
        ssPauseID=pauseID;
       
        // Run new show
        PlayPauseSS();             
    }  
}

// Stop running slideshow
function PlayPauseSS()
{
    // Flip pause flag
    ssPause = (ssPause ? false : true);
    try
    {
        // Flip paly button
        if(ssPlayID!=null) $(ssPlayID).style.display=(ssPause ? '' : 'none');
        // Flip Pause button
        if(ssPauseID!=null)$(ssPauseID).style.display=(ssPause ? 'none' : '');
    }
    catch(err){}
}

// Next Slide
function NextSS()
{
    // Pause the show
    if(ssPause!=true) PlayPauseSS(); 
   
    // increment count
    ssCnt++;  
    // if the count is out of bounds set it back
    if(ssCnt>=ssArray.length) ssCnt=0;        
    // load the new slide
    $(ssImage).src=ssArray[ssCnt];
}

// Last Slide
function LastSS()
{
    // Pause the show
    if(ssPause!=true) PlayPauseSS(); 
   
    // decrement count
    ssCnt--;  
    // if the count is out of bounds set it back
    if(ssCnt < 0) ssCnt = (ssArray.length - 1);        
    // load the new slide
    $(ssImage).src=ssArray[ssCnt];    
}

