/******************************************************************************
 * rotate.js takes the paragraphs in the rotate div and displays them one at
 * at a time with a fade.
 ******************************************************************************/

var gDivs, thisDiv, counter=0;

function init() {
	/* takes the DIVs from the rotate DIV
	 * and moves them out of the way, then
	 * displays them one at a time */
	//test browser
	if (!document.getElementById) return false;
	if (!document.getElementById("rotate")) return false;

	
	gDivs = document.getElementById("rotate").getElementsByTagName("div");

	/* loop through all, but first, DIVs
	 * and add class "hide" */
	for(var i=1;i<gDivs.length;i++) {
		gDivs[i].className = "hide";
	} // end for loop
	
	rotate();

} // end init()

function fade() {
	/* Timers to hide all DIVs in gDivs,
	 * then advances counter and fades
	 * in DIV */
	//test browser
	if (gDivs==null) return false;
	// advance or reset counter
	counter = (counter < gDivs.length-1) ? counter+1 : 0;
	
	// hide all DIVs
	hideDivs();
	
	setTimeout("gDivs[counter].className='start'", 100);
	setTimeout("gDivs[counter].className='o20'", 300);
	setTimeout("gDivs[counter].className='o40'", 500);
	setTimeout("gDivs[counter].className='o60'", 700);
	setTimeout("gDivs[counter].className='o80'", 900);
	setTimeout("gDivs[counter].className='end'", 1100);
}

function rotate() {
	/* Interval that calls fade()
	 * every few seconds */
	if (gDivs==null) return false;
	setInterval("fade()",5000);
}

function hideDivs() {
	/* loop through each DIV
	 * and add class "hide" */
	for(var i=0;i<gDivs.length;i++) {
		gDivs[i].className = "hide";
	} // end for loop
} // end hideDivs()




addLoadEvent(init);

