function createGallery() {
  var imgsrc = new Array();
  
  // set up loading images
  $('.gallery .item .image img').each(function(i) {
    var img = $(this);
    imgsrc[i] = img.attr('src');
    img.attr('src', 'images/blank.gif');
    img.parent().parent().addClass('loading'); /* maybe ? */
  });
  
  // resize gallery
  var width = 0;
  $('.gallery .item .image').each(function(i) {
    var div = $(this);
    var divWidth = div.width();
    div.parent().width(divWidth + 2);
    
    width += divWidth + 62;
  });
  
  $('.gallery .container').width(width);
  
  addHorizontalScrollButtons('.gallery');
  
  // load real images
  $('.gallery .item .image img').each(function(i) {
    var img = $(this);
        
    var image2 = new Image();
    $(image2).load(function() {
      img.attr('src', imgsrc[i]);
      img.parent().parent().removeClass('loading')
    }).attr('src', imgsrc[i]);
  });
}

$(document).ready(function() {
  createGallery();
  addLightbox();
});

