//
// MZ; 8/20/2008; added image array functions
// Create an array of image names
// Pass the array index to functions
/*
<script>
this.aImage = new Array(2);
this.aImage[0] = 'a.jpg';
this.aImage[1] = 'b.jpg';
</script>
*/
// --------------------------------------------------------

// Uses array of image names
function ShowNavArrowsIndex(iCurrent, sTargetDir)
{
    var iPrevious = iCurrent - 1;
    var iNext = iCurrent + 1;
    var iMax = this.aImages.length;
    
    var sPreviousHTML = '<img src="../media/images/shim.gif" border="0" width="30" />';
    var sNextHTML = '<img src="../media/images/shim.gif" border="0" width="30" />';
    
    if (iMax > 1)
    {
        if (iPrevious > -1)
        {
            sPreviousHTML = '<a href="#" title="Go to the previous image." onclick="ShowImageIndex(' + iPrevious + ', \'' + sTargetDir + '\');"><img src="../media/images/left2_30.gif" border="0" /></a>';
        }
        if (iNext < iMax)
        {
            sNextHTML = '<a href="#" title="Go to the next image." onclick="ShowImageIndex(' + iNext + ', \'' + sTargetDir + '\');"><img src="../media/images/right2_30.gif" border="0" /></a>';
        }
    }
    
    oDivPrevious = document.getElementById('previous_div');
    if (oDivPrevious)
    {
        oDivPrevious.innerHTML = sPreviousHTML;
    }
    oDivNext = document.getElementById('next_div');
    if (oDivNext)
    {
        oDivNext.innerHTML = sNextHTML;
    }
}

// Show the image from the array of images
// Call the stream_image.php code to overlay the copyright
function ShowImageIndex(iImageIndex, sTargetDir)
{
    var sImage = this.aImages[iImageIndex];
    MM_swapImage('image_holder', '', '../main/stream_image.php?i=' + sTargetDir + '/full/' + sImage, 1);
    ShowNavArrowsIndex(iImageIndex, sTargetDir);
}

// --------------------------------------------------------

// Uses filename: filename must match format: image_N
function ShowNavArrows(iCurrent, iMax, sTargetDir)
{
    var bShowPrevious = false;
    var bShowNext = false;
    var iPrevious = iCurrent - 1;
    var iNext = iCurrent + 1;
    var sPreviousHTML = '';
    var sNextHTML = '';
    
    sPreviousHTML = '<img src="../media/images/shim.gif" border="0" width="30" />';
    sNextHTML = '<img src="../media/images/shim.gif" border="0" width="30" />';
    
    if (iMax > 1)
    {
        if (iCurrent > 1)
        {
            bShowPrevious = true;
        }

        if (iCurrent < iMax)
        {
            bShowNext = true;
        }
    }

    if (bShowPrevious)
    {
        sPreviousHTML = '<a href="#" title="Go to the previous image." onclick="ShowImage(' + iPrevious + ', ' + iMax + ', \'' + sTargetDir + '\');"><img src="../media/images/left2_30.gif" border="0" /></a>';
    }
    if (bShowNext)
    {
        sNextHTML = '<a href="#" title="Go to the next image." onclick="ShowImage(' + iNext + ', ' + iMax + ', \'' + sTargetDir + '\');"><img src="../media/images/right2_30.gif" border="0" /></a>';
    }
    
    oDivPrevious = document.getElementById('previous_div');
    if (oDivPrevious)
    {
        oDivPrevious.innerHTML = sPreviousHTML;
    }
    oDivNext = document.getElementById('next_div');
    if (oDivNext)
    {
        oDivNext.innerHTML = sNextHTML;
    }
}

// Uses filename: filename must match format: image_N
function ShowImage(iShow, iMax, sTargetDir)
{
    MM_swapImage('image_holder', '', sTargetDir + '/full/image_' + iShow + '.jpg', 1);
    ShowNavArrows(iShow, iMax, sTargetDir);
}

