$(document).ready(function(){
	
	$("a.lightbox").lightBox();

	var slideshowSpeed = 3000;
	var interval;
	var currentImg = 0;
	var navigate = function(direction) {
		
		// Check which current image we need to show
		if(direction == "next") {
			currentImg++;
			if(currentImg == photos.length + 1) {
				currentImg = 1;
			}
		} else {
			currentImg--;
			if(currentImg == 0) {
				currentImg = photos.length;
			}
		}

		showImage(photos[currentImg - 1]);
		
	};
	
	var currentZindex = -1;
	var showImage = function(photoObject) {
		$(".header2").css({"background-image" : "url(" + photoObject.image + ")"});
	};
	
	var stopAnimation = function() {
		clearInterval(interval);
	};
	
	// We should statically set the first image
	navigate("next");
	
	// Start playing the animation
	interval = setInterval(function() {
		navigate("next");
	}, slideshowSpeed);
	
});

