var photos = new Object();

photos.nPhoto = 0;

photos.previous = function()
{
    var nPhoto = photos.nPhoto - 1;
    if (nPhoto >= 0)
    {
        photos.nPhoto--;
        photos.setImage();
    }
    return false;
}

photos.next = function()
{
    var nPhoto = photos.nPhoto + 1;
    if (nPhoto < photos.maxPhotos)
    {
        photos.nPhoto++;
        photos.setImage();
    }
    return false;
}

photos.setImage = function()
{
    var ndx = document.getElementById('_photoIndex');
    ndx.value = photos.nPhoto;
    menu.loadContent('Main/Photos', true);
}

photos.setCaption = function(caption)
{
		photos.caption = caption;
		setTimeout('photos.enableControls()', 100);
}

photos.init = function(imgId, nextId, prevId, infoId, resetPhoto)
{
    photos.imgId = imgId;
    photos.nextId = nextId;
    photos.prevId = prevId;
    photos.infoId = infoId;
    if (resetPhoto) photos.nPhoto = 0;
}

photos.changePhotoSet = function(photoSetId)
{
    var ndx = document.getElementById('_photoIndex');
    ndx.value = 0;
    photos.nPhoto = 0;
    menu.loadContent('Main/Photos', true);
}

photos.setControls = function(prefix, prevEnabled, prevDisabled, nextEnabled, nextDisabled)
{
    photos.prefix = prefix;
    photos.prevEnabled = prevEnabled;
    photos.prevDisabled = prevDisabled;
    photos.nextEnabled = nextEnabled;
    photos.nextDisabled = nextDisabled;
}

photos.enableControls = function()
{
    var img = document.getElementById(photos.imgId);
		img.title = photos.caption;
    var arrow = document.getElementById(photos.prevId);
    var src = (photos.nPhoto > 0) ? photos.prevEnabled : photos.prevDisabled;
    arrow.src = photos.prefix + src;
    arrow = document.getElementById(photos.nextId);
    src = (photos.nPhoto < (photos.maxPhotos-1)) ? photos.nextEnabled : photos.nextDisabled;
    arrow.src = photos.prefix + src;
    var info = document.getElementById(photos.infoId);
    var nPhoto = 1 + photos.nPhoto;
    info.innerText = 'Photo ' + nPhoto + ' of ' + photos.maxPhotos;
}


