// globalequestrianacademy site dynamics
// (c) 2007 Loco (Loohuis Consulting), http://www.loohuis-consulting.nl/
// This work is licensed under a 
// Creative Commons Attribution-Share Alike 3.0 Netherlands License
// see http://www.loohuis-consulting.nl/development/cc-by-sa.php

// show big image
function showImage(e)
{
    img = Event.element(e);
    $('viewimg').setAttribute('src', img.getAttribute('src'));
    $('panetext').update(img.getAttribute('comment'));
    $('panelink').setAttribute('href', img.getAttribute('link'));
    // clear active
    var pager = $('gallerypager');
    if (pager) {
        // thumbnail click events
        var thumbs = document.getElementsByClassName('activeimg');
        thumbs.each(function(t)
        {
            Element.removeClassName(t, 'activeimg');
        });
    }
    // set new active
    Element.addClassName(img.parentNode, 'activeimg');
}

// initialise page
function init()
{
    var pager = $('gallerypager');
    if (pager) {
        // thumbnail click events
        var thumbs = document.getElementsByClassName('galleryimg');
        thumbs.each(function(t)
        {
            Event.observe(t, 'click', showImage);
        });
        // load first image
        thumbs[0].firstChild.addClassName('activeimg');
        img = thumbs[0].getElementsByTagName('img')[0];
        $('viewimg').setAttribute('src', img.getAttribute('src'));
        $('panetext').update(img.getAttribute('comment'));
        $('panelink').setAttribute('href', img.getAttribute('link'));
    }
}

Event.observe(window, 'load', init);

