//Copyright Psand Ltd. 2002. //Author L.Hempelskunt sinister@computertorture.com //Free Software released under GPL - http://www.gnu.org //swap_image.js v1.0 6/2/02 //Rotates an image at regular intervals //This script assumes that an image has already been placed on the document, with an id attribute - see www.computertorture.com/xhtml/ //The include tag for this script MUST be in the body of the html, below the image which requires rotating. //Edit the quantities below //Set image file path. var sFile_path='/images/rot_images/front/'; //Set image file extension. var sExt='.jpg' //Set number of images (in this example 0.jpg to 10.jpg) var iImg_quantity=9; //set image id to rotate var sId='thumb'; //set rotate time interval in milliseconds var iInterval=30000; //Do not edit below this line var iNext=0; var iNow=1; iImg_quantity++; function cacheImage(){ iNext=Math.floor(Math.random()*iImg_quantity); //decide next image to show var im_1=new Image(); //cache next image in advance im_1.src=sFile_path+iNext+sExt; } function rotateImage(){ if(document.images[sId]){ document.images[sId].src=sFile_path+iNow+sExt; iNow=iNext; ident=window.setTimeout("cacheImage(); rotateImage();",iInterval); } } cacheImage(); ident=window.setTimeout("cacheImage(); rotateImage();",30000);