
slide = {

	// vetor com os slides
	_imagens : [
			["imgs/slide/01.jpg","img1","","1.htm"],
			["imgs/slide/02.jpg","img2","","2.htm"],
			["imgs/slide/03.jpg","img3","","3.htm"],
			["imgs/slide/04.jpg","img4","","4.htm"],
			["imgs/slide/05.jpg","img5","","5.htm"],
			["imgs/slide/06.jpg","img6","","6.htm"]
		],
	
	
	// ID dos elementos que o sistema modifica
	// ID da imagem do slide
	_slideImg : 'slideImg',
	// ID do link do slide, ou seja, um elemento A
	_linkSlide : 'linkSlide',
	// ID do título do slide, uma div ou span por exemplo
	_titleSlide: 'titleSlide',
	// ID do título do slide, idêntico ao de cima
	_textSlide : 'textSlide',
	// ID da imagem de play|pause
	_playPause : 'playpause',
	// ID da div que mostra ou esconde as opções de customização de tempo
	// essa opção pode ser omitida do usuário, basta retirar o botão
	// settings da página, e como a div já vem com o display:none por
	// padrão o usuário não terá acesso a essas opções.
	_showTimer : 'showTimer',
	

	// variáveis do sistema
	// Daqui para baixo não é necessário alterar mais nada, aqui o sistema
	// cuidará de tudo
	_count : 0,
	_length : null,
	_timeOutID : null,
	_pause : false,
	_timer : 4,
	
	// função que inicia o slide e seta todas os parâmetros necessários
	start : function(){
		with(this){
			_preLoader();
			_length = _imagens.length;
			_work(); 
		}
	},
	
	// faz o pré-carregamento das imagens
	_preLoader : function(){
		for(x in this._imagens){
			var image = new Image();
			image.src = this._imagens[x][0];
		}
	},
	
	// função principal que faz as checagens necessárias
	_work : function(){
		with(this){
			(_count == _length) ? _count = 0 : (_count < 0) ? _count = _length-1 : void(0);
			var current = _imagens[_count];
			_exchange(current);
			if(!_pause){
				(typeof(_timeOutID) == "number") ? clearTimeout(_timeOutID) : void(0);
				_timeOutID = setTimeout(
						function(){
							slide.next();
							fade(0,0,$(_slideImg));
						}, (Number(_timer)*1000)
				);
			}
		}
	},
	
	// função que altera os elementos da página, altere os IDs se necessário
	_exchange : function(img){
		this.$(this._slideImg).src = img[0];
//		this.$(this._titleSlide).innerHTML = img[1];
//		this.$(this._textSlide).innerHTML = img[2];
//		this.$(this._linkSlide).href = img[3];
//		this.$(this._linkSlide).href = img[4];
		this.fade(0,100,this.$(this._slideImg));
	},
	
	// altera para o próximo slide ao clicar no botão Próximo
	next : function(){
		with(this){
			_count++;
			_work();
		}
	},
	
	// altera para o slide anterior ao clicar no botão correspondente
	previous : function(){
		with(this){
			_count--;
			_work();
		}
	},
	
	// pausa e continua a apresentação
	pause : function(){
		var img = this.$(this._playPause);
		if(this._pause){
			this._pause = false;
					img.src = 'imgs/pause.gif';
				img.title = 'Parar';
		}
		else{
			this._pause = true;
					img.src = 'imgs/play.gif';
				img.title = 'Continuar';
		}
		with(this){(typeof(_timeOutID) == "number") ? clearTimeout(_timeOutID) : void(0); _work();}
	},
	
	// controla o tempo de troca de cada slide
	tControl : function(act){
		with(this){
		(act=="m")?((_timer==4)?void(0):_timer=_timer-1):((_timer==9)?void(0):_timer= _timer +1);
			this.$(this._showTimer).innerHTML = _timer+"s";	
		}
		
	},
	
	// altera a opacidade do elemento e suaviza a transição entre os slides
	fade : function (){
		
		var type,signal;
		var from 	= arguments[0];
		var to		= arguments[1];
		var el		= arguments[2];
		
		(document.all) ? type = 'filter' : type = 'opacity';
		(from>to) ? signal = '-' : signal= '+';
		
		if(from >= to/2){
			from = eval(from+signal+10);
		}else{
			from = eval(from+signal+5);
		}
		
		if(type=='opacity'){
			try{el.style[type] = Number(from*0.01); }catch(e){}
		}else{
			try{el.style[type] = 'alpha(opacity='+from+')'; }catch(e){}
		}
		
		if(from != to){
			setTimeout( function(){ slide.fade(from,to,slide.$(slide._slideImg)); } ,50);
		}
	},
	
	// retorna o elemento solicitado através de seu ID
	$ : function(){
		return document.getElementById(arguments[0]);	
	}
}





// ==============================
// Set the following variables...
// ==============================

// Set the slideshow speed (in milliseconds)
var SlideShowSpeed = 6000;

// Set the duration of crossfade (in seconds)
var CrossFadeDuration = 3;

var Picture = new Array(); // don't change this
var Caption = new Array(); // don't change this

// ESPECIFIQUE SUAS IMAGENS NOS NOMES ABAIXO
// Specify the image files...
// To add more images, just continue
// the pattern, adding to the array below.
// To use fewer images, remove lines
// starting at the end of the Picture array.
// Caution: The number of Pictures *must*
// equal the number of Captions!

Picture[1]  = 'imgs/500_200/fachada.jpg';
//Picture[2]  = 'imgs/500_200/natal_2009_2.jpg';
Picture[2]  = 'imgs/500_200/individual1.jpg';
Picture[3]  = 'imgs/500_200/daia1.jpg';
Picture[4]  = 'imgs/500_200/daia2.jpg';
Picture[5]  = 'imgs/500_200/daia3.jpg';
Picture[6]  = 'imgs/500_200/ale_daia.jpg';
Picture[7]  = 'imgs/500_200/equipe.jpg';


// ESPECIFIQUE A LEGENDA DE CADA IMAGEM
// Specify the Captions...
// To add more captions, just continue
// the pattern, adding to the array below.
// To use fewer captions, remove lines
// starting at the end of the Caption array.
// Caution: The number of Captions *must*
// equal the number of Pictures!

Caption[1]  = "This is the first caption.";
Caption[2]  = "This is the second caption.";
Caption[3]  = "This is the third caption.";
Caption[4]  = "This is the fourth caption.";
Caption[5]  = "This is the fifth caption.";
Caption[6]  = "This is the sixth caption.";
Caption[7]  = "This is the seventh caption.";
Caption[8]  = "This is the eighth caption.";
Caption[9]  = "This is the ninth caption.";
Caption[10] = "This is the tenth caption.";

// =====================================
// Do not edit anything below this line!
// =====================================

var tss;
var iss;
var jss = 1;
var pss = Picture.length-1;

var preLoad = new Array();
for (iss = 1; iss < pss+1; iss++){
preLoad[iss] = new Image();
preLoad[iss].src = Picture[iss];}

function runSlideShow(){
if (document.all){
document.images.PictureBox.style.filter="blendTrans(duration=2)";
document.images.PictureBox.style.filter="blendTrans(duration=CrossFadeDuration)";
document.images.PictureBox.filters.blendTrans.Apply();}
document.images.PictureBox.src = preLoad[jss].src;
//if (document.getElementById) document.getElementById("CaptionBox").innerHTML= Caption[jss];
if (document.all) document.images.PictureBox.filters.blendTrans.Play();
jss = jss + 1;
if (jss > (pss)) jss=1;
tss = setTimeout('runSlideShow()', SlideShowSpeed);
}
