function rand( min, max ) {
// http://kevin.vanzonneveld.net
// + original by: Leslie Hoare
// + bugfixed by: Onno Marsman
// * example 1: rand(1, 1);
// * returns 1: 1
var argc = arguments.length;
if (argc == 0) {
min = 0;
max = 2147483647;
} else if (argc == 1) {
throw new Error('Warning: rand() expects exactly 2 parameters, 1 given');
}
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function count( mixed_var, mode ) {
// http://kevin.vanzonneveld.net
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + input by: _argos
// * example 1: count([[0,0],[0,-4]], 'COUNT_RECURSIVE');
// * returns 1: 6
// * example 2: count({'one' : [1,2,3,4,5]}, 'COUNT_RECURSIVE');
// * returns 2: 6
var key, cnt = 0;
if( mode == 'COUNT_RECURSIVE' ) mode = 1;
if( mode != 1 ) mode = 0;
for (key in mixed_var){
cnt++;
if( mode==1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === Object) ){
cnt += count(mixed_var[key], 1);
}
}
return cnt;
}
var popup = ['код1', 'код2','код3','код4',];
b=popup[rand(0,count(popup)-1)];
//alert(b);
document.write(b);