function i2h(id) {
  var handler = (document.getElementById(id))?document.getElementById(id):false;
  return handler;
}
function galerie(aImg, hZoom){
  this.zoom = hZoom;
  this.myImg = aImg;
  this.curPos = 0;
  this.pictDir = null;
  this.zoomDir = null;
  this.btPrev = false;
  this.btNext = false;
  this.classOffName = '';
  this.classOnName = 'on';
  this.actionPlus = null;
}
galerie.prototype = {
  init:function(){
    var oGalerie = this;
    if(false != this.btPrev){
      for(var nPrev = 0; nPrev < this.btPrev.length; nPrev++){
        if('a' == this.btPrev[nPrev].tagName.toLowerCase) this.btPrev[nPrev].setAttribute('href', 'javascript:' + oGalerie.prev());
        else this.btPrev[nPrev].onclick = function(){ oGalerie.prev()};
      }
    }
    if(false != this.btNext){
      for(var nNext = 0; nNext < this.btNext.length; nNext++){
        if('a' == this.btNext[nNext].tagName.toLowerCase) this.btNext[nNext].setAttribute('href', 'javascript:' + oGalerie.next());
        else this.btNext[nNext].onclick = function(){ oGalerie.next()};
      }
    }
    this.max = this.myImg.length - 1;
    for(var i = 0; i < this.myImg.length; i++){
     this.myImg[i].id = 'vignette-' + this.zoom.id + '_' + i;
     this.myImg[i].onclick = function(){ oGalerie.showMe(this.id); }
     if(null != this.zoomDir && null != this.pictDir){
       this.myImg[i]['zoom'] = new Image();
       this.myImg[i]['zoom'].src =  this.myImg[i].src.replace(this.pictDir, this.zoomDir);
     }
    }
  },
  next:function(){
    if(this.curPos == this.max) this.curPos = 0;
    else this.curPos++;
    this.show();
  },
  prev:function(){
    if(0 == this.curPos) this.curPos = this.max;
    else this.curPos--;
    this.show();
  },
  show:function(){
    this.classOff();
    //this.zoom.setAttribute('src', this.myImg[this.curPos].src.replace(this.pictDir, this.zoomDir));
    this.zoom.setAttribute('src', this.myImg[this.curPos]['zoom'].src);
    this.classOn(this.curPos);
    if(null != this.actionPlus) eval(this.actionPlus);
  },
  showMe:function(eltId){
    var aId = eltId.split('_');
    this.curPos = aId[1];
    this.classOn(this.curPos);
    this.show();
  },
  classOff:function(){
     for(var i = 0; i < this.myImg.length; i++){
      this.myImg[i].setAttribute('class', this.classOffName);
      this.myImg[i].setAttribute('className', this.classOffName);
    }
  },
  classOn:function(pos){
    this.myImg[pos].setAttribute('class', this.classOnName);
    this.myImg[pos].setAttribute('className', this.classOnName);
  }
}