// JavaScript Document
	// This JpegTurnPage.js file implements jpeg animation.
	// It shows each individual jpeg picture after some time delay 
	// (value of time delay is stored in variable, NextImage_Delay.)
	// Two variables need to be declared in the <head> section eg:
	// 	 var NextImage_Delay=2000;  // 2 seconds delay
    //   var A_Stopped=false;
	// the image array is also needed to be declared in the <head> section
    // if(document.images) {
    //   danceSeries = new Array("dance00.jpg", "dance01.jpg", "dance02.jpg", "dance03.jpg");
    //   imagesCache = new Array();
    //   // Cache the images here
    //   for (i=0;i<imageSeries.length;i++) {
    //        imagesCache[i] = new Image;
    //        imagesCache[i].src = imageSeries[i];
    //    }
   //     theCount will keep track of the current image
   //     theCount = 0;
   //  }
	
	// On the <body> need to include an onload event eg:
	//   onload=turnPage('CEjpegPics')
	// Note the 'CEjpegPics' is the name of the image (placeholder) where animation occurs.
	// If mouseover and mouseout events are required (to pause the animation) then these are
	// are also specified on the image attributes, examples:
    // <img src="images/CEpic02.jpg" width=350 height=300 
	//    border=0 name=CEjpegPics onmouseover=A_Stp() onmouseout=A_Rstrt() />
	//
	var timeoutID;
	var timeronStatus = false;
	var theImgName;
	function turnPage(imgName) {
		theImgName = imgName;  // storing the image name for used in animation
	    if (!(A_Stopped))
	       {
		   if (theCount == imagesCache.length-1)
		      {
		      theCount = 0;
		      }
		   else
		      {
		      theCount++;
		      }

		   // (display a frame of the animation)
		   eval('document.'+imgName+'.src = imagesCache[theCount].src;');

		   // repeat the turnPage function
		   timeoutID = setTimeout("turnPage(theImgName)", NextImage_Delay);
		   timeronStatus = true;
		   }
	}

    // Optional, if these functions are required, it must be included in the img attributes
	// as onmouseout=A_Rstrt() onmouseover=A_Stp()
    // stopping the animation of jpeg pictures when the mouse is on the picture.
	function A_Stp()
	  {
	  A_Stopped=true;
	  if (timeronStatus)
	     clearTimeout(timeoutID);
	  }
	
	// Restarting the animation of jpeg pictures when the mouse is off the picture.
	function A_Rstrt()
	  {
	  A_Stopped=false; 
	  turnPage(theImgName);
	  }
