
   /*
     Images Array
     
     If you want to add a pair of images make add a new array line
     and put in the two images you want to display inside the bracket []
     
     To remove a pair of images just remove the [] line they are in
   */
   var images = [
     ["/images/home/home_message_1.gif","/images/home/home_picture_1.jpg"],
     ["/images/home/home_message_2.gif","/images/home/home_picture_2.jpg"], 
     ["/images/home/home_message_3.gif","/images/home/home_picture_3.jpg"],
     ["/images/home/home_message_4.gif","/images/home/home_picture_4.jpg"] 
   ];
     
   /*
     Images Pre-Load Array
      
     Due to the large size of some of the images that are rotating
     it is in our best interest to pre-load them. Set the images to
     be pre-loaded in the images array alone.
   */ 
   var imagesToPreload = ['/images/home/home_picture_2.jpg',
                          '/images/home/home_picture_3.jpg',
                          '/images/home/home_picture_4.jpg'];   
  
   //set the speed of the animations
   var speed = 700;
   
   //set interval for images to show up
   var interval = 4800;
   
   /*
    Actual Animate Function
   */
   function slideThem(imageArray)
   {
    
     var arrayLen = imageArray.length;
     
     var nextImageIndex = 9999;
     
     var current_image = $('#home_picture_content img').attr('src');
     
     //loop through the image array until you find
     for ( i = 0; i < arrayLen; i++ )
     {
        //if current array has that image... set next image to show
        //then break us out of the loop... we found what we were looking
        //for
        if ( images[i][1] == current_image )
        {
            nextImageIndex = ( (i + 1) == arrayLen ? 0 : i+1 );
            break;
        }
     }
     
     //if we did not find the image in the array...
     if ( nextImageIndex == 9999 )
     {
        alert("Something has gone horribly horribly wrong. We apologize for the inconvience. "+
              "It appears our javascript developer has lost his mind. "+
              "When we find him we will let him know you had a issue.");
        return false;
     }
     
     //set images to be shown
     var next_message_image = images[nextImageIndex][0];
     var next_photo = images[nextImageIndex][1];
     
     //animate
     //$('#home_message img').fadeOut(speed,
     //   function(){
     //       $('#home_message img').attr({ src: next_message_image }).fadeIn(speed);       
     //   }
     //);
     
     $('#home_picture_content img').fadeOut(speed,
        function(){
            $('#home_picture_content img').attr({ src: next_photo }).fadeIn(speed);       
        }
     )        
    
   };
   
    //prelaod images function
    function preLoadImages(imagesToPreload)
    {
        for( var i in imagesToPreload )
        {
            $('<img />').attr({ src: imagesToPreload[i] });
        }
    }

   /*
     Pre-load Images
   */
   preLoadImages(imagesToPreload);
   
   /*
     Launch the code!
   */
   setInterval("slideThem(images)",interval);
