var $j = jQuery.noConflict();

$j(document).ready(function() {
	var imgCount = 3;
	animate("promo", 1, imgCount);
});

function animate(itemId, current, total) {
	$j("#"+itemId).hide();
	if (current > total) {
		current = 1;
	}
	var previous = current - 1;
	if (current == 1) {
		previous = total;
	}
	swap(itemId, current+".jpg");
	$j("#splash").css({
		'background-image': 'url(../../gallery/homepage-rotating-images/promo'+previous+'.jpg)'
	});
	$j("#"+itemId).fadeIn("slow");
	current++;
	var tInt = setTimeout("animate('"+itemId+"', '"+current+"', '"+total+"')", 4000);	
}

function swap(imgId, appendix) {
	var img = document.getElementById(imgId);
	path = img.src.substring(0, img.src.indexOf(imgId));
	img.src = path + imgId + appendix;
}