/**
 * Rotates Callouts on the page.
 *
 *
 */
var gCallouts = new Array();
var gCalloutCurrent = 0;
var gCalloutTimeoutObj = null;
var gCalloutSwapTime = 5000; // how long until game rotate
/**
 * Initializes the editor's choice section.
 *
 */
function doCalloutLoad() {	
	// Collect all callouts. Store in global array for quick access later.
	gCallouts = document.getElementsByClassName("callout");
	if(gCallouts.length > 1) {
		gCalloutTimeoutObj = window.setTimeout("doCalloutRotate();", gCalloutSwapTime);
	}
}

/**
 * Shows the appropriate EC game. Hides the rest.
 */
function showCallout(calloutId) {
	for (var i=0, len=gCallouts.length; i<len; i++) {
		if (i == calloutId) {
			//gCallouts[i].style.display = "block";
			new Effect.Appear(gCallouts[i], {duration : 0.7});
		} else {
			gCallouts[i].style.display = "none";
		}
	}
}
/**
 * Rotates the EC games every X seconds.
 */
function doCalloutRotate() {
	if ( (gCalloutCurrent + 1) < gCallouts.length) {
		gCalloutCurrent++;
	} else {
		gCalloutCurrent = 0;
	}
	showCallout(gCalloutCurrent);
	// reset the timeout
	gCalloutTimeoutObj = window.setTimeout("doCalloutRotate();", gCalloutSwapTime);
}


// Add onload handler
Event.observe(window, "load", doCalloutLoad, true);
