codice:
<script type="text/javascript">
function ImmagineCasualeTempo(){
NumberOfImagesToRotate = 37;

FirstPart = '<img src="images/random/logo';
LastPart = '.jpg" height="720" width="">';
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.getElementById('gallery').innerHTML=FirstPart + r + LastPart;

setTimeout(function(){ImmagineCasualeTempo()},5000)
}
window.onload=ImmagineCasualeTempo;
</script>
e il div con class="gallery" diventa id="gallery" dovrebbe andare