
scrollerIntervalMs = 100;
scrollerStep = 1;

function clearOld() {
	$("#rotatingContent").fadeOut(2000, getNew);
}

function getNew() {
	$("#rotatingContent").load("/inc/rotating_content/" + currentRefreshCount, '', displayNew);
}

function displayNew() {
	$("#rotatingContent").fadeIn(2000);
	currentRefreshCount = currentRefreshCount + 1;
	setTimeout("startScrollLate();", 5000);
}

function startScrollLate() {
	$("#rotatingContent").addClass('autoscroll');
	setTimeout("checkIfDoneScrolling();", 1);
}

function checkIfDoneScrolling() {
	if ($("#rotatingContent").hasClass('autoscroll')) {
		setTimeout("checkIfDoneScrolling();", 1000);
	} else {
		setTimeout("clearOld();", 5000);
	}
}

$(document).ready(clearOld);
