function home_picture_swap() {
	
	images = ['0.jpg','1.jpg','2.jpg','3.jpg','4.jpg','5.jpg','6.jpg','7.jpg'].without($('big-picture').getAttribute('src').gsub('/images/home/', ''))
	next_image = images[parseInt(Math.random() * images.length)]
	n = new Image
	n.onload = do_image_animation
	n.src = '/images/home/' + next_image
}

function do_image_animation(event) {
	$('main').setStyle("background:url(images/home/"+next_image+") no-repeat left top")
	new Effect.Morph('big-picture', {
		style: 'opacity:0;',
		duration: 2,
		afterFinish: function(effect) {
			$('big-picture').setAttribute('src', '/images/home/' + next_image)
			$('big-picture').setOpacity(1)
			setTimeout(function(){home_picture_swap()}, 3000)
		}
	})
}

document.observe("dom:loaded", function(){
  setTimeout(function(){home_picture_swap()}, 5000)
})