function LiveTrigger(n,t,i){var r=this;r.delay=n;r.callback=t;r.timer=null;r.trigger=function(){window.clearTimeout(r.timer);r.searchTimer=window.setTimeout(r.callback,n)};r.stop=function(){window.clearTimeout(r.timer)};i&&i.subscribe(r.trigger)}function hashparam(){var n=this;n.params=[];n.remove=function(t){n.set(t,null)};n.clear=function(){n.params=[]};n.get=function(t){for(var r=n.params,i=0;i<r.length;i++)if(r[i].id==t)return r[i]};n.set=function(t,i){for(var u=n.params,r=0;r<u.length;r++)if(u[r].id==t){i==null?u.splice(r,1):u[r].value=i;return}i!=null&&u.push({id:t,value:i})};n.update=function(){var t=document.URL.indexOf("#")>-1?document.URL.substr(0,document.URL.indexOf("#")):document.URL;window.location.href=t+"#"+n.toString()};n.toString=function(){for(var r="",i=n.params,t=0;t<i.length;t++)r+=i[t].id+"="+i[t].value+"&";return r.replace(/&*$/gm,"")};n.load=function(){var u,f,r,t,i;if(n.params=[],u=document.URL.indexOf("#"),u>-1)for(f=document.URL.substr(u+1),r=f.split("&"),t=0;t<r.length;t++)r[t]&&(i=r[t].split("="),i&&i.length==2&&n.set(i[0],i[1]))}}function FloorGuideViewModel(){var n=this;n.uniqueID="";n.selected=new SelectionViewModel;n.eventPrefix="Wood";n.floors=ko.observableArray();n.settings=new SettingsViewModel(n);n.search=new FloorGuideSearchViewModel(n);n.filters=new FilterCollectionViewModel;n.roomTypes=ko.observableArray();n.icons=ko.observableArray();n.colorGroups=ko.observableArray();n.scene=new SceneViewModel(n);n.system=new SystemViewModel(n);n.route=new RoutingModel(n);n.floorGroups=ko.observableArray();n.shownProductCount=ko.observable(24);n.productCountTemplate=ko.observable("");n.productShowFloorsTemplate=ko.observable("");n.sortingOptions=ko.observable([]);n.sortingOptionsExpanded=ko.observable(!1);n.productCount=ko.computed(function(){var e=n.selected.floorGroup(),r,u,t,f,i;if(e==null)return 0;for(r=0,u=e.items(),t=0;t<u.length;t++)for(f=u[t].floors(),i=0;i<f.length;i++)f[i].visible()&&r++;return r});n.productCountText=ko.computed(function(){return n.productCountTemplate()==null?null:n.productCountTemplate().replace("{0}",n.productCount())});n.showFloorsText=ko.computed(function(){return n.productShowFloorsTemplate()==null?null:n.productShowFloorsTemplate().replace("{0}",n.productCount())});n.shouldShowGroupBy=ko.observable(!1);n.shouldShowFilters=ko.observable(!1);n.clickTakesUserToProductPage=ko.observable(!1);n.toggleFilter=function(){n.shouldShowFilters(!n.shouldShowFilters());$("#filterCollapse").collapse("toggle");n.system.setTitleHeights&&n.system.setTitleHeights();n.shouldShowFilters()?$("#filterSummary").hide():$("#filterSummary").show()};n.visibleFloorGroups=ko.computed(function(){var t=[],o=0,c=n.selected.floorGroup(),s,u,f,r,h,i,e;if(!c)return t;for(s=c.items(),u=0;u<s.length;u++)if(f=s[u],f.visible()){for(r=f.floors(),h=!1,i=0;i<r.length;i++)r[i].visible()?(r[i].show(o<n.shownProductCount()),o<n.shownProductCount()&&(o++,h=!0)):r[i].show(!1);h&&t.push(f)}return(e=n.selected.sortingOption(),e==null)?t:e.Id=="PRICE_ASC"?t.toSorted(n.sortGroupPriceAsc):e.Id=="PRICE_DESC"?t.toSorted(n.sortGroupPriceDesc):t});n.sortGroupPriceAsc=function(n,t){return n.minPrice()-t.minPrice()};n.sortGroupPriceDesc=function(n,t){return t.maxPrice()-n.maxPrice()};n.findFloor=function(t){for(var r=n.floors(),i=0;i<r.length;i++)if(r[i].id==t)return r[i]};n.sharePintrest=function(n){var t=window.location.href,i=n.name,r="http://"+document.domain+n.getThumbnail(),u="http://www.pinterest.com/pin/create/button/?url="+t+"&media="+r+"&description="+i,f=window.open(u,"pintrest","width=500,height=275");f.focus()};n.updateShown=function(){var t=$(".iso.scroll"),r,i;if(t.length!=0){for(r=$(t[0]).offset().top,i=1;i<t.length;i++)r<$(t[i]).offset().top&&(r=$(t[i]).offset().top);$(window).scrollTop()+$(window).height()>r-200&&n.shownProductCount(n.shownProductCount()+24)}};n.loadData=function(t,i){var r;for(n.data=t,n.productCountTemplate(t.ProductCountText),n.productShowFloorsTemplate(t.ProductShowFloorsText),n.floors([]),n.roomTypes([]),n.colorGroups([]),n.floorGroups([]),n.eventPrefix=t.GAEventCategoryPrefix,r=0;r<t.Icons.length;r++)n.icons.push(t.Icons[r]);for(r=0;r<t.Floors.length;r++)n.floors.push(new FloorViewModel(t.Floors[r],n));for(r=0;r<t.RoomTypes.length;r++)n.roomTypes.push(new RoomTypeViewModel(t.RoomTypes[r],n));for(r=0;r<t.Colors.length;r++)n.colorGroups.push(new ColorGroupViewModel(t.Colors[r],n));for(r=0;r<t.FloorGroups.length;r++)n.floorGroups.push(new FloorGroupCollectionViewModel(t.FloorGroups[r],n));n.roomTypes().length>0&&n.roomTypes()[0].select();n.colorGroups().length>0&&n.colorGroups()[0].select();t.SortingOptions&&t.SortingOptions.length&&(n.selected.sortingOption(t.SortingOptions[0]),n.sortingOptions(t.SortingOptions));i||n.filters.loadData(t);n.shouldShowGroupBy(n.floorGroups().length>1);n.scene.loadData(t);n.clickTakesUserToProductPage(t.ClickTakesUserToProductPage);Cookies.set("isCommercial",t.IsCommercial);$(window).on("scroll",function(){n.updateShown()})};n.toggleFilter()}function FloorGuideSearchViewModel(n){var t=this;t.root=n;t.submit=function(){t.liveTrigger.stop();t.filterWithSearch(!0)};t.filterWithSearch=ko.observable(!1);t.query=ko.observable("");t.liveTrigger=new LiveTrigger(300,t.submit,t.query);t.clear=function(){t.query("");t.filterWithSearch(!1)};t.createFilter=function(){return t.query()==""?(t.filterWithSearch(!1),"*"):"[data-keywords*='"+t.query().toLowerCase()+"']"}}function FloorGroupCollectionViewModel(n,t){var i=this,r;for(i.id=n.ID,i.text=n.Text,i.root=t,i.selected=ko.computed(function(){return i.root.selected.floorGroup()!=null&&i.root.selected.floorGroup().id==i.id}),i.select=function(){i.root.selected.floorGroup(i)},i.items=ko.observableArray([]),r=0;r<n.Items.length;r++)i.items.push(new FloorGroupViewModel(n.Items[r],t))}function FloorGroupViewModel(n,t){var i=this;i.root=t;i.id=n.ID;i.header=ko.observable(n.Header);i.displayHeader=ko.computed(function(){return colorCode(i.header())});i.text=n.Text;i.selector=n.Selector;i.floors=ko.computed(function(){for(var u=[],r=t.floors(),n=0;n<r.length;n++)(i.selector=="*"||i.selector&&r[n].hasCssClass(i.selector.replace(".","")))&&u.push(r[n]);return u});i.minPrice=ko.computed(function(){for(var t=1e10,r=i.floors(),n=0;n<r.length;n++)r[n].price&&(t=Math.min(r[n].price,t));return t});i.maxPrice=ko.computed(function(){for(var t=-1e10,r=i.floors(),n=0;n<r.length;n++)r[n].price&&(t=Math.max(r[n].price,t));return t});i.sortedFloors=ko.computed(function(){var r=t.selected.sortingOption(),n=i.floors();if(n==null){console.log("sortedFloors: floors == null");return}return n.toSorted==null?(console.log("sortedFloors: type "+typeof n),console.log(n),n):r==null?n:(r.Id!="NONE"&&t.shownProductCount()!=1e4&&t.shownProductCount(1e4),r.Id=="PRICE_ASC")?n.toSorted(i.sortPriceAsc):r.Id=="PRICE_DESC"?n.toSorted(i.sortPriceDesc):n});i.sortPriceAsc=function(n,t){return n.price-t.price};i.sortPriceDesc=function(n,t){return t.price-n.price};i.visible=ko.computed(function(){for(var t=i.floors(),n=0;n<t.length;n++)if(t[n].visible())return!0;return!1})}function RoutingModel(n){var t=this;t.root=n;t.hash=new hashparam;t.updatesPaused=!1;t.update=function(){var u,r,i;if(!t.updatesPaused){for(t.hash.clear(),u=t.root.selected,r=u.filterOptions(),i=0;i<r.length;i++){var o=r[i].group.id(),f=r[i].id(),e=t.hash.get(o);e?t.hash.set(r[i].group.id(),e.value+","+f):t.hash.set(r[i].group.id(),f)}t.hash.set("g",n.selected.floorGroup().id);t.hash.update()}};t.init=function(){var r,i,n;if(document.URL.indexOf("clear=all")>-1&&(t.hash.load(),t.hash.remove("clear"),t.hash.update()),r=t.hash.get("select-floor"),t.loadData(),t.root.selected.filterOptions.subscribe(function(){t.update()}),t.root.selected.floorGroup.subscribe(function(n){t.update();dataLayer&&n&&dataLayer.push({event:"GAEvent",eventCategory:t.root.eventPrefix+" Filter",eventAction:"displaygroup",eventLabel:n.id,eventValue:null})}),i=t.root.floors(),r)for(n=0;n<i.length;n++)i[n].articleId==r.value&&i[n].select();window.addEventListener("hashchange",t.hashChanged)};t.hashChanged=function(){document.URL.indexOf("clear=all")>-1&&(t.hash.load(),t.updatesPaused=!0,t.root.selected.clearFilters(),t.loadData(),t.hash.remove("clear"),t.updatesPaused=!1,t.hash.update())};t.loadData=function(){var r=[],u,e,o,s,h,c,l,f,a,i;for(r=r.concat(t.root.filters.otherFilters()),r.push(t.root.filters.color),r.push(t.root.filters.wearresistance),r.push(t.root.filters.grading),r.push(t.root.filters.collection),u=0;u<r.length;u++)if(e=r[u],o=t.hash.get(e.id()),o)for(s=o.value.toLowerCase().split(","),h=e.options(),i=0;i<h.length;i++){for(c=h[i],l=!1,f=0;f<s.length;f++)if(c.id().toLowerCase()==s[f]){l=!0;break}c.selected(l)}if(a=t.hash.get("g"),a)for(i=0;i<n.floorGroups().length;i++)n.floorGroups()[i].id==a.value&&n.floorGroups()[i].select();else n.floorGroups().length>0&&n.selected.floorGroup()==null&&n.floorGroups()[0].select()};t.hash.load()}function SceneViewModel(n){var t=this;t.root=n;t.url=ko.observable("");t.fullscreen=ko.observable(!1);t.loadingUrl=ko.observable("");t.compareUrl=ko.observable(null);t.defaultColor=ko.observable(null);t.defaultRoomId=ko.observable(0);t.defaultRoom=ko.observable(null);t.defaultFloor=ko.observable(null);t.hideBoxes=ko.observable(!1);t.iframeLoaded=ko.observable(!1);t.iframeFloorReady=ko.observable(!1);t.iframeVisible=ko.computed(function(){return t.root.selected.floor()!=null&&t.iframeLoaded()&&t.iframeFloorReady()});t.showIframe=function(){$("#iframe").length&&!$("#iframe").attr("src")&&$("#iframe").attr("src",$previewUrl)};t.selectedSceneUrl=function(){var i=n.selected;return t.makeSceneUrl(i.room(),i.color(),i.direction(),i.floor())};t.toggleFullscreen=function(){t.fullscreen(!t.fullscreen())};t.makeSceneUrl=function(n,i,r,u,f){var s=0,e,o;return n==null&&(s=t.defaultRoomId()),f==null&&(f="original"),i==null&&(i=t.defaultColor()),u==null&&(u=t.defaultFloor()),r==null&&(r=0),e=null,u!=null&&(u.fullArticleId&&(e=u.fullArticleId),e==null&&u.articleId&&(e=u.articleId),e==null&&u.productAONumber&&(e=u.productAONumber)),o="/images/rooms/"+f+"/"+(u==null?"151XADEKWJ":e)+"__"+(n==null?s:n.id())+".jpg",r>0&&(o+="?rotation="+r),typeof Storage!="undefined"&&localStorage.setItem("FGImageUrl",o),o};t.selectedDataChanged=function(n){t.loadingUrl(t.selectedSceneUrl());n&&$(".compare-1 .image-thumbnail").animate({left:"-250px",opacity:0},400)};t.compareChanged=function(){var u=t.root.selected.compare.floor(),i,r;u==null?t.compareUrl(null):(i=n.selected,t.compareUrl(t.makeSceneUrl(i.room(),i.color(),i.direction(),u)));r=$("#iframe");r.length==0&&(r=$(".compare-container"))};t.loadData=function(n){var i=t.root.route;n.preventSceneSubscriptions||t.createSubscriptions();$.each(t.root.floors(),function(i,r){r.id==n.DefaultFloorID&&t.defaultFloor(r)});$.each(t.root.roomTypes(),function(i,r){$.each(r.rooms(),function(i,r){r.id()==n.DefaultRoomID&&(t.defaultRoom(r),r.select())})});t.defaultRoomId(n.DefaultRoomID);$.each(t.root.colorGroups(),function(i,r){$.each(r.colors(),function(i,r){r.id==n.DefaultColorID&&(t.defaultColor(r),r.select())})});t.url(t.selectedSceneUrl());$(".floor-guide-content img.swap").length>0&&($(".floor-guide-content img.swap")[0].onload=t.swapImageLoaded)};t.swapImageLoaded=function(){var n=$(".floor-guide-content img.swap");n.animate({opacity:1},700,function(){t.url(t.loadingUrl());n.css("opacity",0);t.root.selected.floor()&&$(".compare-1 .image-thumbnail").animate({left:"50px",opacity:1},800);t.loadingUrl(null)})};t.createSubscriptions=function(){t.root.selected.compare.floor.subscribe(t.compareChanged);t.root.selected.floor.subscribe(t.selectedDataChanged);t.root.selected.direction.subscribe(t.selectedDataChanged);t.root.selected.room.subscribe(t.selectedDataChanged);t.root.selected.color.subscribe(t.selectedDataChanged)}}function ColorGroupViewModel(n,t){var i=this,r;for(i.root=t,i.id=n.ID,i.name=ko.observable(n.Name),i.colors=ko.observableArray(),i.select=function(){t.selected.colorGroup(i)},i.selected=ko.computed(function(){return t.selected.colorGroup()==i}),r=0;r<n.Colors.length;r++)i.colors.push(new ColorViewModel(n.Colors[r],t))}function ColorViewModel(n,t){var i=this;i.root=t;i.id=n.ID;i.colorCode=n.ColorCode;i.name=ko.observable(n.Name);i.select=function(){t.selected.color(i)};i.selected=ko.computed(function(){return t.selected.color()==i})}function RoomTypeViewModel(n,t){var i=this,r;for(i.root=t,i.id=n.ID,i.name=ko.observable(n.Name),i.rooms=ko.observableArray(),i.select=function(){t.selected.roomType(i)},i.selected=ko.computed(function(){return t.selected.roomType()==i}),r=0;r<n.Rooms.length;r++)i.rooms.push(new RoomViewModel(n.Rooms[r],t))}function RoomViewModel(n,t){var i=this;i.root=t;i.name=n.Name;i.id=ko.observable(n.ID);i.image=function(){return t.scene.makeSceneUrl(i,null,0,null,"medium2x1")};i.select=function(){t.selected.room(i)}}function SettingsViewModel(){var n=this;n.defaultFloorCssClasses="iso pointer col-md-4 col-6"}function SystemViewModel(n){var t=this;t.root=n;t.resize=function(){var i=$(window).height(),u=$(".compare-container img.preview.main").height(),r;i=i*(n.scene.fullscreen()?.9:.65);u!=0&&u<i&&(i=u);$(".compare-container").height(i);r=$(".compare-container").width();$(".compare-container .compare-2").width(r/2);$(".compare-container .compare-2").css("left",r/2);$(".compare-container .compare-2 img.preview").css("margin-left",-r/2);$(".compare-container .compare-2 img.preview").width(r);t.swatchHeight()};t.bindMenu=function(){$(".floorguide-menu-link").click(function(n){var t=$(n.currentTarget).data("target");$(t).is(":hidden")&&($(".floorguide-bottom-menu").hide(),$(t).show());n.preventDefault();n.stopPropagation()});$(".jsShowMobileFilter").click(function(){$(".mobile-filter-close").addClass("open");$(".filter-wrapper").addClass("open")});$(".jsHideMobileFilter").click(function(n){$(".mobile-filter-close").removeClass("open");$(".filter-wrapper").removeClass("open");n.preventDefault()})};t.renderCompleted=function(){t.checkReadyToStart()};t.checkReadyToStart=function(){window.setTimeout(function(){t.swatchHeight();t.bindMenu();t.root.route.init();$('[data-toggle="popover"]').popover();t.root.scene.showIframe()},70);window.setTimeout(function(){t.setTitleHeights()},300)};t.swatchHeight=function(){return};t.setTitleHeights=function(){$("#floorguide .title").css("height","auto");var n=21;$("#floorguide .title").each(function(){n=Math.max($(this).height(),n)});$("#floorguide .title").height(n)};$(window).resize(t.resize);$(document).ready(function(){t.resize()});$(document).click(function(n){$('[data-toggle="popover"],[data-original-title]').each(function(){$(this).is(n.target)||$(this).has(n.target).length!==0||$(".popover").has(n.target).length!==0||((($(this).popover("hide").data("bs.popover")||{}).inState||{}).click=!1)});$(".floorguide-bottom-menu").hide()});n.selected.filterOptions.subscribe(function(n){for(var i=0;i<n.length;i++){var f=n[i],r=n[i].id(),u=n[i].group.id();dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:t.root.eventPrefix+" Filter",eventAction:u,eventLabel:r,eventValue:null})}});n.selected.floor.subscribe(function(n){if(n){if($(window).width()<768||t.root.clickTakesUserToProductPage()){window.location.href=n.url;return}var i=$("#iframe");i.length==0&&(i=$(".compare-container"))}});n.scene.fullscreen.subscribe(t.resize)}function hideFilters(){var n;return}function FloorViewModel(n,t){var i=this;i.id=n.ID;i.name=n.Name;i.isNew=n.IsNew;i.keywords=n.Keywords;i.articleId=n.ArticleID;i.roomId=n.DefaultRoomID;i.recommendedPrice=n.RecommendedPrice;i.price=n.Price;i.overrideRoomId=null;i.fullArticleId=n.FullArticleID;i.productAONumber=n.ProductAONumber;i.collection=n.Collection;i.cssClasses=n.CssClasses;i.url=n.Url+($kioskmode?"?kioskmode=true":"");i.root=t;i.image=n.Image;i.show=ko.observable(!1);i.getIcons=ko.computed(function(){for(var u=[],f=i.cssClasses,t=i.root.icons(),n,r=0;r<f.length;r++)for(n=0;n<t.length;n++)f[r]==t[n].Selector&&(u.includes(t[n])||u.push(t[n]));return u});i.getThumbnail=function(){return"/images/swatches/medium7x5/"+i.image};i.getCssClasses=function(){return i.root.settings.defaultFloorCssClasses+" "+i.cssClasses.join(" ")};i.hasCssClass=function(n){for(var t=0;t<i.cssClasses.length;t++)if(i.cssClasses[t]==n)return!0;return!1};i.select=function(){dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:"Product grid click",eventAction:EventLanguage()+"-Product grid click",eventLabel:i.name,eventValue:null});i.root.clickTakesUserToProductPage()?window.location.href=i.url:i.root.selected.compare.floor()!=null?i.root.selected.compare.floor(i):i.root.selected.floor(i)};i.visible=ko.computed(function(){var u=i.root.selected.filterGroups(),o=i.root.search.query(),e=i.root.search.filterWithSearch(),r,n,f,t;if(u.length==0&&!e)return!0;for(r=0;r<u.length;r++)if(n=u[r].options(),f=!1,n.length!=0){for(t=0;t<n.length;t++)if(n[t].selected()&&i.cssClasses.indexOf(n[t].uniqueID())>-1){f=!0;break}if(!f)return!1}return!0});i.isFavourite=function(){return $.mainViewModel.favourites().hasItem(i.id)};i.isCart=function(){return $.mainViewModel.cart().hasItem(i.fullArticleId)};i.addCart=function(){$.mainViewModel.cart().add(i.fullArticleId,i.name,{thumb:i.getThumbnail(),url:i.url})};i.toggleCart=function(){$.mainViewModel.cart().hasItem(i.fullArticleId)?$.mainViewModel.cart().remove(i.fullArticleId):i.addCart()};i.toggleFavourite=function(){$.mainViewModel.favourites().hasItem(i.fullArticleId)?$.mainViewModel.favourites().remove(i.fullArticleId):(dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:"Mark as favorite",eventAction:EventLanguage()+"-Mark as favorite",eventLabel:null,eventValue:null}),$.mainViewModel.favourites().add(i.fullArticleId,i.name,{thumb:i.getThumbnail(),url:i.url}),typeof AnimateAddFavorite=="function"&&AnimateAddFavorite())}}function FilterCollectionViewModel(n){var t=this;t.color=new FilterGroupViewModel;t.wearresistance=new FilterGroupViewModel;t.grading=new FilterGroupViewModel;t.otherFilters=ko.observableArray();t.collection=new FilterGroupViewModel;t.loadData=function(n){var r,i;for(t.color.loadData(n.ColorFilter),t.wearresistance.loadData(n.WearResistanceFilter),t.grading.loadData(n.GradingFilter),t.collection.loadData(n.CollectionFilter),r=[],i=0;i<n.OtherFilters.length;i++)r.push(new FilterGroupViewModel(n.OtherFilters[i]));t.otherFilters(r)};n&&t.loadData(n)}function FilterGroupViewModel(n){var t=this;t.id=ko.observable("");t.name=ko.observable("");t.options=ko.observableArray();t.filterDescription=ko.observable(null);t.expanded=ko.observable(!1);t.toggle=function(){t.expanded(!t.expanded())};t.selectedCount=ko.computed(function(){return ko.utils.arrayFilter(t.options(),function(n){return n.selected()==!0}).length});t.loadData=function(n){var r,i;if(n){for(n.FilterDescription!=null?t.name(n.FilterDescription.Title):t.name(n.Name),t.id(n.ID),t.filterDescription(n.FilterDescription),r=[],i=0;i<n.Options.length;i++)r.push(new FilterOptionViewModel(n.Options[i],this));t.options(r)}};n&&t.loadData(n)}function FilterOptionViewModel(n,t){var i=this;i.id=ko.observable("");i.name=ko.observable("");i.url=ko.observable("");i.tooltip=ko.observable("");i.selected=ko.observable(!1);i.group=t;i.uniqueID=function(){return i.group.id()+"-"+i.id()};i.visible=ko.observable(!0);i.select=function(){i.selected(!0)};i.deselect=function(){i.selected(!1)};i.toggle=function(){i.selected(!i.selected())};i.loadData=function(t){i.id(t.ID);i.name(t.Name);i.url(n.Url);i.tooltip(t.Tooltip)};n&&i.loadData(n);i.selected.subscribe(function(n){$.floorGuideViewModel.search.clear();n?$.floorGuideViewModel.selected.filterOptions.push(i):$.floorGuideViewModel.selected.filterOptions.remove(i);hideFilters()})}function CompareViewModel(){var n=this;n.floor=ko.observable(null);n.isDragging=!1;n.mouseDown=function(){n.isDragging=!0};n.floorChanged=function(n){n&&(fullWidth=$(".compare-container").width(),$(".compare-container .compare.item img").width(fullWidth))};n.bindCompare=function(){$(".compare-container").length>0&&(!0&&$(".compare").removeAttr("style"),!1||($(".compare-container").mousemove(function(t){if(n.isDragging){var r=$(".compare-container").width(),i=Math.min(Math.max(t.pageX,380),$(window).width()-380),u=r-i;$(".compare-2").css("left",i);$(".compare-2").width(u);$(".compare-2 img").css("margin-left",-i);$(".compare-2 img").width($(".compare-container").width())}}),$(document).mouseup(function(){n.isDragging&&(n.isDragging=!1)})))};$(document).ready(n.bindCompare());n.floor.subscribe(n.floorChanged)}function SelectionViewModel(){var n=this;n.compare=new CompareViewModel;n.direction=ko.observable(0);n.floor=ko.observable(null);n.direction=ko.observable(0);n.room=ko.observable();n.roomType=ko.observable();n.colorGroup=ko.observable();n.floorGroup=ko.observable(null);n.color=ko.observable();n.filterOptions=ko.observableArray();n.sortingOption=ko.observable(null);n.sortingOptionSelected=ko.computed(function(){return n.sortingOption()!=null&&n.sortingOption().Id!="NONE"});n.sortingOptionText=ko.computed(function(){return n.sortingOption()!=null?n.sortingOption().Text:""});n.clearFilters=function(){for(var t=n.filterOptions();t.length>0;)t[0].selected(!1)};n.toggleCompare=function(){n.compare.floor()==null?n.compare.floor(n.floor()):n.compare.floor(null)};n.startCompare=function(){n.compare.floor(n.floor())};n.stopCompare=function(){n.compare.floor(null)};n.filterGroups=function(){var t=[];return $.each(n.filterOptions(),function(n,i){$.inArray(i.group,t)==-1&&t.push(i.group)}),t}}function getComboFilter(n){var c=0,r=[],v=[],t={},e,i,o,s,u,l,f,a,h;$.each(n,function(n,i){t[i.id()]=[];$.each(i.options(),function(n,r){r.selected()&&t[i.id()].push("."+r.uniqueID())})});for(e in t)if(v.push(t[e].join(" ")),i=t[e],i.length){if(c===0)r=i.slice(0);else{for(o=[],s=r.slice(0),u=0,l=i.length;u<l;u++)for(f=0,a=s.length;f<a;f++)o.push(s[f]+i[u]);r=o}c++}return h=r.join(", "),h?h:"*"}function ToggleActive(n){var t=n.parent().parent().parent(),i=t.hasClass("active");i?(t.removeClass("active"),n.find(".fa").addClass("fa-plus").removeClass("fa-minus")):(t.addClass("active"),n.find(".fa").removeClass("fa-plus").addClass("fa-minus"))}function ToggleActiveGroup(n){n.closest(".container").find("a").removeClass("active");n.addClass("active")}function EventLanguage(){var n=$("html").attr("lang").toUpperCase();return n.indexOf("-")&&(n=n.substr(n.indexOf("-")+1)),n}function colorCode(n){var i;if(!n)return n;while(n.indexOf("###")>-1){var r=n,t=n.indexOf("###"),u=n.substring(t+3,t+9);if(n=n.substring(0,t)+'<span style="color:#'+u+';">'+n.substring(t+9),i=n.indexOf("###"),i<0)return r;n=n.substring(0,i)+"<\/span>"+n.substring(i+3)}return n}function InitFloorGuide(n,t){$data.DefaultRoomId=n?n:$data.DefaultRoomId;$data.DefaultFloorId=t?t:$data.DefaultFloorId;$.floorGuideViewModel.loadData($data);var i=$.floorGuideViewModel.findFloor(t);i&&(i.overrideRoomId=n,$(window).width()>=770&&!$.floorGuideViewModel.route.hash.get("select-floor")&&i.select());ko.applyBindings($.floorGuideViewModel,$("#floorguide")[0]);$($(".grouping-container a[data-key="+$data.DefaultFloorGroup+"]")).addClass("active")}function IframeLoaded(){document.URL.indexOf("clear=all")>-1&&(Cookies.remove($.floorGuideViewModel.uniqueID+"roomId"),Cookies.remove($.floorGuideViewModel.uniqueID+"floorId"));var n=Cookies.get($.floorGuideViewModel.uniqueID+"roomId"),t=Cookies.get($.floorGuideViewModel.uniqueID+"floorId");$.floorGuideViewModel.scene.iframeLoaded(!0);$.floorGuideViewModel.selected.floor()&&FloorSelected($.floorGuideViewModel.selected.floor())}function SendTexture(n){var t={},i;t.action="MapTexture";t.parameter={};t.parameter.artnr=n;i=JSON.stringify(t);SendJson(i)}function SendRoom(n){var t={},i;t.action="ChangeRoom";t.parameter={};t.parameter.room_id=n;i=JSON.stringify(t);SendJson(i)}function SendJson(n){var t=window.location.protocol+"//kahrs_dev.materialo.com",i=document.getElementById("iframe").contentWindow,r=n;i.postMessage(r,t)}function ReceiveJson(n){var s=window.location.protocol+"//kahrs_dev.materialo.com",f=$.floorGuideViewModel.eventPrefix,t,e,o;if(n.origin===s){t=JSON.parse(n.data);console.log(t.action);switch(t.action){case"compareStatus":console.log("compareStatus:"+t.parameter.compare_is_active);t.parameter.compare_is_active=="1"?($.floorGuideViewModel.selected.startCompare(),dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:f+" Room-selector",eventAction:"Compare",eventLabel:null,eventValue:null})):($.floorGuideViewModel.selected.stopCompare(),e=$.floorGuideViewModel.selected.floor(),o=e.productAONumber?e.productAONumber:e.articleId,SendTexture(o));break;case"scrollDown":$("html, body").animate({scrollTop:$(".filter-groups-container").offset().top},1e3);break;case"editorStatus":t.status==1&&t.imageLoaded==1&&dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:f+" Room-selector",eventAction:"Upload image",eventLabel:null,eventValue:null});console.log("editorStatus:"+t.parameter.status);break;case"appStarted":IframeLoaded();break;case"renderStatus":var i=t.parameter.roomId,r=t.parameter.floorTexId,u=t.parameter.wallTexId;lastRoomSelected!=i&&i>0&&(dataLayer&&dataLayer.push({event:"order_sample1"}),dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:f+" Room-selector - Room",eventAction:i,eventLabel:i,eventValue:i}));lastWallTexture!=u&&u>0&&dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:f+" Room-selector - Colour",eventAction:u,eventLabel:u,eventValue:u});lastFloorTexId!=r&&r>0&&dataLayer&&dataLayer.push({event:"GAEvent",eventCategory:f+" Room-selector",eventAction:"Floor",eventLabel:r,eventValue:r});lastFloorTexId=r;lastWallTexture=u;console.info("(renderstatus) texture:"+r+", room: "+i+", lastRoomSelected: "+lastRoomSelected);Cookies.set($.floorGuideViewModel.uniqueID+"wallTexId",u);Cookies.set($.floorGuideViewModel.uniqueID+"floorTexId",r);lastRoomSelected!=i&&i>0&&$.floorGuideViewModel.scene.iframeFloorReady()&&(console.info("Setting room renderStatus: "+i),Cookies.set($.floorGuideViewModel.uniqueID+"roomId",i),Cookies.set("roomId",i))}}}function SendRoomTexture(n,t){SendJson(JSON.stringify({action:"ChangeRoomAndTexture",parameter:{room_id:n,artnr:t}}))}function RoomSelected(){}function CompareFloorSelected(n){if(n!=null){var t=n.productAONumber?n.productAONumber:n.articleId;SendTexture(t)}}function FloorSelected(n){var u,f,i,t,r;if(n!=null){if(u=$.floorGuideViewModel,u.scene.showIframe(),f=window.innerWidth>0?window.innerWidth:screen.width,f<770){window.location.href=n.url;return}i=n.productAONumber?n.productAONumber:n.articleId;t=n.roomId>0?n.roomId:$.floorGuideViewModel.scene.defaultRoomId();lastRoomSelected=t;r=Cookies.get($.floorGuideViewModel.uniqueID+"roomId");console.info("(click) texture:"+i+", room: "+t+", cookieroom: "+r+", lastRoomSelected: "+lastRoomSelected);r&&(t=r);Cookies.set($.floorGuideViewModel.uniqueID+"floorId",n.id);u.selected.compare.floor()||t==0?SendTexture(i):SendRoomTexture(t,i);$.floorGuideViewModel.scene.iframeFloorReady(!0)}}var $=jQuery.noConflict();$.floorGuideViewModel=new FloorGuideViewModel;$(".dropup").on("click",".dropdown-submenu a.toggle-trigger",function(n){$(this).next("ul").toggle();n.stopPropagation();n.preventDefault()});var lastRoomSelected=-1,lastWallTexture=-1,lastFloorTexId=-1;window.addEventListener?window.addEventListener("message",ReceiveJson,!1):window.attachEvent("onmessage",ReceiveJson);$.floorGuideViewModel.selected.floor.subscribe(FloorSelected);$.floorGuideViewModel.selected.compare.floor.subscribe(CompareFloorSelected);$.floorGuideViewModel.selected.room.subscribe(RoomSelected)