jQuery(document).ready(function($) {
  
  $('#parallax').jparallax({yparallax:false}, {xtravel:0.1, ytravel:0.1}, {xtravel:0.2,xorigin:0.55,ytravel:0.1});
  
  $('#levi')
    .css({
      'top':400
    })
    .animate({
      'top':'-=300'
    }, 8000);
  
  var pause = 0, count = 0;
  
  function rawk() {
    
    var pixels = 5, duration = 1000;
    
    if (pause == 0) {
    
      $('.wave').each(function(i) {
        // this.innerHTML = this + " is the element, " + i + " is the position";
        var $this = $(this);
        var position = $this.css('backgroundPosition').split(' '), // ["0px", "0px"]
          x = position[0];
        
        if (count%2) {
          var dir1 = '+', dir2 = '-';
        } else {
          var dir2 = '+', dir1 = '-';
        }
        
        if (i%2) {
          // $this.css('background')
          $this.animate({
            'background-position-x': dir1 + '=' + pixels
          }, duration, 'swing');
        } else {
          $this.animate({
            'background-position-x': dir2 + '=' + pixels
          }, duration, 'swing', function(){ pause = 0; count++; rawk(); });
        }
        console.log('hi');
      });
      
      
    } // /if
  } // function
  
  rawk();
  
});

