/*! fixedbg - v1.0.0 - 2014-12-14 * https://github.com/nnattawat/fixedbg * Copyright (c) 2014 Nattawat Nonsung; Licensed MIT */ !function(a){var b=function(b){var c=b.css("padding-top");c=+c.substring(0,c.length-2);var d=b.css("padding-bottom");d=+d.substring(0,d.length-2);var e=a(window).innerHeight()-c-d;b.css("min-height",e+"px");var f=b.offset().top;b.data("elTop",f);var g=f+b.height()+c+d;b.data("elBottom",g)};a.fn.fixedBG=function(c){var d=this,e=a.extend({autoAdjust:!0},c);return this.each(function(){b(a(this))}),this.first().css("background-attachment","fixed"),e.autoAdjust&&this.css({"background-size":"cover","background-repeat":"no-repeat"}),a(window).resize(function(){d.each(function(){b(a(this))})}),a(window).scroll(function(){var b=a(window).scrollTop();d.each(function(){var c=a(this).data("elTop"),e=a(this).data("elBottom");b>=c&&e>b&&(d.css("background-attachment","scroll"),a(this).css("background-attachment","fixed"))})}),this}}(jQuery);