// JavaScript Document
function GalleryExecuter(baseFolder,galleryName,container,type)
{
  this.container=container;
  this.baseFolder=baseFolder;
  this.gallery=galleryName;
  this.images=[];
  this.currentImageIndex=0;
  this.theImage=null;
}

GalleryExecuter.prototype.addImages=function(commaSeparatedList)
{
  var list=commaSeparatedList.split(',');
  for (var q=0;q<list.length;q++)
  {
    var im=new Image();
    im.src=this.baseFolder+'/'+this.gallery+'/'+list[q];
    this.images.push(im);
  }
  
  var theIm=new Image();
  theIm.src=this.images[0].src;
  this.container.appendChild(theIm);
  this.theImage=theIm;
  this.theImage.style.cursor='pointer';
}


GalleryExecuter.prototype.show=function(direction)
{
  if (direction=='next')
  {
    this.currentImageIndex++;
    if (this.currentImageIndex>=this.images.length)
      this.currentImageIndex=0;
  }
  else
  {
    this.currentImageIndex--;
    if (this.currentImageIndex<0)
      this.currentImageIndex=this.images.length-1;
  }

  this.theImage.src=this.images[this.currentImageIndex].src;
}
