function swapInit() {
  // loop through all images of the document
  var i,imgs,img,count=0;
  imgs = document.getElementsByTagName('img');
  for(i=0;i<imgs.length;i++) {
    // test if the class 'roll' exists
    if(/thumbnail/.test(imgs[i].className)) {
      // add the function roll to the image onmouseover and onmouseout and send
      // the image itself as an object
      imgs[i].onmouseover = function(){swapImg(this);};
      count++;
    }
    // get index of first image
    if(count==1) img=i;
  }
  
  // register popup for first image
  swapImg(imgs[img]);
}

function swapImg(o) {
  var src,swapid;
  // get the src of the image, and find out the file extension
  src = o.src;
  swapid = document.getElementById('collage');
  swapid.src = src.replace('_small','');
}

window.onload = function() {
  swapInit();
}
