daily pastebin goal
26%
SHARE
TWEET

Ryan

a guest May 26th, 2009 223 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function rotateImages(x){
  2.         var images=new Array();
  3.        
  4.         // Set your images here
  5.         images[0] = '/images/scroller/flag.jpg';
  6.         images[1] = '/images/scroller/1.jpg';
  7.         images[2] = '/images/scroller/2.jpg';
  8.         images[3] = '/images/scroller/3.jpg';
  9.         images[4] = '/images/scroller/4.jpg';
  10.         images[5] = '/images/scroller/5.jpg';
  11.        
  12.         // Preload Images, only on first iteration
  13.         if(x != 1){
  14.                 var preload=new Array();
  15.                 for (p=0;p<images.length;p++){
  16.                         preload[p]=new Image();
  17.                         preload[p].src=images[p];
  18.                 }
  19.         }
  20.        
  21.         // Delay between fades in miliseconds, 5000 = 5 seconds
  22.         var delay = 4000;
  23.        
  24.         // The ID of the container div you want to scroll images in
  25.         var container = "scroller";
  26.        
  27.         // Immediately places the first image on first rotation
  28.         if(x!=1){document.getElementById(container).innerHTML = '<img src="'+images[0]+'" />';images.shift();}
  29.        
  30.         // Incrementally create 'fade to next image' events
  31.         for(i=0;i<images.length;i++){var z = setTimeout("changeTo('"+images[i]+"','"+container+"')",(i+1)*delay);}
  32.        
  33.         // Loop after enough time has passed to fade all images
  34.         setTimeout("rotateImages(1);",images.length * delay);
  35. }
  36.  
  37. function changeTo(image,container){    
  38.         var f = setTimeout("document.getElementById('"+container+"').innerHTML = '<img src=\""+image+"\" />'",100);
  39.         var j = new Effect.Opacity(container,{from:0,to:1, duration: 1});return false;
  40. }
  41.  
  42. rotateImages(0);
RAW Paste Data
Top