var currStoryIdx = 0;
var nStories = 0;
var paused = false;
var playing = false;
var mn_300x250 = null;

function pauseStories(force) {
	paused = true;
}
function playStories(force) {
	if (nStories == 0) return;

	if (force) {
		if (playing == true) return;

		paused = false;
		playing = true;
	} else if (paused) {
		playing = false;
		return;
	}

	incrStory(1);

	setTimeout('playStories(false)', 5000)
}
function incrStory(incrVal) {
	if (nStories == 0) return;

	currStoryIdx += incrVal;

	if (currStoryIdx > nStories) {
		currStoryIdx = 1;
	} else if (currStoryIdx < 1) {
		currStoryIdx = nStories;
	}

	showStory();
}
function showStory() {
	vizObj = document.getElementById('dl-' + currStoryIdx);

	if (vizObj != null) {
		for (i = 1; i <= nStories; i++) {
			divObj = document.getElementById('dl-' + i);
			if (divObj != null) {
				divObj.style.display = 'none';
			}
		}
		vizObj.style.display = 'inline';
	}

}