//      **** COPYRIGHT 2008 FRANKTRONICS INC ****
//                  Random Photo Fade 
//                        v1.1
//
//                  Author: Lewis Kerns
//                 www.franktronics.net
//
// This application may not be re-used without the express written
// consent of the Author.



// Set speed (milliseconds)
var speed = 5000;
var fadespeed = 500;
var picdir = '\\';

// Specify the image files
var Pic = new Array(); // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = picdir  + 'banner01.jpg';
Pic[1] = picdir  + 'banner02.jpg';
Pic[2] = picdir  + 'banner03.jpg';
Pic[3] = picdir  + 'banner11.jpg';
Pic[4] = picdir  + 'banner12.jpg';
Pic[5] = picdir  + 'banner06.jpg';
Pic[6] = picdir  + 'banner07.jpg';
Pic[7] = picdir  + 'banner08.jpg';
Pic[8] = picdir  + 'banner09.jpg';
Pic[9] = picdir  + 'banner10.jpg';
Pic[10] = picdir  + 'banner13.jpg';
Pic[11] = picdir  + 'banner14.jpg';

// =======================================
// do not edit anything below this line
// =======================================

var t;
var fadetimer;
var j = -1;
var p = Pic.length;


var preLoad = new Array();

for (i = 0; i < p; i++){
   preLoad[i] = new Image();
   preLoad[i].src = Pic[i];
}

function runSlideShow(fadepic){


	if (j < 0) {
		j = Math.ceil(Math.random() * (p-1) )
	}
	else {
		j = j + 1;
	}

	if (j > (p-1)) j=0;

	if (fadepic > 0) 
		fadeout();
	else
	{
			// set the next object and start the fade in
		document.images.SlideShow.src = preLoad[j].src;
		document.images.SlideShow.xOpacity = 0;
		fadein()

//		document.images.SlideShow.src = preLoad[j].src;
//		document.images.SlideShow.xOpacity = 1;
//		setOpacity(document.images.SlideShow);
	}

   t = setTimeout('runSlideShow(1)', speed);
}



function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
}




function fadeout() 
{

	document.images.SlideShow.style.display = "block";
	document.images.SlideShow.xOpacity -= .1;

	if (document.images.SlideShow.xOpacity >=0) 
	{
		// set the opacity and schedule the next fade slice
		setOpacity(document.images.SlideShow);
		fadetimer= setTimeout('fadeout()', (fadespeed/10));
	}
	else
	{ 
		// set the next object and start the fade in
		document.images.SlideShow.src = preLoad[j].src;
		document.images.SlideShow.xOpacity = 0;
		fadein()
	}
} //end fadeout


function fadein() {

	document.images.SlideShow.style.display = "block";
	document.images.SlideShow.xOpacity += .1;

	if (document.images.SlideShow.xOpacity < 1) 
	{
		// set the opacity and schedule the next fade slice
		setOpacity(document.images.SlideShow);
		fadetimer= setTimeout('fadein()', (fadespeed/10));
	}
	else
	{ 
		document.images.SlideShow.xOpacity += .99;
		setOpacity(document.images.SlideShow);
	}

} //end fadeout

