window.onload = function() {
    var imgs = $$('#gallery img');
    var caption = $('caption');
    imgs.each( function(el) {
        var split = el.parentNode.getAttribute('title').split(' :: ');
        var cap = '<h2>' + split[0] + '</h2>' + '<p>' + split[1] + '</p>' 
        Event.observe(el, 'mouseover', function (event) {caption.innerHTML = cap; } )
        Event.observe(el, 'mouseout', function (event) {caption.innerHTML = '<h2>Roll over image to see painting details.</h2>'; } ) }
    );
}
