/*
Local JavaScript Variables

A variable declared within a JavaScript function becomes LOCAL and can only be accessed within that function. (the variable has local scope).
You can have local variables with the same name in different functions, because local variables are only recognized by the function in which they are declared.
Local variables are destroyed when you exit the function.


Global JavaScript Variables
Variables declared outside a function become GLOBAL, and all scripts and functions on the web page can access it.
Global variables are destroyed when you close the page.

If you declare a variable, without using "var", the variable always becomes GLOBAL.

*/
  
  // called once on page load
jQuery( document ).ready( function() {
  
  count = 0;    
  imagePaths = new Array(4);     // declare 4 elements in array without initialization
  for ( var i=0, j=1; i<imagePaths.length; ++i, ++j )
  {
    imagePaths[i] = '/images/splash/bk'+j+'.jpg'; 
  }
    
    
  for ( var i=0; i<imagePaths.length; ++i )
  { 
    $('<img />').attr( 'src', imagePaths[i] ).appendTo('div#content').css({ display: "none" });   
           
  }  

  // repeadedly called ( time interval ) 
  window.setInterval(function() {
            
        $('div#content').css('background-image', 'url("'+imagePaths[count]+'")'); 
       
        count++;         
        if ( count >= 4 ){
            count = 0; 
        }    
             
  }, 7000);
 
});
