// script to rotate images and links.
// copyright (C) 2005 by Christ Presbyterian Church, All rights reserved
// used by permission and  modified for council site April 20, 2005
// added two more items to menu so upped link count 100995

var stop = 0; // flag which stops rotation, 0=rotate, 1=stop, set in html cod
var maxrecursions = 1500; // max number rotations
var recursions = 0; // counter to count rotations
var loop = 0; //image counter to indicate current image, starts at 0
var img=new Array(); // array of images
var number_of_pictures=2; // the number of pictures we want to rotate
for (i=0;i<number_of_pictures;i++){
 img[i]=new Image();
}

// the image array
img[0].src="learntosquaredance.jpg"; // first image
img[1].src="stateoutfit.jpg"; 


// the corresponding links
var mlinks = new Array(); 
mlinks[0] = "learn2.html"; // first link
mlinks[1] = "outfit2.html";


// this function will do the rotating
function updateImg() {

	// first check to see if we should change the image
	if(stop==0) {
		loop++; // update the image index
      	 	if (loop == number_of_pictures) {
			loop=0; }// its greater than number of images so reset
		document.theimage.src=img[loop].src; // reset the image source
		// change the href for the 9th link, links start at 0
                // pictures are links also
		document.links[10].href=mlinks[loop];
	} // end stop==0

        // check on max recursions if more than maxrecursions don't recurse
        if ( recursions <= maxrecursions) {
	recursions++; // up the recursion count
       	setTimeout("updateImg();",3000); // loop after 3 seconds
	} // end recursion check
} 



