  var switch_timeout = 5000;
  var current_image = 0;
  var current_at_front = 1;
  var fade_time = 1000;
  

  function rotate_images () {
    current_image++;

    if (current_image >= num_images ) current_image = 0;

    if(current_at_front == 1) {
      $("#rotate2").fadeIn(fade_time);
      $("#rotate1").fadeOut(fade_time, function() {
        $(this).attr("src", 'images/galleries/2/' + rotation_array[current_image]);
      });

      current_at_front = 2;
    } else {
      $("#rotate1").fadeIn(fade_time);
      $("#rotate2").fadeOut(fade_time, function() {
        $(this).attr("src", 'images/galleries/2/' + rotation_array[current_image]);
      });

      current_at_front = 1;
    }

    setTimeout( function()
      {
        rotate_images();
     }, switch_timeout);


  } // end function rotate_images
  

  $(document).ready(function() {
    rotate_images();
  });


