function show_user_zoom(cont, size) {
    cont.observe('mouseover', function(ev) {
        var userData = cont.select('.user_info')[0].innerHTML.split('|');
        var userLink = cont.select('a')[0].href;
        var borderImage = cont.select('img')[0].src.replace('_small_', '_medium_');

        // Get medium image
        var currentImage = cont.select('.photo_box_'+size)[0].getStyle('backgroundImage');
        var mediumImage;
        // Check if the user has no profile image
        if (currentImage.search('no_photo_') !== -1) {
            mediumImage = currentImage.replace('55x60', '90x110');
        } else {
            mediumImage = currentImage.replace('1.jpg', '2.jpg');
        }

        // Generate HTML
        var div = new Element('div', { 'class': 'GLOB_photo_box_zoom_container' });

        // Generate image image
        var html = new Element('div', { 'class': 'rounded photo_box_medium GLOB_photo_box_zoom_image' })
            .setStyle({'backgroundImage': mediumImage});
        
        html.insert(new Element('a', { 'href': userLink })
                    .insert(new Element('img', { 'src': borderImage })));
        
        div.insert(html);

        // Generate text
        div.insert(userData[0]+' <br />');
        div.insert(new Element('img', { src: userData[2]}));
        div.insert(' '+userData[1]+' år');

        // Calculate and set position of box
        var offset = (cont.cumulativeOffset());
        if (size == 'small')
            div.setStyle({left: offset.left - 27 + 'px', top: offset.top - 13 + 'px'});
        else if (size == 'medium')
            div.setStyle({left: offset.left - 10 + 'px', top: offset.top - 7 + 'px'});
        
        $('zoom_photo_box').update(div);
    });
}

Event.observe(window, 'load', function() { add_photo_zoom(); });

function add_photo_zoom() {
    $('zoom_photo_box').observe('mouseout', function() {
         $('zoom_photo_box').update('');
    });
    
    $$('.photo_box_small_container').each(function(cont) {
        show_user_zoom(cont, 'small');
    });

    $$('.bday_photo_box_medium_list').each(function(cont) {
        show_user_zoom(cont, 'medium');
    });
};
