/*
 * Used to manipulates the pages and images within the Weekly H image gallery
 */

var _currentPage = 1;
// the image page ID prefix
var PAGE_PREFIX = "imagePage-";

function $(id) { return document.getElementById(id); }

function nextPage()
{
    var nextDivId = PAGE_PREFIX+(_currentPage + 1)
    var nextDiv = $(nextDivId);
    if (nextDiv == null)
        return;
    
    // show the new div, hide the old one
    $(PAGE_PREFIX+_currentPage).style.display = "none";
    nextDiv.style.display = "inline";
    
    // assign new current pages
    ++_currentPage;
}

function prevPage()
{
    if ((_currentPage - 1) <= 0)
        return;
    
    var prevDivId = PAGE_PREFIX+(_currentPage - 1)
    var prevDiv = $(prevDivId);
    if (prevDiv == null)
        return;
    
    // show the new div, hide the old one
    $(PAGE_PREFIX+_currentPage).style.display = "none";
    prevDiv.style.display = "inline";
    
    --_currentPage;
}

function gotoPage(num)
{
    var divId = PAGE_PREFIX+num
    var div = $(divId);
    if (div == null)
        return;
        
    // show the new div, hide the old one
    $(PAGE_PREFIX+_currentPage).style.display = "none";
    div.style.display = "inline";
    
    // set the new page num
    _currentPage = num;
}