function gallery(gallery, galind, big) {
  function showitem(index, gallery) {
     if (allitems != null){
        var size = dijit.byId('slideshow').imageStore.getValue(allitems[index], 'size');
        var butt = dijit.byId('slideshow').imageStore.getValue(allitems[index], 'button');
        var info = dijit.byId('slideshow').imageStore.getValue(allitems[index], 'moreinfo');
        if (size == ''){
          dojo.byId('size'     ).innerHTML = '';
          dojo.byId('more_info').innerHTML = '';
          dojo.byId('purchase' ).innerHTML = '';
        } else {
          dojo.byId('size'     ).innerHTML = size; 
          dojo.byId('more_info').innerHTML = info;
          dojo.byId('purchase' ).innerHTML = butt;
        };
        if (gallery){
          dojo.byId('thumbdescription').innerHTML = 
              dijit.byId('slideshow').imageStore.getValue(allitems[index], 'description'); 
          if (last != -1){
              dojo.removeClass('img_thumbPicker_'+last,'thumb_selected');
          };
          dojo.addClass('img_thumbPicker_'+index,'thumb_selected');
          last = index;
        };
     };
  }
  var allitems = null; 
  var last     = -1;
  var itemRequest = {query: {}};
  var itemNameMap = {imageThumbAttr: "thumb", 
                     imageLargeAttr: "large", 
                     linkAttr:       "link"};
  if (!big)
    itemNameMap.titleAttr = "title";
  dijit.byId('slideshow').setDataStore(imageItemStore, itemRequest, itemNameMap);
  dijit.byId('slideshow').imageStore.fetch({onComplete: function(items){
	  allitems = items;
	  for (var item in allitems){
		  allitems[item]['title'] = Array(decodeURIComponent(allitems[item]['title']));
	  }
  }});
  if (galind != 0)
    dijit.byId('slideshow').showImage(galind); 
  if (!big) {
    dojo.subscribe(dijit.byId('slideshow').getShowTopicName(), function(packet) {
      dojo.byId('gallery_title').innerHTML = 
        	  decodeURIComponent(dijit.byId('slideshow').imageStore.getValue(allitems[packet.index], 'title'));
      dojo.byId('zoomhref').href = dijit.byId('slideshow').imageStore.getValue(allitems[packet.index], 'link');
      showitem(packet.index, gallery);
      if (gallery) 
        dijit.byId('thumbPicker')._showThumbs(packet.index);
    });
    if (gallery) {
      dijit.byId('thumbPicker').setDataStore(imageItemStore, itemRequest, itemNameMap);
      dojo.subscribe(dijit.byId('thumbPicker').getClickTopicName(), function(packet){
        dijit.byId('slideshow').showImage(packet.index);
        dojo.byId('zoomhref').href = dijit.byId('slideshow').imageStore.getValue(allitems[packet.index], 'link');
        showitem(packet.index, gallery); 
      });
      dojo.subscribe(dijit.byId('thumbPicker').getShowTopicName(), function(packet){
        dijit.byId('slideshow').moveImageLoadingPointer(packet.index);
      });
      dojo.subscribe(dijit.byId('slideshow').getLoadTopicName(), function(index){
        dijit.byId('thumbPicker').markImageLoaded(index);
      });
    };
  };
};

