function update(){
            var pos = $window.scrollTop();              

            $this.each(function(){
                var $element = $(this);
                var top = $element.offset().top;
                var height = getHeight($element);

                // Check if totally above or totally below viewport
                if (top + height < pos || top > pos + windowHeight) {
                    return;
                }

                $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px");
            });
        }
// function to be called whenever the window is scrolled or resized
function to be called whenever the window is scrolled or resized
function to be called whenever the window is scrolled or resized
function update(){
            var pos = $window.scrollTop();              
            $this.each(function(){
                var $element = $(this);
                var top = $element.offset().top;
                var height = getHeight($element);
                if (top + height < pos || top > pos + windowHeight) {
                    return;
                }
                $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px");
            });
        }
function update ( ) { var pos = $window . scrollTop ( ) ; $this . each ( function ( ) { var $element = $ ( this ) ; var top = $element . offset ( ) . top ; var height = getHeight ( $element ) ; if ( top + height < pos || top > pos + windowHeight ) { return ; } $this . css ( 'backgroundPosition' , xpos + " " + Math . round ( ( firstTop - pos ) * speedFactor ) + "px" ) ; } ) ; }
function to be called whenever the window is scrolled or resized
function to be called whenever the window is scrolled or resized
// Check if totally above or totally below viewport