// Setup variables
var rotation_interval = 5000;
var rotation_on = true;
var rotation_count = 0;

// These hold the rotator_contents' uh content
var article_viewers = [];
var article_objects = [];

// This function runs after page finishes loading. It finds the rotator viewer
// and rotator_content divs. 
rotator_load =
function ()
{
	// Get array of article viewers.
	article_viewers = getElementsByClassName(document, "div", "article_viewer");
	// Get a list of article_content dls and then process them into DBObjects.
	var dl_list = getElementsByClassName(document, 'dl', 'article_content');
	for (var i=0; i < dl_list.length; i++)
	{
		article_objects.push(createDBObject(dl_list[i]));
	}
	// Fill with initial values
	rotator_loop();
};

rotator_loop = 
function ()
{
	for (var i=0; i < article_viewers.length; i++)
	{
		var rotator_index = (rotation_count + i) % article_objects.length;
		render_object(article_objects[rotator_index], article_viewers[i]);
	}

	if (rotation_on) 
	{
		setTimeout('rotator_loop()', rotation_interval);
	}

	rotation_count++;
};
