Event.observe(window, 'load', function() { 
    $$('img.blogimage').each(function(img) {
	    var pars = $H();
        
        pars.set('file',  getParam(img, 'file'));
        pars.set('sizex', document.viewport.getWidth()-100);
        pars.set('sizey', document.viewport.getHeight() - 150);
        
        var href='http://files.schwiiz.org/image.php?' + pars.toQueryString();

        var a = new Element('a');
        a.setAttribute('href', href);
	a.setAttribute('title', img.getAttribute('title') );
        a.setAttribute('rel', 'lightbox[blog]');
        
        img.up().insertBefore(a, img);
        a.appendChild(img);
    });
    
    initLightbox();
});

function getParam(url, param) {
    return url.getAttribute('src').toQueryParams()[param];
}
