// **** 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 how long a picture will be displayed (in milliseconds)
var speed = 4000;

// Set how long it takes for a picture to fade or fade in ( in milliseconds)
var fadespeed = 500;

// Set the absolute path to the pictures
var picdir ='';  // '\\';

// Specify the image files
// to add more images, just continue
// the pattern, adding to the array below
var Pic = new Array(); // don't touch this
Pic[0] = picdir  + 'gift1.jpg';
Pic[1] = picdir  + 'gift2.jpg';
Pic[2] = picdir  + 'gift3.jpg';
Pic[3] = picdir  + 'gift4.jpg';
Pic[4] = picdir  + 'gift5.jpg';
Pic[5] = picdir  + 'gift6.jpg';
Pic[6] = picdir  + 'gift7.jpg';
Pic[7] = picdir  + 'gift8.jpg';
Pic[8] = picdir  + 'gift9.jpg';
//Pic[5] = picdir  + 'petweek6.jpg';


// Specify the descriptions that go with each picture
// Inserting <br> will create new line
var CapList = [];
CapList [0] = "";
CapList [1] = "";
CapList [2] = "";
CapList [3] = "";
CapList [4] = "";
CapList [5] = "";
CapList [6] = "";
CapList [7] = "";
CapList [8] = "";
//CapList [5] = "Pet Description";



// =======================================
// do not edit anything below this line
// =======================================

var t;
var fadetimer;
var j = 0;
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 (fadepic > 0) 
	{
		j = j + 1;
		if (j > (p-1)) { j=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 = 1;
			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;
		//document.getElementById('PictureCaption').innerHTML=CapList[j];

		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 = 1;
		setOpacity(document.images.SlideShow);
	}

} //end fadeout


