function SlideShow(slides, timeout, fadeSpeed, controlLinks) {
var t = this;
t.load = function (index) {
var t = this;
if (t.controlLinks){
for (var i = 0; i < t.controlLinks.length; i++)
SL.util.removeClass(t.controlLinks[i], 'selected');
SL.util.addClass(t.controlLinks[index], 'selected');
}
if (window.jQuery){
if (t.animation){
t.animation.stop();
t.animation = null;
t.finished(index);
}else{
var callback = function() {
t.animation = null;
t.finished(index);
};
t.animation = jQuery(t.slides[t.selected]);
t.animation.animate({opacity: 0}, t.speed,'', callback);
}
}else
t.finished(index);
return false;
}
t.click = function (index) {
if (index != t.selected){
t.stopLoop();
t.load(index)
}
};
t.finished = function (index) {
var t = this;
if (window.jQuery){
var callback = function() {
t.slides[index].style['filter'] = '';
if (t.animation != null)
t.animation.stop();
t.animation = null;
}
t.animation = jQuery(t.slides[index]);
t.animation.css('opacity', 0);
t.showSlide(index);
t.animation.animate({opacity: 1}, t.speed,'', callback);
}
else{
t.showSlide(index);
}
};
t.showSlide = function (index){
SL.util.addClass(t.slides[t.selected], 'hidden');
SL.util.removeClass(t.slides[index], 'hidden');
t.selected = index;
};
t.loop = function(){
var i = t.selected + 1;
if (i < t.slides.length)
t.load(i);
else{
t.stopLoop();
t.load(0);
}
};
t.stopLoop = function(){
if(t.sched){
window.clearInterval(t.sched);
t.sched = null;
t.loop = null;
};
}
t.slides = slides;
t.controlLinks = controlLinks;
t.selected = 0;
t.speed = fadeSpeed;
if (controlLinks)
for (var i=0; i<t.controlLinks.length; i++)
{
controlLinks[i].viewIndex = i;
controlLinks[i].onclick = function(){ t.click(this.viewIndex); return false; };
}
t.sched = window.setInterval(function(){ t.loop(); }, timeout);
}
/*
function slideShowFactory(slidesExpr, clicksExpr, timeout){
var slides = jQuery(slidesExpr);
if (!slides || slides.length <= 1)
return;
var links = jQuery(clicksExpr);
if (!timeout) timeout = 3000;
return new SlideShow(slides, timeout, 600, links);
}
*/

