Вроде что-то нацарапал, не знаю это правильно.
<script type="text/javascript">
var images = new Array(
"images/thumb_1.jpg",
"images/thumb_2.jpg",
"images/thumb_3.jpg",
"images/thumb_4.jpg",
"images/thumb_5.jpg",
"images/thumb_6.jpg",
"images/thumb_7.jpg",
"images/thumb_8.jpg",
"images/thumb_9.jpg",
"images/thumb_10.jpg",
"images/thumb_11.jpg",
"images/thumb_12.jpg",
"images/thumb_13.jpg",
"images/thumb_14.jpg",
"images/thumb_15.jpg",
"images/thumb_16.jpg",
"images/thumb_17.jpg",
"images/thumb_18.jpg",
"images/thumb_19.jpg",
"images/thumb_20.jpg",
"images/thumb_21.jpg",
"images/thumb_22.jpg",
"images/thumb_23.jpg",
"images/thumb_24.jpg",
"images/thumb_25.jpg",
"images/thumb_26.jpg",
"images/thumb_27.jpg",
"images/thumb_28.jpg",
"images/thumb_29.jpg",
"images/thumb_30.jpg"
);
var img = images;
var num = new Array(
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30"
);
var cifr = num;
for (var i = 0; i < 5; i++) {
var a = Math.floor(Math.random() * img.length);
document.write ("<div class='photo'><a href='/user/"+cifr[a]+".html'><img src ='"+img[a]+"' /></a><br><br></div>");
img.splice(a,1);
};
</script>