// create a custom JavaScript object on the fly to handle the  banner rotation
  
  
header_image_object =   {    
  
    // index tracks the current image that is being displayed,      
    // starts at 1 because image 0 is the default image (array index's start from 0)    
    index : 0,         
    
    // an array of images for the header     
    header_images : ["homepage_img.jpg", "homepage_img2.jpg", "homepage_img3.jpg", "homepage_img4.jpg"],      
   
    // function to increase the index value, and reset it if we are at the end of the array    
    inc_index : function() { 
         this.index++;        
         
         if (this.index == this.header_images.length) {
                  this.index = 0;     
             }   
         },         
              
    // getting function to return the current index     
    get_index : function() { return this.index; },         
 
    // function  to fade out, swap the image, increase the index and fade in the image    
    swap : function() {      
        // first fade the image out      
            $("#rotate_image").fadeOut(2000, function() {  
            $("#rotate_image").attr("class", "lower");  
            $("#rotate_image2").attr("class", "higher");
            // change the image      
            $("#rotate_image").attr("src", "/Images/Jpg/" + header_image_object.header_images[header_image_object.index]);   
            
            // fade the image back in         
            $('#rotate_image').fadeIn(2000);  
            setTimeout( "$('#rotate_image2').fadeOut(2000);", 3000);
              setTimeout( "$('#rotate_image').attr('class', 'higher')", 5000);
              setTimeout( "$('#rotate_image2').attr('class', 'lower')", 5000);
            setTimeout( "$('#rotate_image2').attr('src', '/Images/Jpg/' + header_image_object.header_images[header_image_object.index])", 5000);
            setTimeout( "$('#rotate_image2').fadeIn(2000)", 5000);  
             header_image_object.inc_index();      
        });   
     }
};    

            // increase the index              
// swap the image ever 10 seconds 
//setTimeout("setInterval(header_image_object.swap2, 10000)", 5000);
setInterval(header_image_object.swap, 8000); 
