function getRandom(n){
if(n>1){
var rnd=Math.round(Math.random()*n);
if(rnd==n)rnd=n-1;
return rnd;
}
return 0;
}

