// Image swapping functions

// Data
var zzpl=new Array(10);
var zznumpl=0;

// Preload one image
function tgwPreloadImage(imgSrc)
{
  if (zznumpl>=zzpl.length)
    zzpl.length=zznumpl+1;
  zzpl[zznumpl]=new Image();
  zzpl[zznumpl++].src=imgSrc;
}

// Preload an array of images
function tgwPreloadImages(ia)
{
  var i;
  for (i=0;i<ia.length;i++)
    tgwPreloadImage(ia[i]);
}

// Can be called on a particular image instead of calling the preloader
function tgwRegImg(thisImg,swapImg)
{
  if (!thisImg.src1)
    thisImg.src1=thisImg.src;
  if (!thisImg.src2)
  {
    thisImg.src2=swapImg;
    tgwPreloadImage(swapImg);
  }
}

// Swap to alternate
function tgwSwapImg(thisImg)
{
  if (!thisImg.src1)
    thisImg.src1=thisImg.src;
  if (thisImg.src2)
    thisImg.src=thisImg.src2;
}

// Swap to original
function tgwRestImg(thisImg)
{
  if (thisImg.src1)
    thisImg.src=thisImg.src1;
}
