var ProductGrid=function(n){function t(t,i){this.options=i!==undefined?i:{tileSelector:""};this.$ele=n(t);this.$tiles=this.$ele.children(this.options.tileSelector);this.containers={};this.resize();n(window).on("resize",this.resize.bind(this));if(this.options.getProductInfo!==undefined&&this.options.$links!==undefined){var r=this;this.options.$links.on("click",function(){r.loadDescription(this,r.options.getProductInfo)})}}return t.prototype.loadDescription=function(t,i){i(t).then(function(i){this.appendProductInfo(n(t).closest(this.options.tileSelector),i)}.bind(this))},t.prototype.appendProductInfo=function(t,i){var e=this.$tiles.index(t),f=Math.floor(e/this.tilesPerRow),c=Math.min(this.$tiles.length,(f+1)*this.tilesPerRow)-1,u=(e-f*this.tilesPerRow+1)/this.tilesPerRow,s,r,o,h;return u+=-(.5/this.tilesPerRow),u=Math.trunc?Math.trunc(u*100):u<0?Math.ceil(u*100):Math.floor(u*100),s=this.containers.hasOwnProperty(f),s?(r=this.containers[f],r.$gridCell.removeClass("active"),r.$gridCell=t,r.index=e,o=r.$container.height(),r.$container.removeClass(),r.$container.addClass("product-description col-12 pos-"+u)):(r={index:e,$container:n('<div id="rowcontainer-'+f+'" class="product-description col-12 pos-'+u+'" data-productid=""><\/div>'),$gridCell:t},this.containers[f]=r,this.$tiles.eq(c).after(r.$container),o=0),r.$gridCell.addClass("active"),r.$container.html(i),h=r.$container.height(),n({height:o}).animate({height:h},{step:function(n){r.$container.css("height",n+"px")},complete:function(){r.$container.css("height","")}}),r.$container},t.prototype.resize=function(){var u,f,t;this.tilesPerRow=Math.floor(this.$ele.outerWidth()/this.$tiles.outerWidth());u=this.containers;this.containers={};for(f in u){t=u[f];t.$container.remove();var e=t.index,r=Math.floor(e/this.tilesPerRow),o=Math.min(this.$tiles.length,(r+1)*this.tilesPerRow)-1,i=(e-r*this.tilesPerRow+1)/this.tilesPerRow;if(i+=-(.5/this.tilesPerRow),i=Math.trunc?Math.trunc(i*100):i<0?Math.ceil(i*100):Math.floor(i*100),this.containers.hasOwnProperty(r)){t.$gridCell.removeClass("active");continue}this.$tiles.eq(o).after(t.$container);t.$container.removeClass();t.$container.addClass("product-description col-12 pos-"+i);this.containers[r]=t;n(".quickviewInfo .qvClose").click(function(t){t.preventDefault();n(this).parent().parent().data("productid","");n(this).parent().parent().hide("fast");n(this).parent().parent().html("")})}},t.makeJQueryPlugin=function(){n&&(n.fn.NewConfiguratorProductGrid=function(n){return this.NewConfiguratorProductGrid=new NewConfiguratorProductGrid(this,n),this.NewConfiguratorProductGrid})},t.makeJQueryPlugin(),t}(jQuery),ScrollContainer=function(n){function r(n,t,i){var r;return function(){var u=this,f=arguments,e=function(){r=null;i||n.apply(u,f)},o=i&&!r;clearTimeout(r);r=setTimeout(e,t);o&&n.apply(u,f)}}function u(n,t,i){var u,f,o,r=null,e=0,s;return i||(i={}),s=function(){e=i.leading===!1?0:Date.now();r=null;o=n.apply(u,f);r||(u=f=null)},function(){var c=Date.now(),h;return e||i.leading!==!1||(e=c),h=t-(c-e),u=this,f=arguments,h<=0||h>t?(r&&(clearTimeout(r),r=null),e=c,o=n.apply(u,f),r||(u=f=null)):r||i.trailing===!1||(r=setTimeout(s,h)),o}}function t(t,i){this.options=n.extend({pixelsPerSecond:400,asNavFor:"",leftButton:'<button class="scroll-container__arrow-left scroll-container__arrow"><span class="hide-text">Scroll Left<\/span><i class="fa fa-chevron-left"><\/i><\/button>',rightButton:'<button class="scroll-container__arrow-right scroll-container__arrow"><span class="hide-text">Scroll Right<\/span><i class="fa fa-chevron-right"><\/i><\/button>'},i);this.$ele=n(t);this.$Inner=n('<div class="scroll-container__inner" style="overflow:hidden;"><\/div>');this.$ButtonLeft=n(this.options.leftButton);this.$ButtonRight=n(this.options.rightButton);this.$AsNavForElements=n(this.options.asNavFor);this.$ele.wrapInner(this.$Inner);this.$ele.prepend(this.$ButtonLeft);this.$ele.append(this.$ButtonRight);this.$Inner=this.$ele.children(".scroll-container__inner");this.$Inner.on("scroll",u(function(){var t=this;t.$AsNavForElements.each(function(){var i=n(this).children(".scroll-container__inner"),r=t.$Inner.scrollLeft()/t.$Inner.get(0).clientWidth*i.get(0).clientWidth,u=this.ScrollContainer.ClockLeft.running||this.ScrollContainer.ClockRight.running;r==i.scrollLeft()||u||i.scrollLeft(r)})}.bind(this),250));this.ButtonHoldTimeout;this.ClockLeft=this.MakeScrollClock(-this.options.pixelsPerSecond);this.ClockRight=this.MakeScrollClock(this.options.pixelsPerSecond);this.BindButton(this.$ButtonLeft,"-="+this.options.pixelsPerSecond/4,250,this.ClockLeft);this.BindButton(this.$ButtonRight,"+="+this.options.pixelsPerSecond/4,250,this.ClockRight);var f=function(){this.$Inner.get(0).scrollWidth>this.$Inner.get(0).clientWidth?this.$ele.addClass("has-scrollbar"):this.$ele.removeClass("has-scrollbar")}.bind(this);n(window).resize(r(f,100));f()}var i=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(n){window.setTimeout(n,1e3/60)}}(),f=function(){function n(n,t){var r=this,u,f,e,o,s=0;r.running=!1;r.loop=function(h){r.running&&(i(r.loop),e=1e3/(r.fps||t||60),u=performance.now?performance.now():Date.now(),f=u-r.then,f>e&&(r.then=u-f%e,o=1e3/(h-s),s=h,n(o,f,u)))}}return n.prototype={start:function(){return this.running=!0,this.then=performance.now?performance.now():Date.now(),this.loop(),this},stop:function(){return this.running=!1,this}},n}();return t.prototype.BindButton=function(n,t,i,r){n.mousedown(function(){clearTimeout(this.ButtonHoldTimeout);this.ClockLeft.stop();this.ClockRight.stop();this.$Inner.animate({scrollLeft:t},i);this.ButtonHoldTimeout=setTimeout(function(){r.start()},i+100)}.bind(this)).mouseup(function(){clearTimeout(this.ButtonHoldTimeout);this.ClockLeft.stop();this.ClockRight.stop()}.bind(this))},t.prototype.MakeScrollClock=function(n){var t=function(t,i){this.$Inner.scrollLeft(this.$Inner.scrollLeft()+n*(i/1e3))}.bind(this);return new f(t,60)},t.makeJQueryPlugin=function(){n&&(n.fn.ScrollContainer=function(i){return n(this).each(function(){this.ScrollContainer=new t(this,i)}),n(this)})},t.makeJQueryPlugin(),t}(jQuery)