I dont have the solution in front of me..
But I finally used the gallery plugin, something like this:
$(function() {
$("#rulle.scrollable").scrollable();
$("#rulle .items img").click(function() {
var relpop = $(this).attr("rel");
var refpop = 'images/'+ relpop;
$("#image_wrap img").attr('rel', '#'+ relpop);
$("#pop0").attr('href', refpop);
})
$("#rulle .items img").click(function() {
var url = $(this).attr("src");
var wrap = $("#image_wrap").fadeTo("medium", 0.5);
var img = new Image();
img.onload = function() {
wrap.fadeTo("fast", 1);
wrap.find("img").attr("src", url);
};
img.src = url;
}).filter(":first").click();
$("#image_wrap a").overlay({
target: '#gallery'
}).gallery({
});
});