/*Script written by Jotham Kingston.
It requires all of your photos to be in the same folder, constrained to the same proportions,
and numbered sequentially, from 1 to however many you have.

drop this inside your script tag in the heading.


*/
	
/*Script written by Jotham Kingston.
It requires all of your photos to be in the same folder, constrained to the same proportions,
and numbered sequentially, from 1 to however many you have.



drop this inside your script tag in the heading.


*/
	
function slideShow(loc, len, id, id2, sTime, fSteps, mode) {
	this.pictures=new Array();
	this.thisSlide=1;
	this.newSlide=1;
	this.direction=1;
	this.frameRate=25; //fps
	this.slideTime=sTime;
	this.fadeSteps=fSteps;
	this.tt=0;
	this.loop=(!mode)?"looping":mode;
	for (pp=1;pp<=len;pp++) {
		this.pictures[pp]=new Image();
		this.pictures[pp].src=loc+pp+".jpg";
		//alert (this.pictures[pp].src);
	}
	this.slide=document.getElementById(id);
	this.slide2=document.getElementById(id2);
}

function showSlide (show, direction) {
	//alert(show+ " "+ direction);
	show.timer1 = setTimeout (function() {swapSlides(show,direction);}, (show.slideTime*1000-(show.fadeSteps*show.frameRate)));
}

function swapSlides (show, direction) {
	show.tt++;
	show.slide2.style.opacity=1-(show.tt)/show.fadeSteps; //falls to 0
	show.slide2.filter="alpha(opacity="+show.slide2.style.opacity*100+")"; // for ie
	//document.getElementById("developer").innerHTML=show.tt+" "+show.fadeSteps+ " "+show.newSlide+"  "+show.pictures.length;
		if (show.tt<show.fadeSteps) {
		show.timer2 = setTimeout(function() {swapSlides(show,direction);}, 1000/show.frameRate);
	} 
	else {
		//slide2 has opacity of 0, while slide underneath has opacity of 1.
		show.newSlide=show.thisSlide+show.direction; //e.g. 2
		if (show.newSlide>=show.pictures.length) {show.newSlide=1;}
		if (show.newSlide<=0) {show.newSlide=show.pictures.length-1;}
		show.slide2.src=show.pictures[show.thisSlide].src; //transfer top layer slide while it is invisible to be same as bottom
		show.slide2.style.opacity=1; show.slide2.style.filter="alpha(opacity="+show.slide2.style.opacity*100+")"; // turn top layer slide back on.
		show.slide.src=show.pictures[show.newSlide].src; //convert underneath to 'new slide'
		show.thisSlide=show.newSlide;
		show.tt=0;
		if (show.loop=="looping") {
			showSlide(show,direction);
			}
	}
}

function delayShow (show,wait,direction) {
	show.timer0 = setTimeout ( function() {swapSlides(show,direction)}, wait*1000)
}

//alert("gatlingSlideshow.js is okay");