/* plugin: jquery parallax version 1.1.3 author: ian lunn twitter: @ianlunn author url: http://www.ianlunn.co.uk/ plugin url: http://www.ianlunn.co.uk/plugins/jquery-parallax/ dual licensed under the mit and gpl licenses: http://www.opensource.org/licenses/mit-license.php http://www.gnu.org/licenses/gpl.html */ (function($){var $window=$(window);var windowheight=$window.height();$window.resize(function(){windowheight=$window.height();});$.fn.bgparallax=function(xpos,speedfactor,outerheight){var $this=$(this);var getheight;var firsttop;var paddingtop=0;$this.each(function(){firsttop=$this.offset().top;});if(outerheight){getheight=function(jqo){return jqo.outerheight(true);};}else{getheight=function(jqo){return jqo.height();};} if(arguments.length<1||xpos===null)xpos="50%";if(arguments.length<2||speedfactor===null)speedfactor=0.1;if(arguments.length<3||outerheight===null)outerheight=true;function update(){var pos=$window.scrolltop();$this.each(function(){var $element=$(this);var top=$element.offset().top;var height=getheight($element);if(top+heightpos+windowheight){return;} $this.css('backgroundposition',xpos+" "+math.round((firsttop-pos)*speedfactor)+"px");});} $window.bind('scroll',update).resize(update);update();};})(jquery);