	$(document).ready(function(){
		var numPhotos = 5;
		var showing = 1;
		var preload = 2;
		
		function slideSwitch() {
			var $active = $('#home_photo').find('.active');
			var $next = $('#home_photo').find('.next');
			
			if (showing < numPhotos) { showing ++; }
			else { showing = 1; }
			
			if (showing < numPhotos) { preload ++; }
			else { preload = 1; }
			
			var curPhoto = "http://assets.en.oreilly.com/1/event/30/gov2009_home_photo" + showing + ".jpg";
			var nextPhoto = "http://assets.en.oreilly.com/1/event/30/gov2009_home_photo" + preload + ".jpg";
	
			$next.css('background-image', 'url(' + curPhoto + ')');
			$active.fadeTo(1000, 0, function() {
				$active.css('background-image', 'url(' + curPhoto + ')').css('opacity', 1);
				$next.css('background-image', 'url(' + nextPhoto + ')');
			});
		}
		var photoInterval = setInterval ( slideSwitch, 7000 );
	});



function randomImg(n, prefix) {
	//Generate a random number from 1 to n
	var ranNum = Math.floor(Math.random() * n) + 1;
	
	//Create the random id by concatenating the prefix and the random number
	var id = prefix + ranNum;
	
	if (document.getElementById(id)) {
		document.getElementById(id).style.display = 'inline';
	}
}