
function SlideShow(instance) {
  this.show=function(idx,s){
    document.getElementById(IMAGE_ID).src=IMAGE_PATH+slideImages[currRow][curr];
    //document.getElementById(IMAGE_ID).width=slideImagesW[currRow][curr];
    //document.getElementById(IMAGE_ID).height=367;
	if (typeof SLIDE_COUNTER_ID!="undefined") {
		document.getElementById(SLIDE_COUNTER_ID).innerHTML=(curr+1)+" / "+(slideImages[currRow].length);
	}
  }
  this.go=function(dir){
    if (typeof dir=="undefined") {
      dir=1;
    }
    curr+=dir;
    if (curr>slideImages[currRow].length-1) {
      curr=0;
    }else if (curr<0) {
      curr=slideImages[currRow].length-1;
    }
    this.show();
  }
  this.goIndex=function(rIdx,idx){
    currRow=parseInt(rIdx);
    curr=parseInt(idx);
    this.show();
  }
  this.killTimer=function(){
    if (this.timer) {
      clearTimeout(this.timer);
      this.timer=0;
    }
  }
  this.play=function(){
    this.go();
    this.killTimer();
    this.timer=setTimeout(instance+".play();",SLIDE_DELAY);
  }
  this.pause=function(){
    this.killTimer();
  }
  this.stop=function(){
    this.killTimer();
    this.goIndex(currRow,0);
  }
  var currRow=0;
  var curr=-1;
  this.timer=0;
  this.setCurr=function(r,c) {
	  currRow=parseInt(r);
	  curr=parseInt(c);
  }
}

SlideShow.getIndex=function(src) {
	for (var i=0; i<slideImages.length; i++) {
		for (var j=0; j<slideImages[i].length; j++) {
			//alert(src+" "+slideImages[i][j]+"\n"+src.indexOf(slideImages[i][j]));
			if (src.indexOf(slideImages[i][j])>-1) {
				return [i,j];
			}
		}
	}
	return [0,0];
}
