var aimgs = [];

Event.observe(window, 'load', function() {
    $$('img[rel=ajaxload]').each(function(orig, index) {
        aimgs[index] = document.createElement('img');
        aimgs[index].id = 'ajaximg' + index;
        Event.observe(aimgs[index], 'load', ajaxUpdateImage.bindAsEventListener(aimgs[index], orig.id));
        aimgs[index].src = orig.getAttribute('orig');
    });
});

function ajaxUpdateImage(e, origimg)
{
    $(origimg).src    = this.src;
    $(origimg).width  = this.width;
    $(origimg).height = this.height;
}

