/*
******************************************************************************
* $Id: cover_swap.js 47 2008-01-20 15:34:12Z erico $
******************************************************************************
*/

// This function randomly swaps the images on an HTML page.  This is done
// based on the two class name arguments passed in and the 'class' attributes
// given to your image tags.

function cover_swap(iSwapClass, jSwapClass) {

  number_images = document.images.length;

  i_idx = Math.floor(Math.random() * number_images);
  if ( i_idx == number_images ) i_idx = number_images - 1;
  i_class = document.images[i_idx].className;

  j_idx = Math.floor(Math.random() * number_images);
  if ( j_idx == number_images ) j = number_images - 1;
  j_class = document.images[j_idx].className;

  if (i_class == iSwapClass) {
    if (j_class == jSwapClass) {
      swap_image = document.images[i_idx].src;
      document.images[i_idx].src = document.images[j_idx].src;
      document.images[j_idx].src = swap_image;
    }
  }

} // end of cover_swap()
