// Javascript Document for various time based functions 
//   Author: Jeff Ludwig 
//   Feel free to glean inspiration, as much inspiration as this document shows
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

  var imgTimer;

// Function img_rotate:
//     This function is designed to load an image into a container div
//     It is designed to: 
//        1) Load a text file containing the listing of the .jpg's that are to be in the rotation
//        2) Build an array of those files
//        3) Choose a random picture and place it in a container div
//		  4) Set a timeout variable so that when it expires, img_rotate is again called
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

  function img_rotate(containerDiv)
  {
    var pics = new Array();

    // Input your files here that you wish to have in the random picture cycle
	// Also, don't forget to count them
	  pics[0] = '/images/rotator/CallingOut.jpg';
	  pics[1] = '/images/rotator/Civ4.jpg';
	  pics[2] = '/images/rotator/Idyllic Mountains.jpg';
	  pics[3] = '/images/rotator/Lava Lake.jpg';
	  pics[4] = '/images/rotator/River Pass.jpg';
	  
      numPics = 5;

    // Get a random picture
      var r=(Math.random() * numPics);
      r = r - 0.5;

      randPic = pics[ Math.round(r) ]; 

    // Set the img in the div specified
      document.getElementById(containerDiv).src=randPic;
      imgTimer=setTimeout('img_rotate("rotatedImg")', 5000);
	
	return null;
  }

window.onload  = function(ee) {
  img_rotate('rotatedImg')
}

img_rotate('rotatedImg')
