// DHTML gallery switch and other effects
document.observe('dom:loaded', function()
{
    if ($('mainimg'))
        new Gallery();
});
Event.observe(window, 'load', function()
{
    if ($$('div.klant').length)
        new ColumnSet();
});

// gallery image switcher
var Gallery = Class.create({
    initialize: function()
    {
        $$('.thumbs a').each(function(a)
        {
            // click handler for thumbs
            a.observe('click', function(e)
            {
                var elm = Event.element(e).up('a');
                $('mainimg').removeClassName('albumfoto_portrait');
                $('mainimg').removeClassName('albumfoto_landscape');
                $('mainimgtext').removeClassName('albumfoto_portrait');
                $('mainimgtext').removeClassName('albumfoto_landscape');
                $('mainimg').src = elm.getAttribute('src');
                $('mainimg').addClassName(elm.getAttribute('orientation'));
                $('mainimgtext').update(elm.getAttribute('description'));
                $('mainimgtext').addClassName(elm.getAttribute('orientation'));
                Event.stop(e);
            });
        });
    }
});

var ColumnSet = Class.create({
    initialize: function()
    {
        // balance div heights
        // find height of highest div
        var height = $$('div.klant').max(function(div) {
            return div.getHeight();
        });
        // apply height to all divs
        $$('div.klant').each(function(div)
        {
            div.setStyle({'height': height + 'px'});
        });
    }
});

