

var slideshowy = {
ile : 2,
start : 1,
temp : 1,
slidet: 5,
running:null,
old:null,
clicked:false,

start: function() {

this.startshow();
},
startshow: function(){

	this.running = true;
	this.slideS = new PeriodicalExecuter(function(pex){ slideshowy.Next(); pex.stop(); },this.slidet);


},

stopshow: function(){
		this.running = false;
		if(this.slideS){
			this.slideS.stop();
		}

},
stopshowf: function(){
		this.stopshow();
//		document.getElementById('pause').style.display = "none";
//		document.getElementById('play').style.display = "";

},

hidetext: function(tval){
	//document.getElementById('directions').style.display = "none";
	//this.dirs =	document.getElementById('dire'+tval).innerHTML;
	//document.getElementById('dire'+tval).innerHTML = "";


},
showtext: function(tval){


},
Next : function(){
	this.clicked= true;
	this.old = this.temp;

	slideshowy.temp++;
	if(this.temp>this.ile) this.temp=1;
	new Effect.Fade('text'+this.old, {duration:.5,afterFinish: function(){slideshowy.hidetext(slideshowy.old);slideshowy.showtext(slideshowy.temp);}});


//	new Effect.Appear('directions',{duration:.2});

	new Effect.Appear('text'+this.temp,{duration:.5,queue:"end",afterFinish: function(){slideshowy.clicked = false;
		//document.getElementById('directions').style.display = "";
	//	document.getElementById('dire'+slideshow.temp).innerHTML = slideshow.dirs;
		 slideshowy.toggleshow();}});



},

butPrev : function(){
	if(this.clicked==true){

		return false;

	}
	this.clicked = true;
	this.stopshowf();
	this.old = this.temp;
	this.temp--;
	if(this.temp<1) this.temp=this.ile;
	new Effect.Fade('text'+this.old, {duration:.5,afterFinish: function(){slideshowy.hidetext(slideshowy.old);slideshowy.showtext(slideshowy.temp);}});

	new Effect.Appear('text'+this.temp,{queue:"end",duration:.5,afterFinish: function(){slideshowy.clicked = false;

	//document.getElementById('dire'+slideshow.temp).innerHTML = slideshow.dirs;
	}});



},
butNext : function () {
	if(this.clicked==true){

		return false;

	}
	this.clicked = true;
	this.stopshowf();
	this.old = this.temp;

	slideshowy.temp++;
	if(this.temp>this.ile) this.temp=1;
	//new Effect.Fade('whole'+this.temp,{duration:.5});
	new Effect.Fade('text'+this.old, {duration:.5,afterFinish: function(){slideshowy.hidetext(slideshowy.old);slideshowy.showtext(slideshowy.temp);}});

	new Effect.Appear('text'+this.temp,{queue:"end",duration:.5,afterFinish: function(){slideshowy.clicked = false;
	//document.getElementById('directions').style.display = "";
	//document.getElementById('dire'+slideshow.temp).innerHTML = slideshow.dirs;
	}});


},
toggleshow: function(){
		if(this.running){
			this.startshow();

		}else{
			this.stopshow();


		}
	},
toggleshowbut: function(){
		if(this.running){
			this.stopshowf();
		}else{

			this.startshow();
			//document.getElementById('play').style.display = "none";
			//document.getElementById('pause').style.display = "";


		}
},
togglelight : function() {
	if(this.running){
		if(this.slideS){
				this.slideS.stop();
		}
	}
},
togglelightclose : function() {
	if(this.running){
		if(this.slideS){
				this.startshow();
		}
	}
}
}

slideshowy.start();
