var folderName = "images/";
var photoArray = new Array();

function init() 
{
   popArray(photoArray);
   populateHtmlAssets(0);
   galleryNumbers();
}
function galleryNumbers() 
{
    document.getElementById('galleryNumber').innerHTML = document.getElementById('title').innerHTML.substring(2, 1) + " of " + photoArray.length;
    return document;
}
function populateHtmlAssets(index)
{
   document.getElementById('dynamicImage').src = folderName + photoArray[parseFloat(index)][0];
   document.getElementById('title').innerHTML = photoArray[parseFloat(index)][1];
   document.getElementById('fullDesc').innerHTML = photoArray[parseFloat(index)][2];
   return document;
}
function swap(direction) {
    popArray(photoArray);
    if (photoArray.length - 1 > 0) {
        var currentImageFullName = document.getElementById('dynamicImage').src;
        var start = currentImageFullName.indexOf(folderName);
        var ImageNameWithFolder = currentImageFullName.substring(start, currentImageFullName.length);
        var ImageNameOnly = ImageNameWithFolder.slice(7, [ImageNameWithFolder.length])

        if (direction == "next") {
            for (i = 0; i < photoArray.length; i++) {

                if (ImageNameOnly == photoArray[i][0]) {
                    if (i != photoArray.length - 1) {
                        populateHtmlAssets(i + 1);
                        break;
                    }
                    else {
                        populateHtmlAssets(0);
                        break;
                    }
                }
            }
        }
        else if (direction == "previous") {
            for (i = 0; i < photoArray.length; i++) {
                if (ImageNameOnly == photoArray[i][0]) {
                    if (i != 0) {
                        populateHtmlAssets(i - 1);
                        break;
                    }
                    else {
                        populateHtmlAssets(photoArray.length - 1);
                        break;
                    }
                }
            }
        }
        galleryNumbers();
    }
}