/* Code for helpful popup stuff.
 * Arguments may not contain double quotes
 */
 
function openSplitWin(title, topUrl, btmUrl) {
	var thisWin = window.open("split.htm?"+topUrl+"&"+btmUrl, "_blank");
	//thisWin.title = title;
	/*
	var inHTML = "<!doctype html public \"-//W3C//DTD HTML 3.2 Final//EN\">\
    <html><head><title>" + title + "</title></head>\
      <frameset cols=\"200, *\"><frame name=\"upper\" src=\"" + topUrl + "\"><frame name=\"lower\" src=\"" + btmUrl + "\">\
      </frameset>\
      <noframes>\
      Since your browser does not support frames, <a href=" + topUrl + ">click here</a>.\
      </noframes>\
  </html>";
  
    thisWin.document.write(inHTML);*/
}

/* Simply tacks on an extension to strings in an array
 */
function addExt(theseFiles, ext) {
	var i;
	for (i = 0; i < theseFiles.length; i++) {
		theseFiles[i] = theseFiles[i] + ext;
	}
	return theseFiles;
}

/* Tacks on a path to strings in an array
 */
function addPath(theseFiles, path) {
	var i;
	for (i = 0; i < theseFiles.length; i++) {
		theseFiles[i] = path + theseFiles[i];
	}
	return theseFiles;
}

/* A collection of pictures
 * An "img" is an image object or HTML <IMG> target...
 */
function SlideShow() {
	var imagePaths;
	var imgs;
	var curImage = 0;
	var imgTotal = 0;
	var targetImg;
	
	/* Loads images into the slideshow
	 */
	this.loadImages = function (theseFiles) {
		// Get basic info
		this.imagePaths = theseFiles;
		this.imgTotal = theseFiles.length;
		this.curImage = 0;
		
		// Fill images array
		this.imgs = new Array(this.imgTotal);
		var i;
		for (i = 0; i < this.imgTotal; i++) {
			this.imgs[i] = new Image();
			this.imgs[i].src = this.imagePaths[i];
		}
	}
	
	/* Shows the current image
	 */
	this.showImage = function () {
		if (this.curImage < 0 || this.curImage >= this.imgTotal) return;
		if (this.targetImg && this.imgs) {
			this.targetImg.src = this.imgs[this.curImage].src;
		}
	}
	
	/* Goes to the next image
	 */
	this.nextImage = function() {
		if (this.curImage + 1 >= this.imgTotal) {
			this.curImage = 0;
		} else {
			this.curImage++;
		}
		this.showImage(this.curImage);
	}
	
	/* Goes to the last image
	 */
	this.prevImage = function() {
		if (this.curImage - 1 < 0) {
			this.curImage = this.imgTotal - 1;
		} else {
			this.curImage--;
		}
		this.showImage(this.curImage);
	}
}