<!-- THIS ROUTINE ROTATES THE SIDEBAR IMAGES -->
<!-- Thanks to Susan Liu for locating this link -->

<!-- Original:  Robert Bui (astrogate@hotmail.com) -->
<!-- Web Site:  http://astrogate.virtualave.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var interval2 = 8; // delay between rotating images (in seconds)
var random_display2 = 0; // 0 = no, 1 = yes
interval2 *= 1000;
var image_index2 = 0;

loadArray();

var number_of_image2 = image_list2.length;

function loadArray() {
image_list2 = new Array();
caption_list2 = new Array();
href_list2 = new Array();
caption_list2[image_index2] = "National Space Biomedical Research Institute"; 
href_list2[image_index2] = "http://www.nsbri.org/";
image_list2[image_index2++] = new imageItem2("images/Sidepanel/sideBarImage1.jpg");
caption_list2[image_index2] = "National Aeronautics and Space Administration"; 
//Code for href added by Tracy Persky 07/30/2007
href_list2[image_index2] = "http://www.nasa.gov/";
image_list2[image_index2++] = new imageItem2("images/Sidepanel/sideBarImage2.jpg");
}

function imageItem2(image_location2) {
  this.image_item2 = new Image();
  this.image_item2.src = image_location2;
}

function get_ImageItemLocation2(imageObj2) {
  return(imageObj2.image_item2.src)
}

function generate2(x, y) {
  var range = y - x + 1;
  return Math.floor(Math.random() * range) + x;
}

function getNextImage2() {
  if (random_display2) {
    image_index2 = generate2(0, number_of_image2-1);
  }
  else {
    image_index2 = (image_index2+1) % number_of_image2;
  }
  var new_image2 = get_ImageItemLocation2(image_list2[image_index2]);
  new_caption2 = caption_list2[image_index2];
  //Code for href added by Tracy Persky 07/30/2007
  new_href2 = href_list2[image_index2];
  return(new_image2);
}

function rotateImage2(place2) {
  var new_image2 = getNextImage2();
  var myPlace2 = document.getElementById(place2);
  myPlace2.src = new_image2;
  myPlace2.title = new_caption2;
  myPlace2.alt = new_caption2;
  //Code for href added by Tracy Persky 07/30/2007
  var myHref2 = document.getElementById("rImage2Anchor");
  myHref2.href = new_href2;
  myHref2.target = "_blank"; 
/*  addCaption(document[place2]); */ 
  var recur_call2 = "rotateImage2('"+place2+"')";
  setTimeout(recur_call2, interval2);
}


/* http://www.suodenjoki.dk/us/productions/articles/addcaption.htm */
function addCaption( oImgElem )
{
  // Insert Caption
  var oCaptionElem = document.createElement("div");
  oCaptionElem.className = "caption";

  var oCaptionTextElem = document.createElement("div");
  oCaptionTextElem.className = "caption-text";
  var oCaptionText = document.createTextNode( oImgElem.alt );
  oCaptionTextElem.appendChild(oCaptionText );
  oCaptionElem.appendChild(oCaptionTextElem);
  
  if(oImgElem.nextSibling)
    oImgElem.parentNode.insertBefore(oCaptionElem, oImgElem.nextSibling);
  else
    oImgElem.parentNode.appendChild(oCaptionElem);

  return true; 
} 


//  End -->
