Hello,
I am using this script to rotate background images and it is working great HOWEVER we would like to control the order of the rotation and I am just not sure how to modify this code to do that?
I have looked and tried several options but I am just missing something and appreciate any help you can provide.
<script type="text/javascript">
function ChangeCSSBgImg() {
if (!document.getElementById) return true;
var MyElement = "logo" //The ID of the element you want to change
var ImgPath = "graphics/en-US/new/rotate/" //The file path to your images
if (!document.getElementById(MyElement)) return true;
var random_images = new Array (5);
random_images[0] = "company_logo-1.jpg";
random_images[1] = "company_logo-2.jpg";
random_images[2] = "company_logo-3.jpg";
random_images[3] = "company_logo-4.jpg";
random_images[4] = "company_logo-5.jpg";
random_images[5] = "company_logo-6.jpg";
random_images[6] = "company_logo-7.jpg";
random_images[7] = "company_logo-8.jpg";
random_images[8] = "company_logo-9.jpg";
random_images[9] = "company_logo-10.jpg";
var $header = document.getElementById(MyElement);
var $backgroundurl = $header.style.backgroundImage;
var ImgURL = "url(" + ImgPath + random_images[rand(random_images.length)] + ")";
if ($backgroundurl != ImgURL) {
$header.style.backgroundImage = ImgURL;
}
movement = setTimeout("ChangeCSSBgImg()",14000);
}
/* random number generator */
function rand(n) {
return ( Math.floor ( Math.random ( ) * n ) );
}
/* Custom onload function */
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
/* trigger onload */
addLoadEvent(ChangeCSSBgImg);
</script>