var ToutCount = 2;
// Set initial variables
var toutNext = 1;

var speed = 4000;
var timer = "off";

var ToutTabs = new MakeImageArray(2);
var ToutImages = new MakeImageArray(2);
var ToutTexts = new Array(2);
var ToutLinks = new Array(2);
var TabLinks = new Array(2);


// 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 kickstart() {

	if (document.images) 
	{

//		ToutTabs[1].src = "/products/classroombooks/images/browse/ExpertLib/tout_brainbank_science.jpg";
		TabLinks[1] = "/go/THPMM.htm";
		ToutImages[1].src = "/products/classroombooks/images/browse/ExpertLib/tout_brainbank_science.jpg";
		ToutTexts[1] = "<b>Science</b><br />Build science literacy and vocabulary with leveled books.";
		ToutLinks[1] = "/go/THPMM.htm";
//		ToutTabs[2].src = "/products/classroombooks/images/browse/ExpertLib/tout_brainbank_soc-studies.jpg";
		TabLinks[2] = "/go/THPMM.htm";
		ToutImages[2].src = "/products/classroombooks/images/browse/ExpertLib/tout_brainbank_soc-studies.jpg";
		ToutTexts[2] = "<b>Social Studies</b><br />Enhance social studies and reading skills with leveled texts.";
		ToutLinks[2] = "/go/THPMM.htm";

// Begin Cycle		

    	if (timer=="off")
		{
	 		setTimeout("cycle()",speed);
		}
		timer = "on";
	}

}


function MakeImageArray(n) {
  	this.length = n;
  	if (document.images) 
	{
	  	for (var i = 1; i<=n; i++) {
	    	this[i] = new Image();
	  	}
  	}
  	return this;  
}

function cycle() {

  if (document.images){

    toutNext = toutNext + 1;
		if (toutNext > ToutCount) toutNext = 1;
		document.getElementById("toutText").innerHTML = ToutTexts[toutNext];
		document.images["toutImage"].src = ToutImages[toutNext].src;
    setTimeout("cycle()",speed);
  }
}

function getToutLink() {
  document.location = ToutLinks[toutNext];
}
function getTabLink() {
  document.location = TabLinks[toutNext];
}