function startRotating() {
	// Load in the images so we don't get a delay
	img0 = new Image();
	img0.src = "images/index/image-0.jpg";
	img1 = new Image();
	img1.src = "images/index/image-1.jpg";
	img2 = new Image();
	img2.src = "images/index/image-2.jpg";
	img3 = new Image();
	img3.src = "images/index/image-3.jpg";
	img4 = new Image();
	img4.src = "images/index/image-4.jpg";
	img5 = new Image();
	img5.src = "images/index/image-5.jpg";
	img6 = new Image();
	img6.src = "images/index/image-6.jpg";
	img7 = new Image();
	img7.src = "images/index/image-7.jpg";
	img8 = new Image();
	img8.src = "images/index/image-8.jpg";
	img9 = new Image();
	img9.src = "images/index/image-9.jpg";
	img10 = new Image();
	img10.src = "images/index/image-10.jpg";
	img11 = new Image();
	img11.src = "images/index/image-11.jpg";
	
	// Rotate images every 5 seconds
	window.setTimeout("rotateImages(1)", 5000);
}

function rotateImages(index) {
	// Fade out the current image
	imageId = "rotatingPhoto";
	fadeOut(imageId,100);
	
	// Change to the new image
	srcArray = new Array ("images/index/image-0.jpg", "images/index/image-1.jpg", "images/index/image-2.jpg", "images/index/image-3.jpg", "images/index/image-4.jpg", "images/index/image-5.jpg", "images/index/image-6.jpg", "images/index/image-7.jpg", "images/index/image-8.jpg", "images/index/image-9.jpg", "images/index/image-10.jpg", "images/index/image-11.jpg");
	
	newSrc = srcArray[index];
	index = (index + 1) % 12;
	window.setTimeout("swapImage('" + imageId + "','" + newSrc + "')", 1100);
	
	// Fade in the new image
	window.setTimeout("fadeIn('" + imageId + "',0)", 1100);
	
	// Change the image again in 5 seconds
	window.setTimeout("rotateImages(" + index + ")", 5000);
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function swapImage(objId, newSrc) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		obj.src = newSrc;
	}
}

function fadeIn(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		}
	}
}

function fadeOut(objId,opacity) {
	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity >= 0) {
			setOpacity(obj, opacity);
			opacity -= 10;
			window.setTimeout("fadeOut('"+objId+"',"+opacity+")", 100);
		}
	}
}

