8 var iSlideShow = new Class.create();
9 iSlideShow.prototype = {
11 initialize : function (oArgs){
12 this.wait = oArgs.wait ? oArgs.wait : 4000;
13 this.start = oArgs.start ? oArgs.start : 0;
14 this.duration = oArgs.duration ? oArgs.duration : 0.5;
15 this.autostart = (typeof(oArgs.autostart)=='undefined') ? true : oArgs.autostart;
16 this.slides = oArgs.slides;
17 this.counter = oArgs.counter;
18 this.caption = oArgs.caption;
19 this.playButton = $(oArgs.playButton ? oArgs.playButton : 'PlayButton');
20 this.pauseButton = $(oArgs.pauseButton ? oArgs.pauseButton : 'PauseButton');
21 this.iImageId = this.start;
23 this.numOfImages = this.slides.length;
24 if ( !this.numOfImages ) {
28 if ( this.autostart ) {
29 this.startSlideShow();
34 swapImage: function (x,y) {
35 $(this.slides[x]) && $(this.slides[x]).appear({ duration: this.duration });
36 $(this.slides[y]) && $(this.slides[y]).fade({duration: this.duration });
39 // the onload event handler that starts the fading.
40 startSlideShow: function () {
42 window.setInterval(function () {
43 _t.play() },this.wait);
44 this.playButton && this.playButton.hide();
45 this.pauseButton && this.pauseButton.appear({ duration: 0});
53 var imageShow, imageHide;
55 imageShow = this.iImageId+1;
56 imageHide = this.iImageId;
58 if (imageShow == this.numOfImages) {
59 this.swapImage(0,imageHide);
62 this.swapImage(imageShow,imageHide);
66 this.textIn = this.iImageId+1 + ' of ' + this.numOfImages;
71 clearInterval(this.play);
72 this.playButton && this.playButton.appear({ duration: 0});
73 this.pauseButton && this.pauseButton.hide();
77 clearInterval(this.play);
78 $(this.playButton).appear({ duration: 0});
79 $(this.pauseButton).hide();
81 var imageShow, imageHide;
83 imageShow = this.iImageId+1;
84 imageHide = this.iImageId;
86 if (imageShow == this.numOfImages) {
87 this.swapImage(0,imageHide);
90 this.swapImage(imageShow,imageHide);
97 goPrevious: function () {
98 clearInterval(this.play);
99 $(this.playButton).appear({ duration: 0});
100 $(this.pauseButton).hide();
102 var imageShow, imageHide;
104 imageShow = this.iImageId-1;
105 imageHide = this.iImageId;
107 if (this.iImageId == 0) {
108 this.swapImage(this.numOfImages-1,imageHide);
109 this.iImageId = this.numOfImages-1;
111 //alert(NumOfImages-1 + ' and ' + imageHide + ' i=' + i)
114 this.swapImage(imageShow,imageHide);
117 //alert(imageShow + ' and ' + imageHide)
120 this.updatecounter();
123 updatecounter: function () {
124 var textIn = this.iImageId+1 + ' of ' + this.numOfImages;
125 $(this.counter) && ( $(this.counter).innerHTML = textIn );
126 if ( $(this.caption) && ( oNewCaption = $(this.slides[this.iImageId]).down('.image-caption') ) ) {
127 $(this.caption).innerHTML = oNewCaption.innerHTML;
131 Event.observe(window, 'load', function(){
132 if ($$('.category-slide').length < 2) {
133 if (!$$('.category-slide').length) {
136 $$('.category-slide')[0].appear( { duration : 1 });
139 oMySlides = new iSlideShow({
140 autostart : true, // optional, boolean (default:true)
141 start : 0, // optional, slides[start] (default:0)
142 wait : 4000, // optional, milliseconds (default:4s)
143 slides : $$('.category-slide'),
144 counter : 'counter-div-id', // optional...
145 caption : 'caption-div-id', // optional...
146 playButton : 'PlayButton', // optional (default:playButton)
147 pauseButton : 'PauseButton', // optional (default:PauseButton)
149 $$('.category-slide')[0].appear( { duration : 1 });
150 // oMySlides.startSlideShow();