<!--

// ESTABLISH VARS
var start = new Number(queryString('start'));
var maxSlides = new Number(queryString('maxSlides'));
var currentSlide = new Number(start + 1);
var totalSlides = this.slide.length + 1;

// iFRAME RELOAD
function iFrameReload() {
	if (parent.frames['float1'] != null) {
		parent.frames['float1'].location.href="iframe.html";
	}
}

// SLIDE OBJECT
function slide(src,link,target,text) {
// This is the constructor function for the slide object.
// It is called automatically when you create a new slide object.
// For example:
// s = new slide();

	// CREATE IMAGE OBJECT FOR THE SLIDE
	if (document.images) {
		this.image = new Image();
	}

	// LOAD THE IMAGE FOR THE SLIDE
	this.load = function() {
		if (this.image.src != this.src) {
			this.image.src = this.src;
		}
	}

	this.goURL = function() { // GO TO SLIDE'S LINK
		if (this.target) {
			window.open(this.link, this.target);
		} else {
			location.href = this.link;
		}
	}

}

// SLIDESHOW OBJECT
function slideshow(slideshowname) {
	this.name = slideshowname; // NAME OF OBJECT (ex: "show1")
	// REQUIRED IF YOU WANT SLIDESHOW TO AUTO-PLAY

	// LOOP SLIDESHOW ??
	this.repeat = true;

	// NUMBER OF IMAGES TO PRE-FETCH
	// -1 = PRELOAD ALL IMAGES
	//  0 = LOAD EACH IMAGE IS IT IS USED
	//  n = PRE-FETCH n IMAGES AHEAD OF THE CURRENT IMAGE
	this.prefetch = -1;

	// IMAGE ELEMENT ON PAGE (ex: document.images.SLIDES1IMG)
	this.image;

	// SECONDS TO PAUSE BETWEEN SLIDES * 1000
	this.timeout = 4000;

	this.slides = new Array();
	this.current = 0;
	this.timeoutid = 0;


	// ADD A SLIDE TO THE SLIDESHOW
	// ex: SLIDES.add_slide(new slide("image.jpg", "link.html"))
	this.add_slide = function(slide) {
		var i = this.slides.length;

  	 	// PREFETCH THE SLIDE IMAGE IF NECESSARY
		if (this.prefetch == -1) {
			slide.load();
		}
		this.slides[i] = slide;
		if (! this.image) {
			this.image = slide.image;
		}
	}

	// AUTO-RUN SLIDESHOW SUPPORT
	this.play = function(timeout) {
    		this.pause(); // STOP SHOW, IF RUNNING

		// RESET TIMEOUT (OPTIONAL)
		if (timeout) {
			this.timeout = timeout;
		}

		this.timeoutid = setTimeout( this.name + ".loop()", this.timeout);
	}

	// STOPS THE SLIDESHOW IF IT IS AUTOMATICALLY RUNNING
	this.pause = function() {
		if (this.timeoutid != 1) {
			clearTimeout(this.timeoutid);
			this.timeoutid = 1;
		}
	}

	// UPDATE THE SLIDESHOW IMAGE ON THE PAGE
	this.update = function() {
 		var slide = this.slides[this.current];

		// MAKE SURE THE SLIDESHOW HAS BEEN INITIALIZED CORRECTLY
		if (! this.valid_image()) {
			return;
		}

		// LOAD THE SLIDE IMAGE IF NECESSARY
		slide.load();
  
		// UPDATE THE IMAGE
		this.image.src = slide.image.src;

		// UPDATE THE TEXT
		this.update_current();
		this.display_text();

		// RELOAD iFRAME AD
		iFrameReload();

		// PRE-FETCH THE NEXT SLIDE IMAGE(S) IF NEEDED
		if (this.prefetch > 0) {
			for (i = this.current + 1;
			i <= (this.current + this.prefetch) && i < this.slides.length; i++) {
				this.slides[i].load();
			}
		}
	}

	// JUMP TO SPECIFIED SLIDE
	// -1 = JUMP TO LAST SLIDE
	// YOU CAN USE THIS TO MAKE LINKS THAT GO TO A SPECIFIC SLIDE,
	// OR TO GO TO THE BEGINNING OR END OF THE SLIDESHOW. Ex:
	// onClick="myslides.goto_slide(0)"
	// onClick="myslides.goto_slide(-1)"
	// onClick="myslides.goto_slide(5)"
	this.goto_slide = function(n) {
		if (n == -1) {
			n = this.slides.length - 1;
		}
  
		if (n < this.slides.length && n >= 0) {
			this.current = n;
		}
  		this.update();
	}

	// GOTO NEXT SLIDE
	this.next = function() {
  		if (this.current < this.slides.length - 1) { // INCREMENT THE IMAGE NUMBER
			this.current++;
			currentSlide++;
		}
		else if (this.repeat) {
			this.current = 0;
			currentSlide = 1;
		}
		this.update();
	}

	// GOTO PREVIOUS SLIDE
	this.previous = function() {
		if (this.current > 0) { // DECREMENT THE IMAGE NUMBER
			this.current--;
			currentSlide--;
		}
		else if (this.repeat) {
			this.current = this.slides.length - 1;
			currentSlide = totalSlides;
		}
		this.update();
	}



	// DISPLAY THE CURRENT SLIDE NUMBER
	this.update_current = function() {
		// IF A LAYER ID HAS BEEN SPECIFIED, THEN CHANGE THE CONTENTS OF THE HTML ELEMENT
		if (this.currentid) {
			// CHECK getElementById SUPPORT
			if (!document.getElementById) {
				return false;
			}
			writeCurrent = document.getElementById(this.currentid);
			if (!writeCurrent) {
				return false;
			}

		// UPDATE THE TEXT
		writeCurrent.innerHTML = '[ ' + currentSlide + ' of ' + maxSlides + ' ]';
		}
	}

	// DISPLAY THE TEXT FOR THE CURRENT SLIDE
	this.display_text = function() {
		title =  this.slides[ this.current ].title;
		text = this.slides[ this.current ].text;

		// IF A LAYER ID HAS BEEN SPECIFIED, THEN CHANGE THE CONTENTS OF THE HTML ELEMENT
		if (this.textid) {
			// MAKE SURE WE DON'T CAUSE AN ERROR FOR BROWSERS THAT DO NOT SUPPORT getElementById
			if (!document.getElementById) {
				return false;
			}
			writeText = document.getElementById(this.textid);
			if (!writeText) {
				return false;
			}

		// UPDATE THE TEXT
		writeText.innerHTML = '<a href="javascript:SLIDES.goURL()">' + title + '</a><br>' + text;
		}
	}

	// GOTO SLIDE URL
	this.goURL = function() {
		this.slides[ this.current ].goURL();
	}


	// ADVANCE TO NEXT SLIDE ON TIMEOUT
	this.loop = function() {
		// MAKE SURE THE NEXT SLIDE IMAGE HAS FINISHED LOADING
		if (this.current < this.slides.length - 1) {
			next_slide = this.slides[this.current + 1];
			if (next_slide.image.complete == null || next_slide.image.complete) {
				this.next();
			}
		} else { // WE'RE AT THE LAST SLIDE
			this.next();
		}

		// KEEP PLAYING THE SLIDESHOW
		this.play( );
	}

	// RETURNS 1 IF A VALID IMAGE HAS BEEN SET FOR THE SLIDESHOW
	this.valid_image = function() {
		if (!this.image) {
			// STOP THE SLIDESHOW
			this.pause;
		  
		      // DISPLAY AN ERROR MESSAGE
			window.status = "Error: slideshow image not initialized for " + this.name;
			//alert("Error: slideshow image not initialized for " + this.name);
          		return 0;
		} else {
			return 1;
		}
	}
}

//-->
