I got a random image rotator working by using the following script (demo). But I was told that it is a bad practice to extend Array.prototype. And it does. It conflicts with the chained select box unless I modify the selected box script. So I guess it's better to not use Array.prototype.shuffle ,isn't it? Here's The script:                Array.prototype.shuffle = function() {                var s = [];                while (this.length) s.push(this.splice(Math.random() * this.length, 1));                while (s.length) this.push(s.pop());                return this;            }            var picData = [                ['img1','url_1'],                ['img2','url_2'],                ['img3','url_3'],            picO = new Array();            randIndex = new Array();             for(i=0; i < picData.length; i++){                picO[i] = new Image();                picO[i].src = picData[i][0];                picO[i].alt = picData[i][1];                randIndex.push(i);            }            randIndex.shuffle();            window.onload=function(){                var mainImgs = document.getElementById('carouselh').getElementsByTagName('img');                for(i=0; i < mainImgs.length; i++){                    mainImgs[i].src = picO[randIndex[i]].src;                    mainImgs[i].parentNode.href = picData[randIndex[i]][1];                    mainImgs[i].alt = picData[randIndex[i]][1];                }            }I'm not sure where to start. I'm reading this article, should I do something like    Array.shuffle = function() {for(var a=[];this.length;)a.push(array.splice(Math.random()*array.length,1));for(;a.length;)this.push(a.pop());return this};Would anyone please point me in some directions to rewrite that part?
Trying to convert an extended Array.prototype to a function
javascript;jquery;array