function show_loaded_image() { // {{{
    $('div.PListImgBox').each(hide_image);
    var full = $(this);
    var w = full.width();
    var h = full.height();
    var w_ratio = w / 300;
    var h_ratio = h / 300;
    var ratio = Math.max(w_ratio, h_ratio, 1);
    var w_scaled = w / ratio;
    var h_scaled = h / ratio;
    if (w_scaled <= 125 || h_scaled <= 94) {
        window.setTimeout(function() { full.each(show_loaded_image); }, 100);
        return true;
    }
    full.css({
        position: 'absolute',
        left: (125 - w_scaled) / 2,
        top: (94 - h_scaled) / 2,
        cursor: 'pointer'
    });
    full.width(w_scaled);
    full.height(h_scaled);
    full.css('display', 'inline');
} // }}}

function load_and_show_image() { // {{{
    var div = $(this);
    var thumb = div.find('img:first');
    var thumb_src = thumb.attr('src');
    var full = div.find('img:last');
    var full_src = full.attr('src');
    if (thumb_src == full_src) {
        var full_src = thumb_src.replace('images/T/', 'images/P/');
        var full = $('<img />');
        full.css('display', 'none')
            .addClass('full')
            .mouseout(hide_image)
            .load(show_loaded_image)
            .click(function() { window.location = thumb.parents('a').attr('href'); });
        full.attr('src', full_src);
        div.append(full);
    } else {
        full.each(show_loaded_image);
    }
} // }}}

function hide_image() { // {{{
    if (this.tagName != 'IMG') {
        var full = $(this).find('.full');
    } else {
        var full = $(this);
    }
    full.hide();
    return true;
} // }}}

