website view scripts/slideshow.js @ rev 725

en/packages: Tiny remove <h2>
author Christophe Lincoln <pankso@slitaz.org>
date Tue Jan 11 20:11:46 2011 +0100 (2011-01-11)
parents
children 4123d64d7e06
line source
2 window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init);
4 var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;
6 function so_init()
7 {
8 if(!d.getElementById || !d.createElement)return;
10 css = d.createElement('link');
11 css.setAttribute('href','slideshow.css');
12 css.setAttribute('rel','stylesheet');
13 css.setAttribute('type','text/css');
14 d.getElementsByTagName('head')[0].appendChild(css);
16 imgs = d.getElementById('slideshow').getElementsByTagName('img');
17 for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
18 imgs[0].style.display = 'block';
19 imgs[0].xOpacity = .99;
21 setTimeout(so_xfade,4000);
22 }
24 function so_xfade()
25 {
26 cOpacity = imgs[current].xOpacity;
27 nIndex = imgs[current+1]?current+1:0;
28 nOpacity = imgs[nIndex].xOpacity;
30 cOpacity-=.05;
31 nOpacity+=.05;
33 imgs[nIndex].style.display = 'block';
34 imgs[current].xOpacity = cOpacity;
35 imgs[nIndex].xOpacity = nOpacity;
37 setOpacity(imgs[current]);
38 setOpacity(imgs[nIndex]);
40 if(cOpacity<=0)
41 {
42 imgs[current].style.display = 'none';
43 current = nIndex;
44 setTimeout(so_xfade,4000);
45 }
46 else
47 {
48 setTimeout(so_xfade,60);
49 }
51 function setOpacity(obj)
52 {
53 if(obj.xOpacity>.99)
54 {
55 obj.xOpacity = .99;
56 return;
57 }
59 obj.style.opacity = obj.xOpacity;
60 obj.style.MozOpacity = obj.xOpacity;
61 obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
62 }
63 }