1 /***********************************************
2 * Ultimate Fade-In Slideshow (v1.51): © Dynamic Drive (http://www.dynamicdrive.com)
3 * This notice MUST stay intact for legal use
4 * Visit http://www.dynamicdrive.com/ for this script and 100s more.
5 ***********************************************/
7 //SET IMAGE PATHS. Extend or contract array as needed
9 //var fadeimages2=new Array() //2nd array set example. Remove or add more sets as needed.
10 //SET IMAGE PATHS. Extend or contract array as needed
11 //fadeimages2[0]=["../dynamicindex4/bs00825a.gif", "http://www.wired.com", ""]
12 //fadeimages2[1]=["../dynamicindex4/bs00847a.gif", "http://www.theregister.com", ""]
13 //fadeimages2[2]=["../dynamicindex4/hh01478a.gif", "http://www.news.com", "_new"]
15 var fadebgcolor="white"
17 ////NO need to edit beyond here/////////////
19 var fadearray=new Array() //array to cache fadeshow instances
20 var fadeclear=new Array() //array to cache corresponding clearinterval pointers
22 var dom=(document.getElementById) //modern dom browsers
23 var iebrowser=document.all
25 function fadeshow(theimages, fadewidth, fadeheight, borderwidth, delay, pause, displayorder){
29 this.degree=10 //initial opacity degree (10%)
32 fadearray[fadearray.length]=this
33 this.slideshowid=fadearray.length-1
34 this.canvasbase="canvas"+this.slideshowid
35 this.curcanvas=this.canvasbase+"_0"
36 if (typeof displayorder!="undefined")
37 theimages.sort(function() {return 0.5 - Math.random();}) //thanks to Mike (aka Mwinter) :)
38 this.theimages=theimages
39 this.imageborder=parseInt(borderwidth)
40 this.postimages=new Array() //preload images
41 for (p=0;p<theimages.length;p++){
42 this.postimages[p]=new Image()
43 this.postimages[p].src=theimages[p][0]
46 var fadewidth=fadewidth+this.imageborder*2
47 var fadeheight=fadeheight+this.imageborder*2
49 if (iebrowser&&dom||dom) //if IE5+ or modern browsers (ie: Firefox)
50 document.write('<div id="master'+this.slideshowid+'" style="position:relative;width:'+fadewidth+'px;height:'+fadeheight+'px;overflow:hidden;"><div id="'+this.canvasbase+'_0" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div><div id="'+this.canvasbase+'_1" style="position:absolute;width:'+fadewidth+'px;height:'+fadeheight+'px;top:0;left:0;filter:progid:DXImageTransform.Microsoft.alpha(opacity=10);opacity:0.1;-moz-opacity:0.1;-khtml-opacity:0.1;background-color:'+fadebgcolor+'"></div></div>')
52 document.write('<div><img name="defaultslide'+this.slideshowid+'" src="'+this.postimages[0].src+'"></div>')
54 if (iebrowser&&dom||dom) //if IE5+ or modern browsers such as Firefox
58 setInterval("fadearray["+this.slideshowid+"].rotateimage()", this.delay)
62 function fadepic(obj){
65 if (obj.tempobj.filters&&obj.tempobj.filters[0]){
66 if (typeof obj.tempobj.filters[0].opacity=="number") //if IE6+
67 obj.tempobj.filters[0].opacity=obj.degree
69 obj.tempobj.style.filter="alpha(opacity="+obj.degree+")"
71 else if (obj.tempobj.style.MozOpacity)
72 obj.tempobj.style.MozOpacity=obj.degree/101
73 else if (obj.tempobj.style.KhtmlOpacity)
74 obj.tempobj.style.KhtmlOpacity=obj.degree/100
75 else if (obj.tempobj.style.opacity&&!obj.tempobj.filters)
76 obj.tempobj.style.opacity=obj.degree/101
79 clearInterval(fadeclear[obj.slideshowid])
80 obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
81 obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
82 obj.populateslide(obj.tempobj, obj.nextimageindex)
83 obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
84 setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
88 fadeshow.prototype.populateslide=function(picobj, picindex){
90 if (this.theimages[picindex][1]!="") //if associated link exists for image
91 slideHTML='<a href="'+this.theimages[picindex][1]+'" target="'+this.theimages[picindex][2]+'">'
92 slideHTML+='<img src="'+this.postimages[picindex].src+'" border="'+this.imageborder+'px">'
93 if (this.theimages[picindex][1]!="") //if associated link exists for image
95 picobj.innerHTML=slideHTML
99 fadeshow.prototype.rotateimage=function(){
100 if (this.pausecheck==1) //if pause onMouseover enabled, cache object
102 if (this.mouseovercheck==1)
103 setTimeout(function(){cacheobj.rotateimage()}, 100)
104 else if (iebrowser&&dom||dom){
106 var crossobj=this.tempobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
107 crossobj.style.zIndex++
108 fadeclear[this.slideshowid]=setInterval("fadepic(fadearray["+this.slideshowid+"])",50)
109 this.curcanvas=(this.curcanvas==this.canvasbase+"_0")? this.canvasbase+"_1" : this.canvasbase+"_0"
112 var ns4imgobj=document.images['defaultslide'+this.slideshowid]
113 ns4imgobj.src=this.postimages[this.curimageindex].src
115 this.curimageindex=(this.curimageindex<this.postimages.length-1)? this.curimageindex+1 : 0
118 fadeshow.prototype.resetit=function(){
120 var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
121 if (crossobj.filters&&crossobj.filters[0]){
122 if (typeof crossobj.filters[0].opacity=="number") //if IE6+
123 crossobj.filters(0).opacity=this.degree
124 else //else if IE5.5-
125 crossobj.style.filter="alpha(opacity="+this.degree+")"
127 else if (crossobj.style.MozOpacity)
128 crossobj.style.MozOpacity=this.degree/101
129 else if (crossobj.style.KhtmlOpacity)
130 crossobj.style.KhtmlOpacity=this.degree/100
131 else if (crossobj.style.opacity&&!crossobj.filters)
132 crossobj.style.opacity=this.degree/101
136 fadeshow.prototype.startit=function(){
137 var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
138 this.populateslide(crossobj, this.curimageindex)
139 if (this.pausecheck==1){ //IF SLIDESHOW SHOULD PAUSE ONMOUSEOVER
141 var crossobjcontainer=iebrowser? iebrowser["master"+this.slideshowid] : document.getElementById("master"+this.slideshowid)
142 crossobjcontainer.onmouseover=function(){cacheobj.mouseovercheck=1}
143 crossobjcontainer.onmouseout=function(){cacheobj.mouseovercheck=0}