// JavaScript Document
// Script to change order of 2 images in different locations at the same time and makes the selection of image pairs random.
// add onload = "rotate()" to body tag
// reference images as img name = "pic1" src = "/phycommon/images/hleft/physics1left.jpg" and
// img name = "pic2" src = "/phycommon/images/hright/physics1right.jpg"
// reference this script in head tag e.g. script type="text/javascript" language="javascript" src="/phycommon/java/changeimages.js">

 var speed = 20000; // milliseconds
  var Pic1 = new Array();
  var Pic2 = new Array();

  Pic1[0] = "/phycommon/images/hleft/physics1left.jpg";
  Pic1[1] = "/phycommon/images/hleft/physics2left.jpg";
  Pic1[2] = "/phycommon/images/hleft/physics3left.jpg";
  Pic1[3] = "/phycommon/images/hleft/physics4left.jpg";
  Pic1[4] = "/phycommon/images/hleft/physics5left.jpg";
  Pic1[5] = "/phycommon/images/hleft/physics6left.jpg";
  // change to correct path of images. you can add more pictures in the same style

  Pic2[0] = "/phycommon/images/hright/physics1right.jpg";
  Pic2[1] = "/phycommon/images/hright/physics2right.jpg";
  Pic2[2] = "/phycommon/images/hright/physics3right.jpg";
  Pic2[3] = "/phycommon/images/hright/physics4right.jpg";
  Pic2[4] = "/phycommon/images/hright/physics5right.jpg";
  Pic2[5] = "/phycommon/images/hright/physics6right.jpg";
  // change to correct path of images. you can add more pictures in the same style, but make sure Pic1 and Pic2 are the same length

  var j = Math.floor(Math.random() * Pic1.length);
  // randomizes the image order of arrays

  var t;
  function rotate(){
    if (document.body){
      
      document.pic1.src = Pic1[j];

      document.pic2.src = Pic2[j];
      j++;
      if (j == Pic1.length) {        j=0;      }  
      t = setTimeout('rotate()', speed);
  }
}
//end