﻿playspeed=3000;// The playspeed determines the delay for the "Play" button in ms
playdiffernce=500; // The speed that the autoplay speed is changed by. 1000=1sec

dotrans=1; // if value = 1 then there are transitions played in IE
transtype='revealtrans';// 'blendTrans' or 'revealtrans'
transattributes='3';// duration=seconds,transition=#<24
//#####
//key that holds where in the array currently are
i=0;
can_play = 1;

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

	//preload images into browser
//	preloadSlide();

	//set transitions
	GetTrans();

	//set the first slide
	SetSlide(0);

	//autoplay
	PlaySlide();
}

//###########################################
function SetSlide(num) {

	old = i;
	//too big
	i=num%theimage.length;
	//too small
	if(i<0)i=theimage.length-1;
    if (theimage[i][2] == '') {old = (old < i || old ==0) ? 1 : -1; SetSlide(num + old);}

	//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);

	//if they have the speed timer
	if(document.slideshow.slidespeed){
		SetSpeed(0);
	}
/* 
 var theObj;
  
    theObj=document.getElementsByTagName('div');
	for (var j = 0; j < theObj.length; j++) {
	  if (theObj[j].style.zIndex > 10000) {
        theObj[j].style.display = 'none';       
      }     
    }
*/
}


//###########################################
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);
	} else {
		playing=setTimeout('PlayingSlide(i+1);', 1000);	
	}
}


//###########################################
function SetSpeed(num){

	if(playspeed+num>0){
		playspeed+=num;
		document.slideshow.slidespeed.value=playspeed/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)";

}
//###########################################
function preloadSlide() {
//	for(k=0;k<theimage.length;k++) {
//		theimage[k][0]=new Image().src=theimage[k][0];
//	}
}



