// mama - www.yamago.net - rand(pValue) // ------------------------------------ // renvoie aléatoirement un ou plusieurs éléments // d'un tableau. // pValue est un parametre optionnel, si il vaut 1, 0 // ou n'est pas transmis, rand() renvoie la valeur de // l'élément tiré au hasard, sinon rand() renvoie un // tableau d'éléments aléatoires: // monTableau=["bob","bill","babar","gobi"]; // monTableau.rand() renvoie par exemple "bill" // monTableau.rand(2) renvoie par exemple ["bob","babar"] Array.prototype.rand = function (pValue) { if (pValue>this.length) return this; if (pValue==undefined || pValue <2 ) { return this[Math.floor(Math.random()*this.length)]; } else { var tmp=this.slice(); var result=[]; for (var i = 0;i