Prueba esto a ver si te ayuda, tiene un problema con el alt porque creo que ese atributo no es manejable vía JavaScript, pero como aproximación creo que funciona.
Código PHP:
<html>
<head>
<script language="JavaScript">
var Img = new VecImgs();
var Alt = new VecAlts();
function VecImgs(){
n=0;
this[n++] = "paginas/fotos/imagen1.jpg";
this[n++] = "paginas/fotos/imagen2.jpg";
this[n++] = "paginas/fotos/imagen3.jpg";
this[n++] = "paginas/fotos/imagen4.jpg";
this[n++] = "paginas/fotos/imagen5.jpg";
this[n++] = "paginas/fotos/imagen6.jpg";
this.N=n;
}
function VecAlts(){
n=0;
this[n++]="imagen 1 \n\251 autor 1";
this[n++]="imagen 2 \n\251 autor 2";
this[n++]="imagen 3 \n\251 autor 3";
this[n++]="imagen 4 \n\251 autor 4";
this[n++]="imagen 5 \n\251 autor 5";
this[n++]="imagen 6 \n\251 autor 6";
this.N=n;
}
function repetir(){
pos = Math.floor(Math.random() * Img.N);
sSrc = Img[pos];
sAlt = Alt[pos];
with (document.getElementById("aImg")){
href = sSrc;
alt = sAlt;
}
document.getElementById("iImg").src = sSrc;
}
</script>
</head>
<body>
<script language="JavaScript">
pos = Math.floor(Math.random() * Img.N);
sSrc = Img[pos];
sAlt = Alt[pos];
document.write("<a id='aImg' href='"+sSrc+"' alt='"+sAlt+"' target='_blank'><IMG id='iImg' SRC='"+sSrc+"' width=186 height=279>");
id = setInterval("repetir()",5000);
</script>
</body>
</html>
Saludos.