
    // Array of images needs to be included before this script to suppply
    // required confiuration
    var start_image      = 0;
    var number_of_images = arrImage.length - 1; // ignore last dummy entry  
    
    function swapGalleryImage( url, lurl, gtext ) {
        var img = document.getElementById('gallery_image');
        if ( img ) {
            img.setAttribute('src', url);        
        }
        var ahref = document.getElementById('gallery_link');
        if ( ahref ) {
            ahref.setAttribute('href', lurl);
        }
        var gtextnode = document.getElementById('gallery_text');
        gtextnode.firstChild.nodeValue = gtext;
    }
    
    function prevImage() {
        if ( start_image > 0 ) {
            --start_image;
        }
        updateThumbs(start_image);
    }
    
    function nextImage() {
        if ( start_image < number_of_images - images_per_page ) {
            ++start_image;
        }            
        updateThumbs(start_image);
    }
    
    function updateThumbs(start_image) {
        for ( var i=0; i<2; i++ ) {
            var img = document.getElementById('gallery_image'+(1+i) );
            if ( img ) {
                img.setAttribute('src', arrImage[start_image+i][0]);
                eval("img.onclick = function() { swapGalleryImage( '" + arrImage[start_image+i][1] + "', '" + arrImage[start_image+i][2] + "', '" + arrImage[start_image+i][3] + "'); return false; }");
            }
        }   
    }
