slide = {
// vetor com os slides
_imagens : [
["../img/destaques/5deef7726d.jpg","2008-08-18 - 11:19:41","Congresso de Herpetologia reúne cientistas de vários países","http://www.inpa.gov.br/noticias/noticia_sgno2.php?codigo=869"],["../img/destaques/c3e4405629.jpg","2008-08-18 - 10:54:53","Insetos aliados à lei
","http://www.inpa.gov.br/noticias/noticia_sgno2.php?codigo=868"],["../img/destaques/3dc149685e.jpg","2008-08-15 - 11:48:37","Inpa e Femact realizam curso de Identificação de Madeira","http://www.inpa.gov.br/noticias/noticia_sgno2.php?codigo=865"],["../img/destaques/a7fdd8f4e3.jpg","2008-08-15 - 11:11:10","Inpa realiza 2ª reunião do CTC no ano","http://www.inpa.gov.br/noticias/noticia_sgno2.php?codigo=864"],["../img/destaques/10fa008b6e.jpg","2008-08-15 - 10:40:11","Inpa abre inscrições para mestrado","http://www.inpa.gov.br/noticias/noticia_sgno2.php?codigo=863"] ],
// ID dos elementos que o sistema modifica
// ID da imagem do slide
_slideImg : 'slideImg',
// ID da data do slide
_dataSlide : 'dataSlide',
// 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 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 : 6,
// 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._dataSlide).innerHTML = img[1];
this.$(this._linkSlide).innerHTML = img[2];
this.$(this._linkSlide).href = img[3];
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 = 'img/itens/botao-pause-off.png';
img.title = 'Parar';
}
else{
this._pause = true;
img.src = 'img/itens/botao-play-on.png';
img.title = 'Iniciar';
}
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]);
}
}