﻿
///// Plugin variables

playspeed=500;// The playspeed determines the delay for the "Play" button in ms
dotrans=1; // if value = 1 then there are transitions played in IE
transtype='revealtrans';// 'blendTrans' or 'revealtrans'
transattributes='3';// duration=seconds,transition=#<24
loop_on = true;
//#####
//key that holds where in the array currently are
i=0;
can_play = 1;
//###########################################
//if random
function SetRandom() {
	tempimage = new Array();
	for(p=0; p<theimage.length; p++){
		for(p1=0; p1>-1; p1) {
			tempNum = Math.floor(Math.random()*(theimage.length))
			if(!tempimage[tempNum]){
				tempimage[tempNum]=theimage[p];
				break;
			}
		}
	}
	for(p=0;p<theimage.length;p++)theimage[p]=tempimage[p];
	while((i < theimage.length) && (theimage[i][2] != '')) {
	i++; 
	}
	tempimage[0] = theimage[0];
	theimage[0] = tempimage[i];
	theimage[i] = tempimage[0];
	i = 0;
}

//if random order
SetRandom()


//###########################################
window.onload=function(){

	//set transitions
	GetTrans();

	//set the first slide
	SetSlide(0);

	//autoplay
	PlaySlide();
}

//###########################################
function SetSlide(num) {
	if (loop_on) {
	//too big
	i=num%theimage.length;
	//too small
	if(i<0)i=theimage.length-1;

	//switch the image
	if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Apply()')
	document.images.imgslide.src=theimage[i][0];
	if(document.all&&!window.opera&&dotrans==1)eval('document.images.imgslide.filters.'+transtype+'.Play()')
	//if they want name of current slide
  	document.images.imgslide.onload=function(){	document.getElementById('slidebox').innerHTML=theimage[i][2];}
	
	}
	setTimeout("can_play = 1",500);
}


//###########################################
function PlaySlide() {
	if (!window.playing) {
		PlayingSlide(i+1);
//		if(document.slideshow.play){
//			document.slideshow.play.value="   Stop   ";
//		}
	}
	else {
		playing=clearTimeout(playing);
//		if(document.slideshow.play){
//			document.slideshow.play.value="   Play   ";
//		}
	}
	// if you have to change the image for the "playing" slide
	if(document.images.imgPlay){
		setTimeout('document.images.imgPlay.src="'+imgStop+'"',1);
		imgStop=document.images.imgPlay.src
	}
}


//###########################################
function PlayingSlide(num) {
	if (can_play) {
		can_play = 0;
		playing=setTimeout('PlayingSlide(i+1);SetSlide(i+1);', playspeed);
		playspeed = 3000;
	} else {
		playing=setTimeout('PlayingSlide(i+1);', 1000);	
	}
}


//###########################################
//desc: picks the transition to apply to the images
function GetTrans() {
	//si=document.slideshow.trans.selectedIndex;

		dotrans=1;
		transtype='blendTrans';
		document.imgslide.style.filter = "blendTrans(duration=1,transition=1)";
}


