//=== Implements switchable images
//=== Copyright (c) 1999, Paul Evenblij

//=== Start of application-specific stuff

ICNT = 2;
IBAS = "imgs/";
IEXT  = ".gif";

rhome = new ImageSet('home',ICNT,IBAS,IEXT);
rhome.load();

rfeat = new ImageSet('feat',ICNT,IBAS,IEXT);
rfeat.load();

rordr = new ImageSet('ordr',ICNT,IBAS,IEXT);
rordr.load();

rlink = new ImageSet('link',ICNT,IBAS,IEXT);
rlink.load();

for(i=0;i<ICNT;i++)
{
	qhome = new ImageSequ(rhome,0);
	qfeat = new ImageSequ(rfeat,0);
	qordr = new ImageSequ(rordr,0);
	qlink = new ImageSequ(rlink,0);
}
//=== End of application-specific stuff


//=== CLASS ImageSet

function ImageSet(name,count,imgbase,imgext)
{
   this.images = new Array();
   this.name = name;
   this.count = count;
   this.base = imgbase;
   this.ext = imgext;
   this.load = loadImages;
}

function loadImages()
{
   for(i=0;i<this.count;i++)
   {
      this.images[i] = new Image;
      this.images[i].src = this.base + this.name + i + this.ext;
   }
}

//=== CLASS ImageSequ

function ImageSequ(imgSet,first)
{
   this.imgSet = imgSet;
   this.index = first;
   this.current = currentImage;
   this.next = nextImage;
}

function currentImage()
{
   return ("r" + this.imgSet.name + ".images[" + this.index + "].src");
}

function nextImage()
{
   if(++(this.index) >= this.imgSet.count)
     this.index = 0;

   return this.current();
}

//=== HANDLER doNewImage

function doNewImage(srcName,imgSeq,inLayer)
{	
     document.images[srcName].src = eval(imgSeq.next());
}

	
