active = 0;
over = -1;

function thumbClick(target, src) 
{
   new_active = Number(target.firstChild.firstChild.firstChild.id.substr(6));
   if (active == new_active) return false;
   clearShadow(document.getElementById('thumb-' + active));
   active = new_active;
   refreshAll();
   
   var bigPic=document.getElementById('bigPic');
   bigPic.src = src;
   return false;
}

function thumbOver(target) 
{
//   over = Number(target.firstChild.id.substr(6));
//   refreshAll();
   makeShadow(target.firstChild.firstChild.firstChild);
   return true;
}

function thumbOut(target)
{
   var id = Number(target.firstChild.firstChild.firstChild.id.substr(6));
   if (active != id) {
      clearShadow(target.firstChild.firstChild.firstChild);
   }
   return true;
}

function makeShadow(img)
{
   img.parentNode.parentNode.className = "photoWrapper";
}

function clearShadow(img)
{
   img.parentNode.parentNode.className = "photoFlat";
}

function makeColour(img)
{
   img.src = img.src.replace("grayscale_", "colour_");
}

function makeGrayScale(img)
{
   img.src = img.src.replace("colour_", "grayscale_");
}

function refreshAll()
{
   for (var i = 0; i < 10; i++)  {
      var thumb = document.getElementById("thumb-" + i);
      if (null == thumb) break;
      
      if ((active == i && over == -1) || over == i) {
         makeColour(thumb);
      }  else  {
         makeGrayScale(thumb);
      }
   }
}