window.onload = rolloverInit;

function rolloverInit() {
var imageRegExp = new RegExp("img_\\d+");
var totalImages = document.images.length;

for (var i=0; i<=totalImages; i++) {
var imgObj = document.images[i];
//alert(imgObj.id);

if (document.images[i].id != null) {
//if ((imgObj.getAttribute("id") == "") || (imgObj.getAttribute("id") == null)) {
if (imgObj.id.match(imageRegExp)) {
imageRollover(imgObj);
}
}
}
}

function imageRollover(thisImage) {
thisImage.onmouseover = rollOver;
}

function rollOver() {
document.getElementById("main_photo").src = this.src;
}