            $(document).ready(function() {backgroundAnimate();});
            
              var width = 960;
              var currentPos = 0;
              var backward = 1; // 1 is true, -1 is false        

               function backgroundAnimate() 
               {                      
                  // apply the background position
                  $('.background').css("background-position", currentPos + "px");
                   
                   if (backward == 1)
                        currentPos--;
                   else
                        currentPos++;  

                  if ((Math.sqrt(currentPos*currentPos) == (8*width)-width) || (currentPos == 0)) // Check if it's time to reverse the direction. The non-zero integer is the number of  panels in the background gradient image, 0 is in case we're back at the start again. 
                  {
                    backward = backward*-1;
                  }
                  setTimeout(backgroundAnimate, 3);     
               }  
               

