var g_hdl_modulePopularListRotateTimeout = null; //!< Handle for the timeout on the rotation.
var totalLists = 0; //!< the number of lists for this page.
var g_modulePopularListTimeToDisplay = 0; //!< The time, in milliseconds, the rotation should 'pause'.
var currentList = 1; //!< Current list being displayed

/*--------------------------------------------------------------------------*/
/**
	@brief Used to change the list which is currently displayed.
	This method performs the "rotation" service and it is set to run 
	at an interval (in seconds) that is configured by the user.
 */
function CycleLists() { /* <<<( */

	var sponsorTag = null; // temp variable that stores the sponsor content element.
	var listTag = null; // temp variable that stores the avertisement content element.
	var imageTag = null; // temp variable that stores the list's image element.

	// clear time for list cycle
	if (g_hdl_modulePopularListRotateTimeout != null) {
		clearTimeout(g_hdl_modulePopularListRotateTimeout);
	}

	// check that we have lists to rotate
	if (0 < totalLists) {

		// hide current list
		if (document.getElementById('module-popular-list-container-' + currentList)) {
			document.getElementById('module-popular-list-container-' + currentList).style.display = 'none';
		}

		// move to next list
		currentList++;
		if (totalLists < currentList) {
			currentList = 1;
		}

		// display current list
		if (document.getElementById('module-popular-list-container-' + currentList)) {
			document.getElementById('module-popular-list-container-' + currentList).style.display = 'block';
		}

		// set the time below for length of image display
		g_hdl_modulePopularListRotateTimeout = setTimeout(CycleLists, g_modulePopularListTimeToDisplay);
	}
} /* )>>> */

/**
	@brief Used to start the 'rotation' of the lists.
	This method also correctly formats the configurable rotation time
	into milliseconds.
	@param displayTime Int containing the number of seconds the rotation
	should 'pause' for an list.
 */
function StartListCycle(displayTime) { /* <<<( */
	g_modulePopularListTimeToDisplay = displayTime * 1000;
	CycleLists();
} /* )>>> */

