// gallery_portfolio.js - javascript for gallery portfolio
// furniture, kitchens, bedrooms, stairs, craft

var ntmax = 4;
var typestr = 'fkbsc';
var numbergp = new Object();
numbergp.f = 35;
numbergp.k = 41;
numbergp.b = 13;
numbergp.s = 4;
numbergp.c = 14;
var typechar, nmax, more;
var nblock = 0;

// when a new type of object is selected we need to reset all the basic values and redraw the thumbnails

function changeType ()
   {
   var si = document.gp.type.selectedIndex;
   typechar = typestr.charAt(si);
   nmax = numbergp[typechar];
   nblock = 0;
   showThumbs();
   return false;
   }

// this routine displays a sequence of thumbnail pics on the LHS
// the first pic displayed is pointed at by nstart
// ntmax is the maximum number of spaces available
// nmax is the maximum number of thumbnails of this type
// n pics are displayed followed by blanks if there are not enough to fill the available spaces

function showThumbs ()
   {
   var n, ii;
   if (!more) nblock = 0;
   var nn = nblock + 1;
   var nstart = ((nn-1) * ntmax) + 1;
   if (nstart > nmax)
      {
      n = 0;
      document.gpmsg.src = "images/gallery/gp_msg1.gif";
      more = false;
      }
   else
      {
      n = nmax - nstart + 1;
      if (n > ntmax) { n = ntmax; }
      document.gpmsg.src = "images/gallery/gp_msg0.gif";
      more = true;
      }
   nblock++;
   for (var i=1; i<=ntmax; i++)
      {
      if (i <= n)
         {
         ii = nstart + i - 1;
         eval ('document.gt' + i + '.src = "images/gallery/gpt_pic' + typechar + ii + '.jpg"');
         }
      else { eval ('document.gt' + i + '.src = "images/gallery/gpt_pic00.gif"'); }
      }
   return false;
   }

// this routine displays the large picture on the RHS
// it relies on the current type (encoded in typechar) and is passed the id

function showPic (id)
   {
   var n = (nblock-1) * ntmax + Math.abs(id);
   if (n > 0 && n <= nmax)
      {
//alert("typechar = "+typechar+"\n");
      var s = 'images/gallery/gp_pic' + typechar + n + '.jpg';
      document.gallerypic.src = s;
      }
   return false;
   }

