$(function()
{
	var imageIndex = Math.floor(((Math.random() * 4) + 1));
	var overlayIndex = 2;
	//onload
	$("#rotateclassoverlay1").attr("class", "").addClass("home_image" + imageIndex);
	$("#rotateclassoverlay2").attr("class", "").addClass("home_image" + imageIndex);
	setTimeout(onImageSwapTimer, 10000);

	//timer
	function onImageSwapTimer()
	{
		var rcdo1 = $("#rotateclassoverlay" + getNextOverlayIndex());
		var rcdo2 = $("#rotateclassoverlay" + getNextOverlayIndex());
		rcdo2.css({opacity: 0}).attr("class", "").addClass("home_image" + getNextIndex());
		rcdo1.animate({opacity: 0}, 1200, function()
		{
			//future callback action?
		});
		rcdo2.animate({opacity: 1}, 1200, function()
		{
			//future callback action?
		});
		getNextOverlayIndex();
		setTimeout(onImageSwapTimer, 10000);
	}

	function getNextIndex()
	{
		if (++imageIndex > 3) imageIndex = 1;
		return imageIndex;
	}

	function getNextOverlayIndex()
	{
		if (++overlayIndex > 2) overlayIndex = 1;
		return overlayIndex;
	}
});
