document.observe("dom:loaded", function() {
	var photo_box = $('photo_box');
	var i = 0;

	// image preloading
	var preload = new Image();
	preload.src = photo_path + photos[i] + ".jpg"; // preload photo for first function call **

	var bottom = $('static_img'); // grab bottom image layer
	var link = $('static_link'); // grab link above images

	var top = new Element('img', { }); // create top image layer
	photo_box.appendChild(top);

	function swap_images() {
		top.src = bottom.src // swap source from bottom to top
		top.setOpacity(1) // set opacity of top to 1

		link.href = member_path + photos[i]; // set link location
		bottom.src = photo_path + photos[i] + ".jpg"; // set new source for bottom
		i++; // iterate to next photo

		if(i >= photos.length) { i = 0; } // if index is equal or longer to array length, zero the photo index
		new Effect.Opacity(top, { from: 1, to: 0, duration: 2.0 }); // top photo fade to 0
		preload.src = photo_path + photos[i] + ".jpg"; // preload photo for next function call **
	}

	swap_images();
	new PeriodicalExecuter(swap_images, 7); // create periodic loop
});
