// multiple rotating touts in one script
// 
var toutToRotate=new Array();

//features at a glance
toutToRotate['faag']=new Array();
toutToRotate['faag'][0]="/products/grolier/images/rotate/FAAG_GrolierKids.jpg";
toutToRotate['faag'][1]="/products/grolier/images/rotate/FAAG_ForEducatorsKids.jpg";
toutToRotate['faag'][2]="/products/grolier/images/rotate/FAAG_ForEducatorsPassport.jpg";
//for educators
toutToRotate['fe']=new Array();
toutToRotate['fe'][0]="/products/grolier/images/rotate/Grolier_ForEducatorsKids.jpg";
toutToRotate['fe'][1]="/products/grolier/images/rotate/Grolier_ForEducatorsPassport.jpg";
//amazing animals of the world
toutToRotate['aaotw']=new Array();
toutToRotate['aaotw'][0]="/products/grolier/images/rotate/Amazing_Animals_0.jpg";
toutToRotate['aaotw'][1]="/products/grolier/images/rotate/Amazing_Animals_1.jpg";
toutToRotate['aaotw'][2]="/products/grolier/images/rotate/Amazing_Animals_2.jpg";
//america the beautiful
toutToRotate['atb']=new Array();
toutToRotate['atb'][0]="/products/grolier/images/rotate/America_the_Beautiful_0.jpg";
toutToRotate['atb'][1]="/products/grolier/images/rotate/America_the_Beautiful_1.jpg";
toutToRotate['atb'][2]="/products/grolier/images/rotate/America_the_Beautiful_2.jpg";
//the new book of popular science
toutToRotate['tnbops']=new Array();
toutToRotate['tnbops'][0]="/products/grolier/images/rotate/Book_Pop_Science_0.jpg";
toutToRotate['tnbops'][1]="/products/grolier/images/rotate/Book_Pop_Science_1.jpg";
toutToRotate['tnbops'][2]="/products/grolier/images/rotate/Book_Pop_Science_2.jpg";
//encyclopedia americana
toutToRotate['ea']=new Array();
toutToRotate['ea'][0]="/products/grolier/images/rotate/Encyclopedia_Americana_0.jpg";
toutToRotate['ea'][1]="/products/grolier/images/rotate/Encyclopedia_Americana_1.jpg";
toutToRotate['ea'][2]="/products/grolier/images/rotate/Encyclopedia_Americana_2.jpg";
//grolier multimedia encyclopedia
toutToRotate['gme']=new Array();
toutToRotate['gme'][0]="/products/grolier/images/rotate/Grolier_Multimedia_0.jpg";
toutToRotate['gme'][1]="/products/grolier/images/rotate/Grolier_Multimedia_1.jpg";
toutToRotate['gme'][2]="/products/grolier/images/rotate/Grolier_Multimedia_2.jpg";
//lands and people
toutToRotate['lap']=new Array();
toutToRotate['lap'][0]="/products/grolier/images/rotate/Lands_People_0.jpg";
toutToRotate['lap'][1]="/products/grolier/images/rotate/Lands_People_1.jpg";
toutToRotate['lap'][2]="/products/grolier/images/rotate/Lands_People_2.jpg";
//the new book of knowledge
toutToRotate['tnbon']=new Array();
toutToRotate['tnbon'][0]="/products/grolier/images/rotate/New_Book_Knowledge_0.jpg";
toutToRotate['tnbon'][1]="/products/grolier/images/rotate/New_Book_Knowledge_1.jpg";
toutToRotate['tnbon'][2]="/products/grolier/images/rotate/New_Book_Knowledge_2.jpg";
//la nueva eciclopedia cumbre
toutToRotate['lnec']=new Array();
toutToRotate['lnec'][0]="/products/grolier/images/rotate/Nueva_Enciclopedia_0.jpg";
toutToRotate['lnec'][1]="/products/grolier/images/rotate/Nueva_Enciclopedia_1.jpg";
toutToRotate['lnec'][2]="/products/grolier/images/rotate/Nueva_Enciclopedia_2.jpg";

//var ToutCount = 4;

// Set initial variables
var toutNext=0;


var speed = 3000;
var timer = "off";

//var val1 = randRange(1,ToutCount);

function MakeImageArray(n) {
  	this.length = n;
  	if (document.images) {
	  	for (var i = 1; i<=n; i++) {
	    	this[i] = new Image();
	  	}
  	}
  	return this;  
}

function cycle(section) {
	toutNext++;
	if (toutNext > toutToRotate[section].length-1) toutNext=0;
		document.images['toutImage'].src = toutToRotate[section][toutNext];
    setTimeout('cycle("'+section+'")',speed);
}

function getToutLink() {
  var popup=window.open(ToutLinks[val1],'');
}


function randRange(lowVal,highVal) {
     return Math.floor(Math.random()*(highVal-lowVal+1))+lowVal;
}

// This function loads the images once the rest of the page has loaded and starts the cycling function.
// When new images are put in, change the file names here
function init(section) {

	// Begin Cycle
	if (timer=="off")	{
		setTimeout('cycle("'+section+'")',speed);
	}
	timer = "on";

	document.images["toutImage"].src = toutToRotate[section][0];
	
}