// This first line wraps my JavaScript around some very nice jQuery 
// syntactical sugar; another way of doing this would be to go:
// 
//  $(document).ready(function() {
//    // Handler for .ready() called.
//  });
// 
// Wrapping our code in the jQuery ready method does several things: 1) it
// allows us to use the jQuery library; 2) it stops the global namespace
// from being filled with all kinds of variables that could interfere with
// each other, this is called a closure; 3) it provides us with a shortcut to
// the jQuery namespace with the `$`; 4) it only performs the actions within
// AFTER the page has been fully loaded.
// 
// For more on jQuery, go to jquery.com.
jQuery(function($){
  
  // This is another closure, called an 'anonymous closure' because it has no 
  // name, it merely executes itself.
  (function(){
    
    // Quick, explanatory variables to further illustrate what is going on.
    var
      fade_delay_in_milliseconds = 2500,
      fade_length_in_milliseconds = 1500;
    
    // This is a little more complex. I'll try to break it down between the
    // dots; the dots together make what is called a 'chain'.
    // 
    // Before the first dot is a call to the global jQuery method which 
    // includes the argument '#image-wrapper img', which is a CSS selector
    // defining the location of the image we want to fade out.
    // 
    // After the first dot is a delay method which will delay the following 
    // command by a set number of milliseconds.
    // For more on the delay method, see http://api.jquery.com/delay/.
    // 
    // After the second dot is the fadeOut method, which is a built-in jQuery
    // animation method that progressively, bits at a time, mathematically 
    // until it reaches the opacity of zero, use Firefox's Firebug to see this
    // in action (see the README).
    // For more on the fadeOut method, see http://api.jquery.com/fadeOut/.
    $('#fade-image2 img').delay( fade_delay_in_milliseconds ).fadeIn( fade_length_in_milliseconds );
    
  // The empty parenthesis before the semicolon is what makes the anonymous
  // closure execute itself.
  })();

// Closes the jQuery global method.
});