var fixto=function(t,i,e){var o,s=(o={getAll:function(t){return e.defaultView.getComputedStyle(t)},get:function(t,i){return this.getAll(t)[i]},toFloat:function(t){return parseFloat(t,10)||0},getFloat:function(t,i){return this.toFloat(this.get(t,i))},_getAllCurrentStyle:function(t){return t.currentStyle}},e.documentElement.currentStyle&&(o.getAll=o._getAllCurrentStyle),o),n=function(){function i(t){this.element=t,this.replacer=e.createElement("div"),this.replacer.style.visibility="hidden",this.hide(),t.parentNode.insertBefore(this.replacer,t)}return i.prototype={replace:function(){var t=this.replacer.style,i=s.getAll(this.element);t.width=this._width(),t.height=this._height(),t.marginTop=i.marginTop,t.marginBottom=i.marginBottom,t.marginLeft=i.marginLeft,t.marginRight=i.marginRight,t.cssFloat=i.cssFloat,t.styleFloat=i.styleFloat,t.position=i.position,t.top=i.top,t.right=i.right,t.bottom=i.bottom,t.left=i.left,t.display=i.display},hide:function(){this.replacer.style.display="none"},_width:function(){return this.element.getBoundingClientRect().width+"px"},_widthOffset:function(){return this.element.offsetWidth+"px"},_height:function(){return jQuery(this.element).outerHeight()+"px"},_heightOffset:function(){return this.element.offsetHeight+"px"},destroy:function(){t(this.replacer).remove();for(var i in this)this.hasOwnProperty(i)&&(this[i]=null)}},e.documentElement.getBoundingClientRect().width||(i.prototype._width=i.prototype._widthOffset,i.prototype._height=i.prototype._heightOffset),{MimicNode:i,computedStyle:s}}();function r(){this._vendor=null}r.prototype={_vendors:{webkit:{cssPrefix:"-webkit-",jsPrefix:"Webkit"},moz:{cssPrefix:"-moz-",jsPrefix:"Moz"},ms:{cssPrefix:"-ms-",jsPrefix:"ms"},opera:{cssPrefix:"-o-",jsPrefix:"O"}},_prefixJsProperty:function(t,i){return t.jsPrefix+i[0].toUpperCase()+i.substr(1)},_prefixValue:function(t,i){return t.cssPrefix+i},_valueSupported:function(t,i,e){try{return e.style[t]=i,e.style[t]===i}catch(t){return!1}},propertySupported:function(t){return void 0!==e.documentElement.style[t]},getJsProperty:function(t){if(this.propertySupported(t))return t;if(this._vendor)return this._prefixJsProperty(this._vendor,t);var i;for(var e in this._vendors)if(i=this._prefixJsProperty(this._vendors[e],t),this.propertySupported(i))return this._vendor=this._vendors[e],i;return null},getCssValue:function(t,i){var o,s=e.createElement("div"),n=this.getJsProperty(t);if(this._valueSupported(n,i,s))return i;if(this._vendor&&(o=this._prefixValue(this._vendor,i),this._valueSupported(n,o,s)))return o;for(var r in this._vendors)if(o=this._prefixValue(this._vendors[r],i),this._valueSupported(n,o,s))return this._vendor=this._vendors[r],o;return null}};var h,l=new r,p=l.getJsProperty("transform");var f,d=l.getCssValue("position","sticky"),a=l.getCssValue("position","fixed");function c(i,e,o){this.child=i,this._$child=t(i),this.parent=e,this.options={className:"fixto-fixed",top:0},this._setOptions(o)}function u(t,i,e){c.call(this,t,i,e),this._replacer=new n.MimicNode(t),this._ghostNode=this._replacer.replacer,this._saveStyles(),this._saveViewportHeight(),this._proxied_onscroll=this._bind(this._onscroll,this),this._proxied_onresize=this._bind(this._onresize,this),this.start()}function _(t,i,e){c.call(this,t,i,e),this.start()}"Microsoft Internet Explorer"===navigator.appName&&(f=parseFloat(navigator.appVersion.split("MSIE")[1])),c.prototype={_mindtop:function(){var t=0;if(this._$mind)for(var i,e,o=0,n=this._$mind.length;o=this._fullOffset("offsetTop",this._ghostNode))return void this._unfix()}else if(this._scrollTop>this._parentBottom||this._scrollTop<=this._fullOffset("offsetTop",this._ghostNode)-this.options.top-this._mindtop())return void this._unfix();this._adjust()}else{var t=s.getAll(this.child);(this._scrollTopthis._fullOffset("offsetTop",this.child)-this.options.top-this._mindtop()&&this._viewportHeight>this.child.offsetHeight+s.toFloat(t.marginTop)+s.toFloat(t.marginBottom)||this.options.toBottom)&&(this._fix(),this._adjust())}},_adjust:function(){var i=0,e=this._mindtop(),o=0,n=s.getAll(this.child),r=null;if(h&&(r=this._getContext())&&(i=Math.abs(r.getBoundingClientRect().top)),(o=this._parentBottom-this._scrollTop-(this.child.offsetHeight+s.toFloat(n.marginBottom)+e+this.options.top))>0&&(o=0),this.options.toBottom);else{var l=this.options.top;0===l&&(l=t("body").offset().top),this.child.style.top=Math.round(o+e+i+l-s.toFloat(n.marginTop))+"px"}},_fullOffset:function(t,i,e){for(var o=i[t],s=i.offsetParent;null!==s&&s!==e;)o+=s[t],s=s.offsetParent;return o},_getContext:function(){for(var t,i=this.child,o=null;!o;){if((t=i.parentNode)===e.documentElement)return null;if("none"!==s.getAll(t)[p]){o=t;break}i=t}return o},_fix:function(){var i=this.child,o=i.style,n=s.getAll(i),r=i.getBoundingClientRect().left,l=n.width;if(this.options._original,this._saveStyles(),e.documentElement.currentStyle&&(l=i.offsetWidth,"border-box"!==n.boxSizing&&(l-=s.toFloat(n.paddingLeft)+s.toFloat(n.paddingRight)+s.toFloat(n.borderLeftWidth)+s.toFloat(n.borderRightWidth)),l+="px"),h){this._getContext();r=this._$child.offset().left}if(this._replacer.replace(),o.left=r-s.toFloat(n.marginLeft)+"px",o.width=l,o.position="fixed",this.options.toBottom)o.top="",o.bottom=this.options.top+s.toFloat(n.marginBottom)+"px";else{o.bottom="";var p=this.options.top;0===p&&(p=t("body").offset().top),o.top=this._mindtop()+p-s.toFloat(n.marginTop)+"px"}this._$child.addClass(this.options.className),this.fixed=!0,this._$child.trigger("fixto-added")},_unfix:function(){var t=this.child.style;this._replacer.hide(),t.position=this._childOriginalPosition,t.top=this._childOriginalTop,t.bottom=this._childOriginalBottom,t.width=this._childOriginalWidth,t.left=this._childOriginalLeft,this.options.always||(this._$child.removeClass(this.options.className),this._$child.trigger("fixto-removed")),this.fixed=!1},_saveStyles:function(){var t=this.child.style;this._childOriginalPosition=t.position,this.options.toBottom?(this._childOriginalTop="",this._childOriginalBottom=t.bottom):(this._childOriginalTop=t.top,this._childOriginalBottom=""),this._childOriginalWidth=t.width,this._childOriginalLeft=t.left},_onresize:function(){this.refresh()},_saveViewportHeight:function(){this._viewportHeight=i.innerHeight||e.documentElement.clientHeight},_stop:function(){this._unfix(),t(i).unbind("scroll.fixto mousewheel",this._proxied_onscroll),t(this._toresize).unbind("resize.fixto",this._proxied_onresize)},_start:function(){this._onscroll(),t(i).bind("scroll.fixto mousewheel",this._proxied_onscroll),t(this._toresize).bind("resize.fixto",this._proxied_onresize)},_destroy:function(){this._replacer.destroy()},refresh:function(){this._saveViewportHeight(),this._unfix(),this._onscroll()}}),_.prototype=new c,t.extend(_.prototype,{_start:function(){var t=s.getAll(this.child);this._childOriginalPosition=t.position,this._childOriginalTop=t.top,this.child.style.position=d,this.refresh()},_stop:function(){this.child.style.position=this._childOriginalPosition,this.child.style.top=this._childOriginalTop},refresh:function(){this.child.style.top=this._mindtop()+this.options.top+"px"}});var g=function(t,i,o){return d&&!o||d&&o&&!1!==o.useNativeSticky?new _(t,i,o):a?(void 0===h&&(s=!1,n=e.createElement("div"),r=e.createElement("div"),n.appendChild(r),n.style[p]="translate(0)",n.style.marginTop="10px",n.style.visibility="hidden",r.style.position="fixed",r.style.top=0,e.body.appendChild(n),r.getBoundingClientRect().top>0&&(s=!0),e.body.removeChild(n),h=s),new u(t,i,o)):"Neither fixed nor sticky positioning supported";var s,n,r};return f<8&&(g=function(){return"not supported"}),t.fn.fixTo=function(i,e){var o=t(i),s=0;return this.each(function(){var n=t(this).data("fixto-instance");n?n[i].call(n,e):t(this).data("fixto-instance",g(this,o[s],e));s++})},{FixToContainer:u,fixTo:g,computedStyle:s,mimicNode:n}}(window.jQuery,window,document);