All pastes #1938520 Raw Edit

Image Rotator With Fader

public javascript v1 · immutable
#1938520 ·published 2010-09-11 23:27 UTC
rendered paste body
if (document.images) {    img1 = new Image();    img1.src = "images/re_image_01.jpg";    img2 = new Image();    img2.src = "images/re_image_02.jpg";    img3 = new Image();    img3.src = "images/re_image_03.jpg";}images = ["images/re_image_01.jpg", "images/re_image_02.jpg", "images/re_image_03.jpg"];b = 1;c = 1;function rotateImages() {	var a = document.getElementById("rotator");	a.src = images[b];	var c = 1	b++;	if (b==3) {		b = 0;	}	restore();//Go from 0 opacity to 1}function opacity() {	var a = document.getElementById("rotator");	if (c > 0) {		a.style.opacity = c;		a.style.filter = "alpha(opacity="+c*100+")";//Gotta love IE...		c = c - 0.05;		setTimeout("opacity()",30);	}	else {		rotateImages();//Now that we're hidden, we can secretly switch the images around	}}setTimeout("opacity()",3000);function restore() {	var a = document.getElementById("rotator");	if (c < 1)//If not climaxed {		a.style.opacity = c;		a.style.filter = "alpha(opacity="+c*100+")";		c = c + 0.05;		setTimeout("restore()",30);	}	else {		setTimeout("opacity()",3000);//Image has been showing for 3 seconds, so start fading out	}}