// little javascript 
// made by elfling.nl

// class slides

slides.prototype._name;
slides.prototype._images;
slides.prototype._counter;
slides.prototype._max;

function slides(name)
{
    this._name = name;
    this._counter = 0;
}

slides.prototype.getName = function()
{
    alert(this._name);
}

slides.prototype.setImages = function(images)
{
    this._images = images;
    this._max = images.length;
}


slides.prototype.writeFirst = function()
{
    document.write('<img src="' + this._images[0] + '" id="' + this._name + '" />');
}
   
slides.prototype.showImage = function(number)
{
   myTargetImage = document.getElementById(this._name);
   myImage = this._images[number];
   myTargetImage.src = "";
   myTargetImage.src = myImage;
   // setting the class of the potx img
   myPotxImage = document.getElementById("potximage");
   if (myImage.indexOf("portrait") > -1 )
   {
      myPotxImage.className = "header_portrait";
   }
   if (myImage.indexOf("landscape") > -1 )
   {
      myPotxImage.className = "header_landscape";
   }
   this._counter = number;
}

slides.prototype.showLinks = function()
{
   for (var i=0;i<this._images.length;i++)
   {
       document.write('<a href="javascript:' + this._name + '.showImage(' + i + ');">foto ' + (i+1) + '</a><br />');
  }
}

slides.prototype.showPrevNext = function()
{
/*
  myTargetNode=document.getElementById(this._name).parentNode;
  var newdiv = document.createElement('div'); 
  newdiv.setAttribute('style','position:relative;top:0px;');  newdiv.innerHTML = 'JO';  myTargetNode.appendChild(newdiv);
*/
    document.write('<a href="javascript:' + this._name + '.showPrev();">prev</a>');
    document.write(' | ' + this._max + ' foto\'s | ');
    document.write('<a href="javascript:' + this._name + '.showNext();">next</a>');
}

slides.prototype.showPrev = function()
{
    this._counter--;
    if (this._counter < 0) this._counter = this._max - 1;
    this.showImage(this._counter);
}

slides.prototype.showNext = function()
{
    this._counter++;
    if (this._counter == this._max) this._counter = 0;
    this.showImage(this._counter);
}
