var which = 0

function keeptrack() {
    window.status = "Image " + (which + 1) + " of " + photos.length
    if (document.all) {
        document.getElementById('low_picture_number').innerText = which + 1;
    } else {
        document.getElementById('low_picture_number').textContent = which + 1;
    }
}

function updateCaption(captionText) {
    if (document.all) {
        document.getElementById('picture_caption').innerText = captionText;
    } else {
        document.getElementById('picture_caption').textContent = captionText;
    }
}


function backward() {
    if (which > 0) {
        which--
        document.images.photoslider.src = photos[which] + '?width=250&quality=60&crop=auto';
        document.images.photoslider.alt = altText[which];
        document.getElementById('main_link').onclick = function() { return Shadowbox.open(document.getElementById('ThumbPic' + which)); }
        document.getElementById('main_link').title = altText[which];
        updateCaption(captions[which]);
        keeptrack();
        Shadowbox.setup();
    } else {
        which = photos.length - 1
        document.images.photoslider.src = photos[which] + '?width=250&quality=60&crop=auto';
        document.images.photoslider.alt = altText[which];
        document.getElementById('main_link').onclick = function() { return Shadowbox.open(document.getElementById('ThumbPic' + which)); }
        document.getElementById('main_link').title = altText[which];
        updateCaption(captions[which]);
        keeptrack();
        Shadowbox.setup();
    }
}

function forward() {
    if (which < photos.length - 1) {
        which++
        document.images.photoslider.src = photos[which] + '?width=250&quality=60&crop=auto';
        document.images.photoslider.alt = altText[which];
        document.getElementById('main_link').onclick = function() { return Shadowbox.open(document.getElementById('ThumbPic' + which)); }
        document.getElementById('main_link').title = altText[which];
        updateCaption(captions[which]);
        keeptrack();
        Shadowbox.setup();
    } else {
        which = 0;
        document.images.photoslider.src = photos[which] + '?width=250&quality=60&crop=auto';
        document.images.photoslider.alt = altText[which];
        document.getElementById('main_link').onclick = function() { return Shadowbox.open(document.getElementById('ThumbPic' + which)); }
        document.getElementById('main_link').title = altText[which];
        updateCaption(captions[which]);
        keeptrack();
        Shadowbox.setup();
    }
}


