"),a=a.replace("[[[SKU1]]]",n.sku),a=a.replace("[[[SKU2]]]",n.sku),null!=e){var s=e[n.sku];void 0==s&&alert("setupAllProducts(): SKU not found in thumbnails pack: "+n.sku),s=s.replace("url('","url('mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/"),s=s.replace(".jpg",".jpg?"+mobileVisualizerStopCaching),a=a.replace('style=""','style="'+s+'"'),a=a.replace("HIDE-IMAGE","m-hide")}else a=a.replace('src=""','src="'+n.thumbnail+'"'),a=a.replace("HIDE-BACKGROUND-IMAGE","m-hide");t+=a,++i}}$(".m-product-thumbnails-inject").html(t)}if(mobileVisualizerConfig.enableSimpleUYORooms)return void e();if(!mobileVisualizerConfig.thumbnailsFromPack)return t(null),void e();var o="mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/thumbnailpacks-100.json?"+mobileVisualizerStopCaching;"Desktop"==S&&(o="mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/thumbnailpacks-200.json?"+mobileVisualizerStopCaching),VUtils.loadTextFromURL(o,function(o){k=JSON.parse(o),t(k),e()})}function p(){for(var e="",t=$(".m-product-filter-template").html(),o=$(".m-product-filter-item-template").html(),i=null,r=0;r',"[DELETE]",'',"[WHITE+]",'',"[WHITE-]",'',"[RED+]",'',"[RED-]",'',"[GREEN+]",'',"[GREEN-]",''],r=o;"Desktop"==S&&(r=t),r=r.concat(i);for(var n=0;n0&&0==mobileVisualizer.getNumDecoratedTexturedWalls()||mobileVisualizer.getNumFloors()>0&&0==mobileVisualizer.getNumTexturedWalls()?($(".m-tool-button.mm-rotate-floor .mm-rotate-floor").show(),$(".m-tool-button.mm-rotate-floor .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-area").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-floor").show(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-area").hide()):mobileVisualizer.getNumDecoratedTexturedWalls()>0&&0==mobileVisualizer.getNumDecoratedFloors()||mobileVisualizer.getNumTexturedWalls()>0&&0==mobileVisualizer.getNumFloors()?($(".m-tool-button.mm-rotate-floor .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-wall").show(),$(".m-tool-button.mm-rotate-floor .mm-rotate-area").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-wall").show(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-area").hide()):($(".m-tool-button.mm-rotate-floor .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor .mm-rotate-area").show(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-floor").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-wall").hide(),$(".m-tool-button.mm-rotate-floor-wide .mm-rotate-area").show()),"CarpetRight"!=mobileVisualizerConfigType){var r=$(".m-tools-container .m-tool-button.mm-patch-floor-area .m-tool-button-text");0==mobileVisualizer.getNumFloors()&&mobileVisualizer.getNumWalls()>0?($(".m-tools-container .m-tool-button.mm-patch-floor-area .m-tool-button-text").html("Add Wall Area"),$(".m-tools-container .m-tool-button.mm-mask-floor-area .m-tool-button-text").html("Remove Wall Area")):1==mobileVisualizer.getNumFloors()&&mobileVisualizer.getNumWalls()>0?($(".m-tools-container .m-tool-button.mm-patch-floor-area .m-tool-button-text").html("Add Area"),$(".m-tools-container .m-tool-button.mm-mask-floor-area .m-tool-button-text").html("Remove Area")):($(".m-tools-container .m-tool-button.mm-patch-floor-area .m-tool-button-text").html("Add Floor Area"),$(".m-tools-container .m-tool-button.mm-mask-floor-area .m-tool-button-text").html("Remove Floor Area"))}mobileVisualizerConfig.enableAutoFindWalls||mobileVisualizer.isStairsRoom()||"UYO"!=mobileVisualizer.getCurRoomId()||!mobileVisualizerConfig.enableToolsFloorPatchAndMask?($(".m-tool-button.mm-patch-floor-area").hide(),$(".m-tool-button.mm-mask-floor-area").hide()):($(".m-tool-button.mm-patch-floor-area").show(),$(".m-tool-button.mm-mask-floor-area").show()),"UYO"==mobileVisualizer.getCurRoomId()&&mobileVisualizerConfig.enableToolsEditingTools?$(".m-tool-button.mm-editing-tools").show():$(".m-tool-button.mm-editing-tools").hide(),$(".m-tool-button.mm-editing-tools-after-rotate").hide(),mobileVisualizer.isStairsRoom()&&$(".m-tool-button.mm-editing-tools").hide(),$(".m-tool-button.mm-edit-stairs").hide(),mobileVisualizer.isStairsRoom()&&($(".m-tool-button.mm-edit-stairs").removeClass("mm-disabled"),mobileVisualizer.isDecoratedFloor()||$(".m-tool-button.mm-edit-stairs").addClass("mm-disabled"),$(".m-tool-button.mm-edit-stairs").show()),"UYO"==mobileVisualizer.getCurRoomId()&&mobileVisualizer.getCurUYORoomIsStock()&&$(".m-tool-button.mm-edit-stairs").hide(),"Mannington"==mobileVisualizerConfigType&&mobileVisualizerConfig.enableStairs&&"Room99"==mobileVisualizer.getCurRoomId()&&$(".m-tool-button.mm-edit-stairs").hide(),$(".m-tool-button.mm-select-pattern").hide();for(var n=0;nRiser Color"),$(".m-select-grout-button").show()),"Mannington"==mobileVisualizerConfigType&&mobileVisualizerConfig.enableStairs&&"Room99"==mobileVisualizer.getCurRoomId()&&$(".m-select-grout-button").hide(),v(),z&&C.closeMenu(),void 0!=e&&e?($(".m-product-selector-container").scrollTop(0),$(".m-product-selector-container").css({top:"0px"}),$(".m-product-selector-close-container").show(),void(_=!0)):($(".m-product-selector-container").scrollTop(0),$(".m-product-selector-container").animate({top:"0px"},200,function(){$(".m-product-selector-close-container").show()}),_=!0,mobileVisualizerConfig.useTargets&&(h(),m(),d()),void(mobileVisualizerConfig.fudgeRiserColourUsingGrout&&mobileVisualizerConfig.fudgeRiserTextureUsingGrout&&b()))},this.closeProductSelector=function(e){if("FactoryDirectFlooring"==mobileVisualizerConfigType&&($(".fdf-menu-container").removeClass("mm-disabled"),$(".fdf-tools-container").removeClass("mm-disabled")),mobileVisualizerConfig.sidebarSelector){C.closeProductTypesSelector(),C.closeProductFilterSelector(),C.closeFilters();var t="-375px";return"Phone"==S&&(t="-90%"),$(".m-product-selector-close-container").hide(),$(".m-product-selector-container").animate({left:t},200,function(){void 0!=e&&e()}),$(".m-open-products-button.mm-sidebar-selector").animate({left:"0px"},200,function(){mobileVisualizerConfig.useTargets&&$(".m-open-products-button").hide()}),void(_=!1)}C.closeProductTypesSelector(),C.closeProductFilterSelector(),C.closeFilters(),$(".m-product-selector-close-container").hide(),$(".m-product-selector-container").animate({top:"-100%"},200,function(){void 0!=e&&e()}),_=!1},this.switchToGroutSelector=function(){if($(".m-product-selector-close-container").hide(),mobileVisualizerConfig.sidebarSelector){var e="-375px";"Phone"==S&&(e="-90%"),$(".m-product-selector-container").css({left:e})}else $(".m-product-selector-container").css({top:"-100%"});$(".m-grout-selector-container").scrollTop(0),mobileVisualizerConfig.sidebarSelector?$(".m-grout-selector-container").css({left:"0px"}):$(".m-grout-selector-container").css({top:"0px"}),$(".m-grout-selector-close-container").show(),O=!0,_=!1},this.closeGroutSelector=function(e){if($(".m-grout-selector-close-container").hide(),mobileVisualizerConfig.sidebarSelector){var t="-375px";"Phone"==S&&(t="-90%"),$(".m-grout-selector-container").animate({left:t},200,function(){mobileVisualizerConfig.useTargets&&$(".m-open-products-button").hide(),void 0!=e&&e()}),$(".m-open-products-button.mm-sidebar-selector").animate({left:"0px"},200,function(){})}else $(".m-grout-selector-container").animate({top:"-100%"},200,function(){void 0!=e&&e()});O=!1},this.instantCloseGroutSelector=function(){if($(".m-grout-selector-close-container").hide(),mobileVisualizerConfig.sidebarSelector){var e="-375px";"Phone"==S&&(e="-90%"),$(".m-grout-selector-container").css({left:e}),mobileVisualizerConfig.useTargets&&$(".m-open-products-button").hide(),$(".m-open-products-button.mm-sidebar-selector").css({left:"0px"})}else $(".m-grout-selector-container").css({top:"-100%"});O=!1},this.switchToPaintSelector=function(){if($(".m-product-selector-close-container").hide(),mobileVisualizerConfig.sidebarSelector){var e="-375px";"Phone"==S&&(e="-90%"),$(".m-product-selector-container").css({left:e})}else $(".m-product-selector-container").css({top:"-100%"});$(".m-paint-selector-container").scrollTop(0),mobileVisualizerConfig.sidebarSelector?$(".m-paint-selector-container").css({left:"0px"}):$(".m-paint-selector-container").css({top:"0px"}),$(".m-paint-selector-close-container").show(),F=!0,_=!1},this.openPaintSelector=function(){if("FactoryDirectFlooring"==mobileVisualizerConfigType&&($(".fdf-menu-container").addClass("mm-disabled"),$(".fdf-tools-container").addClass("mm-disabled")),v(),z&&C.closeMenu(),_){if($(".m-paint-selector-container").scrollTop(0),$(".m-paint-selector-container").css({left:"0px"}),F=!0,mobileVisualizerConfig.sidebarSelector){var e="-375px";"Phone"==S&&(e="-90%"),$(".m-product-selector-container").css({left:e})}else $(".m-product-selector-container").css({top:"-100%"});return void(_=!1)}if(O){if($(".m-paint-selector-container").scrollTop(0),$(".m-paint-selector-container").css({left:"0px"}),F=!0,mobileVisualizerConfig.sidebarSelector){var e="-375px";"Phone"==S&&(e="-90%"),$(".m-grout-selector-container").css({left:e})}else $(".m-grout-selector-container").css({top:"-100%"});return void(O=!1)}if(mobileVisualizerConfig.sidebarSelector){mobileVisualizerConfig.useTargets&&$(".m-open-products-button").show(),$(".m-paint-selector-container").scrollTop(0),$(".m-paint-selector-container").animate({left:"0px"},200,function(){});var e="375px";"Phone"==S&&(e="90%"),$(".m-open-products-button.mm-sidebar-selector").animate({left:e},200,function(){})}else $(".m-paint-selector-container").scrollTop(0),$(".m-paint-selector-container").animate({top:"0px"},200,function(){$(".m-paint-selector-close-container").show()});F=!0},this.closePaintSelector=function(e){if("FactoryDirectFlooring"==mobileVisualizerConfigType&&($(".fdf-menu-container").removeClass("mm-disabled"),$(".fdf-tools-container").removeClass("mm-disabled")),$(".m-paint-selector-close-container").hide(),mobileVisualizerConfig.sidebarSelector){var t="-375px";"Phone"==S&&(t="-90%"),$(".m-paint-selector-container").animate({left:t},200,function(){mobileVisualizerConfig.useTargets&&$(".m-open-products-button").hide(),void 0!=e&&e()}),$(".m-open-products-button.mm-sidebar-selector").animate({left:"0px"},200,function(){})}else $(".m-paint-selector-container").animate({top:"-100%"},200,function(){void 0!=e&&e()});F=!1},this.instantClosePaintSelector=function(){if("FactoryDirectFlooring"==mobileVisualizerConfigType&&($(".fdf-menu-container").removeClass("mm-disabled"),$(".fdf-tools-container").removeClass("mm-disabled")),$(".m-paint-selector-close-container").hide(),mobileVisualizerConfig.sidebarSelector){var e="-375px";"Phone"==S&&(e="-90%"),$(".m-paint-selector-container").css({left:e}),mobileVisualizerConfig.useTargets&&$(".m-open-products-button").hide(),$(".m-open-products-button.mm-sidebar-selector").css({left:"0px"})}else $(".m-paint-selector-container").css({top:"-100%"});F=!1},this.updateNewRoomProductTypes=function(){if("PhenixFlooring"==mobileVisualizerConfigType&&(m(),d()),"Mannington"==mobileVisualizerConfigType)return mobileVisualizer.isStairsRoom()||mobileVisualizer.isStairsStockRoom()?N="SimpleStairs":"SimpleStairs"==N&&(N="Adura MaxApex"),void l();if(!mobileVisualizer.curRoomSupportsProductTypeSubType(N,j))for(var e=0;e=e.canvas.height){s=document.createElement("canvas"),s.width=e.canvas.height,s.height=e.canvas.width;var i=s.getContext("2d");i.save(),i.translate(e.canvas.height,0),i.rotate(90*Math.PI/180),i.drawImage(e.canvas,0,0),i.restore()}var l=document.createElement("canvas");l.width=Math.floor(f*s.width/s.height),l.height=f,"WhitneyKiosk"==mobileVisualizerConfigType&&e.canvas.width>=e.canvas.height&&(l.width=f,l.height=Math.floor(f*s.height/s.width));var u=l.getContext("2d");if(u.fillStyle=g,u.fillRect(0,0,l.width,l.height),r)n.resize(s,l,{unsharpAmount:30,unsharpRadius:.5,unsharpThreshold:15,quality:3,alpha:!0}).then(function(){var i=document.createElement("canvas");i.width=f,i.height=f;var r=i.getContext("2d");r.fillStyle=g,r.fillRect(0,0,i.width,i.height),r.drawImage(l,(i.width-l.width)/2,0),"WhitneyKiosk"==mobileVisualizerConfigType&&e.canvas.width>=e.canvas.height&&(r.fillStyle=g,r.fillRect(0,0,i.width,i.height),r.drawImage(l,0,(i.height-l.height)/2)),a(t,d,i,o)});else{v=l.height*e.canvas.width/e.canvas.height,p=(l.width-v)/2,u.drawImage(s,0,0,s.width,s.height,0,0,l.width,l.height);var c=document.createElement("canvas");c.width=f,c.height=f;var h=c.getContext("2d");h.fillStyle=g,h.fillRect(0,0,c.width,c.height),h.drawImage(l,(c.width-l.width)/2,0),a(t,d,c,o)}}else if("Tile"==d.type){var p=e.tiles[0].x,b=e.tiles[0].y,v=e.tiles[0].w,w=e.tiles[0].h;"811382"==d.sku&&(w/=2);var l=document.createElement("canvas");w>v?(l.width=Math.floor(f*v/w),l.height=f):(l.width=f,l.height=Math.floor(f*w/v));var u=l.getContext("2d");u.fillStyle=g,u.fillRect(0,0,l.width,l.height),u.drawImage(e.canvas,p,b,v,w,0,0,l.width,l.height);var c=document.createElement("canvas");c.width=f,c.height=f;var h=c.getContext("2d");h.drawImage(l,(c.width-l.width)/2,(c.height-l.height)/2,l.width,l.height),a(t,d,c,o)}else{if(e.tiles.length>1){var C=document.createElement("canvas");C.width=500,C.height=500;for(var b=0;b0){y=Math.floor(VUtils.getRandom()*e.tiles.length);var A=e.tiles[y].w;p=-b/R*25*10}for(;p=w.width&&(A=0,S+=f+p),(t+1)%(v*v)!=0&&t+1!=e.products.length)return void r();var m="mobile/config/"+mobileVisualizerConfigType+"/thumbnails/products/",d=m+"thumbnailspack"+y+"-"+f+".jpg";l(w,m,d,function(){++y,C.fillStyle="#ffffff",C.fillRect(0,0,w.width,w.height),A=0,S=0,r()})}function m(e,t,o){for(var i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),n=!1,a,s,l,u=0;u\n',s+='\n',s+="\n",s+='\n',s+='\n',s+='\n';var l="";s+='\n',s+='\n',s+=""+$("title").text()+"",s+="\n",s+="\n",s+='<[[[script]]] type="text/javascript">\n',s+='window.location.href="'+window.location.href+'";',s+="[[[script]]]>\n",s+="\n",s+="\n";var u="vsaveroomimagejpg.php",c={html:s};c.base64RoomImage=e(r,800,0).toDataURL("image/jpeg",.75).replace("data:image/jpeg;base64,",""),$.post(u,c,function(e){if(e.indexOf("[[[OK]]]")==-1)return n(!1),void verror("Share Failed: "+e);var r=e.replace("[[[OK]]]","");o=r,i=t,n(!0)})},this.send=function(e){switch(e){case"facebook":var t="https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(o);window.open(t);break;case"twitter":var t="https://twitter.com/share",r=location.href.substring(0,location.href.lastIndexOf("/"))+"/";t+="?url="+r,t+="&text='"+o.replace(".html",".jpg")+"' "+i,window.open(t);break;case"pinterest":var t="https://pinterest.com/pin/create/button/";t+="?url="+o,t+="&media="+o.replace(".html",".jpg"),window.open(t)}}}function MultipleUYO(){function e(e,t){var o=mobileVisualizerConfigType+"-"+VUtils.getGUID().replace(/-/g,"").substr(0,8),i="multiple-user-photos",r=i+"/"+o+".jpg";alert("File name: "+e.name);var n=new FormData;n.append("section","general"),n.append("action","previewImg"),n.append("image","1234"),$.ajax({url:"vsavefile.php",data:n,type:"POST",contentType:!1,processData:!1})}function t(e,t){var i=mobileVisualizerConfigType+"-"+VUtils.getGUID().replace(/-/g,"").substr(0,8),r="multiple-user-photos",n=r+"/"+i+".jpg";alert("File name: "+e.name);var a=new FileReader;a.onload=function(e){o(a.result,r,n)},a.readAsDataURL(e)}function o(e,t,o,i){var r={base64Data:e,folder:t,filename:o};$.post("vsavebase64.php",r,function(e){alert("uploadFileData(): Finish: "+e),void 0!=i&&i()})}var i=this;this.addFiles=function(t){alert(t),e(t[1])}}function vDebug(e){null!=VUtils.GetQueryStringParam("debug")&&alert("New debug: "+e)}function MobileVisualizer(){function e(){if(mobileVisualizerConfig.enableStairs){var e={stairsEditStartedCallback:p,stairsEditFinishedCallback:g};location.href.indexOf(":5757")!=-1?si.setStairsCallbacks(e,!0):si.setStairsCallbacks(e)}if(mobileVisualizerConfig.enableWallOutlining){var e={firstPointPlacedCallback:t,adjustPerspectiveCallback:r,startDraggingPerspectivePointCallback:n,enterDimensionsCallback:a,editingExistingAreaCallback:u,editingExistingMaskCallback:c,startDraggingOutlinePointCallback:o,outlineFinishedCallback:l,adjustCountertopThicknessCallback:null};si.setUYOCallbacks(e)}}function t(){Pt.showInstruction(null)}function o(){Pt.showInstruction(null)}function r(){$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-perspective").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("Drag the circles as necessary to adjust the perspective and [tap] [OK] when finished, or [DELETE] to delete the area",Yo)}function n(){Pt.showInstruction(null)}function a(e){return mobileVisualizerConfig.skipUYOScalingStage?void xt.finishedAdjustingDimensions():(Bo=parseFloat(e[0]),Mo=parseFloat(e[1]),$(".m-uyo-tools .m-uyo-tool-button").hide(),visualizerPluginConfig.useGlobalUYOScaling?($(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-global-dimensions").show(),s()):$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-dimensions").show(),$(".m-uyo-tools").show(),void(visualizerPluginConfig.useGlobalUYOScaling?Pt.showInstructionFor("[Tap] the [WHITE+][WHITE-] buttons to adjust the height of the outline, then [tap] [OK] or [DELETE] to delete the area",2e6):Pt.showInstructionFor("[Tap] the [RED+][RED-][GREEN+][GREEN-] buttons to increase or decrease the one foot squares until their number represents the lengths of the red and green lines, then [tap] [OK] or [DELETE] to delete the area",Yo)))}function s(){var e=si.scaleUYOAreasDimensions(0,Ao),t=e.toFixed(2);t=parseFloat(t),$(".m-uyo-tool-button.mm-adjusting-global-dimensions.mm-adjusting-global-dimensions-size .mm-size").html(t),Ao?$(".m-uyo-tool-button.mm-adjusting-global-dimensions.mm-adjusting-global-dimensions-size .mm-feet-or-metres").html("Metres"):$(".m-uyo-tool-button.mm-adjusting-global-dimensions.mm-adjusting-global-dimensions-size .mm-feet-or-metres").html("Feet")}function l(){var e=!1;mobileVisualizerGUI.showMessageFor("Updating");for(var t=si.getUYOAreas(),o=!1;!o;){o=!0;for(var i in Co){for(var r=Co[i],n=!1,a=0;a0&&Qe()>0?Pt.showInstructionFor("Select a product to place on the floor or wall Note that walls can only take Hardwood and Laminate",5e3):1==Qe()?Pt.showInstructionFor("Select a product to place on the wall Note that walls can only take Hardwood and Laminate",5e3):Pt.showInstructionFor("Select a product to place on a wall Note that walls can only take Hardwood and Laminate",5e3):je()>0&&Qe()>0?Pt.showInstructionFor("Select a product to place on the floor or wall",5e3):1==Qe()?Pt.showInstructionFor("Select a product to place on the wall",5e3):Pt.showInstructionFor("Select a product to place on a wall",5e3))}))}function u(){$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-outline").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("Drag the circles to adjust the area and [tap] [OK] when finished, or [DELETE] to delete the area",Yo)}function c(){$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-outline").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("Drag the circles to adjust the area and [tap] [OK] when finished, or [DELETE] to delete",Yo)}function m(){si.uyoFinishSurfaceEdit(),Qt="",$(".m-uyo-tools").hide(),he(function(){h(),Pt.updateTools(),Pt.updateCurrentProduct()})}function d(){return mobileVisualizerConfig.enableSimpleUYORooms?void $(".m-simple-room-selector .mm-button-container").hide():(vt(!1),$(".m-header .mm-all-buttons").hide(),$(".m-open-products-button").hide(),$(".m-tools-container").hide(),$(".m-current-product-details").hide(),It(),lt(),void Je())}function h(){return mobileVisualizerConfig.enableSimpleUYORooms?void $(".m-simple-room-selector .mm-button-container").show():(vt(!0),$(".m-header .mm-all-buttons").show(),mobileVisualizerConfig.useTargets||$(".m-open-products-button").show(),$(".m-tools-container").show(),Pt.updateCurrentProduct(),void Je())}function f(){Pt.showMessage(null),$(".m-floor-or-stairs-popup").show()}function p(){ro=!0,b()}function g(){ro=!1,v(),Ro=null;var e=null,t=null;for(var o in Co)t=Co[o].sku,e=Co[o].decoration;var i="FLOOR-"+Ke(),o="AreaRef-"+Ke();Co=new Object,Co[o]=new Object,Co[o].id="Stairs",Co[o].gridName=i,Co[o].surface="stairs",Co[o].where="inside",Co[o].type="texture",Co[o].group="",Co[o].isLayer=!1,Co[o].isLayerForCarpet=!1,Co[o].decoration=e,Co[o].decorationRotate=0,Co[o].rugDecoration=null,Co[o].sku=t,"Mannington"==mobileVisualizerConfigType&&(visualizerPluginConfig.colourUYOStairsRiser=null),"RunRug"==mobileVisualizerConfigType&&ze(o,fo.assetRef,fo.sku),++Po,he(function(){Pt.updateNewRoomProductTypes(),Pt.updateCurrentProduct(),Pt.updateTools(),Je(),dt(),Pt.updateCurrentProductPos(),$t()})}function b(){vt(!1),$(".m-header .mm-all-buttons").hide(),$(".m-open-products-button").hide(),$(".m-tools-container").hide(),$(".m-current-product-details").hide(),"RunRug"==mobileVisualizerConfigType&&$(".m-runrug-gui .mm-runrug-gui-container").hide(),It(),Pt.hideHelp(),Ho=Pt.isQuickSelectorOn(),Ho&&Pt.setQuickSelectorMode(!1)}function v(){Pt.updateTools(),$(".m-header .mm-all-buttons").show(),mobileVisualizerConfig.useTargets||$(".m-open-products-button").show(),$(".m-tools-container").show(),"RunRug"==mobileVisualizerConfigType&&$(".m-runrug-gui .mm-runrug-gui-container").show(),Ho&&Pt.setQuickSelectorMode(!0)}function w(){var e=new Object;if(e.roomId=Zt,e.roomData=Co,"UYO"==Zt){var t=.5;e.uyoData=JSON.parse(si.getUYOEditData()),e.uyoOriginalRoomImage=JSON.parse(si.getUYOOriginalRoomImage(t))}e.thumbnail=S(400,266).toDataURL("image/jpeg",.5),ni.save(mobileVisualizerConfigType+"-MobileVisualizer-AutoSaveRoom-"+mobileVisualizerConfig.savedRoomsRef,e)||ni.save(mobileVisualizerConfigType+"-MobileVisualizer-AutoSaveRoom-"+mobileVisualizerConfig.savedRoomsRef,null)}function C(){var e=ni.load(mobileVisualizerConfigType+"-MobileVisualizer-AutoSaveRoom-"+mobileVisualizerConfig.savedRoomsRef);return null!=e&&("Started"==VUtils.loadCookie("AutoLoading")?(VUtils.saveCookie("AutoLoading","Finished"),ii.track("@AutoLoadFailed"),!1):(VUtils.saveCookie("AutoLoading","Started"),"RunRug"==mobileVisualizerConfigType&&Pt.showLanding(!1),"UYO"==e.roomId?oe(e.uyoData,e.uyoOriginalRoomImage,function(){Pt.showLanding(!1),B(),ft(null),Co=VUtils.clone(e.roomData),ke(function(){U(),Pt.updateCurrentProduct(),Pt.updateNewRoomProductTypes(),VUtils.saveCookie("AutoLoading","Finished")})}):ie(e.roomId,function(){Pt.showLanding(!1),ft(null),Co=VUtils.clone(e.roomData),ke(function(){U(),Pt.updateCurrentProduct(),Pt.updateNewRoomProductTypes(),VUtils.saveCookie("AutoLoading","Finished")})}),!0))}function y(){io||(io=!0,Pt.updateQuickSelector())}function A(){to=ni.load(mobileVisualizerConfigType+"-MobileVisualizer-SavedRooms-"+mobileVisualizerConfig.savedRoomsRef),null==to&&(to=new Array,ni.save(mobileVisualizerConfigType+"-MobileVisualizer-SavedRooms-"+mobileVisualizerConfig.savedRoomsRef,to));for(var e=!1,t=0;t1&&$(".m-change-rug-size").show()}}function Q(e,t){function o(){if(!e)return void t(i);var o=5,n=document.getElementById("m-id-header-logo"),a=i.width/4,s=a/n.width*n.height;null==mobileVisualizerConfig.savePhotoHeaderBackgroundColour?r.fillStyle="#ffffff":r.fillStyle=mobileVisualizerConfig.savePhotoHeaderBackgroundColour,r.fillRect(0,0,i.width,o+s+5),r.drawImage(n,(i.width-a)/2,o,a,s),o+=s+20;for(var l=[],u=te(),c=0;c0){r.font="30px Arial",r.textAlign="center";for(var h=0,c=0;c0&&(x+=20+a/2),r.fillStyle="rgba(32,32,32,0.7)",r.fillRect(x-a/2,o,a,s),r.fillStyle="#fff";for(var f=o,c=0;c0){r.font="30px Arial",r.textAlign="center";for(var h=0,c=0;c135&&(Co[e].decorationRotate=0)),ft(so,no),he(function(){Pt.updateTools(),Pt.updateCurrentProduct()})}function de(e){null!=Xt&&(clearTimeout(Xt),Xt=null),Pt.showInstruction(null),Qt="",Co[e].rugDecoration.decorationRotate=90-Co[e].rugDecoration.decorationRotate,he(function(){Pt.updateTools(),Pt.updateCurrentProduct()})}function he(e){function t(){Go.update(so.assetRef,so.panoVersion,yo,function(){Pt.showMessage(null),Pt.showHelpOnce(),Pt.updateCurrentProduct(),null!=e&&e()})}function o(){function t(){"Demo"==mobileVisualizerConfigType&&(visualizerPluginConfig.renderUYOStairsAsRunner=!1,xt.isStairsRoom()&&n&&(visualizerPluginConfig.renderUYOStairsAsRunner=!0,visualizerPluginConfig.fixUVBug=!0)),si.renderAreasAndLayers(i,o,function(){Pt.showMessage(null),pt(),mobileVisualizerConfig.autoSaveCurrentRoom&&w(),void 0!=e&&e()})}mobileVisualizerConfig.panoEnabled&&Go.hide();var o=[],i=[],r=25;mobileVisualizerConfig.UseHalfSizedtextures&&(r=12.5),mobileVisualizerConfig.overrideDPI!=-1&&(r=mobileVisualizerConfig.overrideDPI);var n=!1;for(var a in Co){var s=Co[a];if(null!=s.decoration){var l=!1;if(s.isLayer&&(l=!0),s.decoration.indexOf("#")==-1&&s.isLayerForCarpet){var u=ve(s.sku);"Carpet"==u.type&&(l=!0),"Demo"==mobileVisualizerConfigType&&"Runner"==u.type&&(l=!0)}if(l){var c=s.decoration,m="";if(90==s.decorationRotate&&(m="_Rotation=90"),"Demo"==mobileVisualizerConfigType&&xt.isStairsStockRoom()&&0==s.sku.indexOf("R-")&&"AreaRef2"==a){var d=mobileVisualizerConfig.layersPath+Zt+"/"+Zt+"_AllStairs.png";o.push(d)}VUtils.GetQueryStringParam("vit-testscale")&&(c="OneFootSquares");var d=mobileVisualizerConfig.layersPath+Zt+"/"+Zt+"_"+a.replace("Ref","")+"_Texture="+c+m+".png";o.push(d)}else if(s.decoration.indexOf("#")==-1){var u=ve(s.sku);"Runner"==u.type&&(n=!0);var h=mobileVisualizerConfig.assetsPrefix+"textures/";void 0!=u.assetPath&&""!=u.assetPath&&(h+=u.assetPath+"/");var f="png";void 0!=u.assetFileExt&&""!=u.assetFileExt&&(f=u.assetFileExt);var p=h+s.decoration+"_c."+f;VUtils.GetQueryStringParam("vit-testscale")&&(h=mobileVisualizerConfig.assetsPrefix+"textures/",p=h+"OneFootSquares_c.jpg"),p+="?"+mobileVisualizerStopCaching;var g=null;mobileVisualizerConfig.isTextureNormals&&(g=p.replace("_c.","_n.")),mobileVisualizerConfig.isTextureNormals&&"FLAT_NORMAL"==u.normalAssetRef&&(g=h+"FlatNormal_n."+f);var b={colourTexture:p,normalTexture:g,pattern:"Linear",lighting:"matt",rotate:s.decorationRotate,dpi:r};void 0!=u.forcePattern&&""!=u.forcePattern&&(b.pattern=u.forcePattern),"RitzFlooring"==mobileVisualizerConfigType&&(b.pattern="Random"),void 0!=s.pattern&&(b.pattern=s.pattern),void 0!=s.groutColour&&(b.groutColour=s.groutColour),"Demo"==mobileVisualizerConfigType&&(b.lighting=u.lighting),"TileMountain"==mobileVisualizerConfigType&&(b.lighting=u.lighting,b.type="Tile",""==u.addNoEdgeGrout&&(b.addGrout=2)),"Primco"==mobileVisualizerConfigType&&(b.lighting=u.lighting,b.type="Tile"),"WorldOfTiles"==mobileVisualizerConfigType&&(b.lighting=u.lighting,b.type="Tile"),"AmberTiles"==mobileVisualizerConfigType&&(b.lighting=u.lighting,b.type="Tile"),location.href.indexOf("vitshowglosslevel")!=-1&&alert(b.lighting),i.push({id:s.id,data:b})}else{var v={colour:s.decoration};i.push({id:s.id,data:v})}}}var C=!1;for(var a in Co){var s=Co[a],y=s.rugDecoration;if(null!=y){var u=ve(y.sku),h=mobileVisualizerConfig.assetsPrefix+"textures/";void 0!=u.assetPath&&""!=u.assetPath&&(h+=u.assetPath+"/");var f="png";void 0!=u.assetFileExt&&""!=u.assetFileExt&&(f=u.assetFileExt);var p=h+y.decoration+"_c."+f;p+="undefined"!=typeof vitRugMaker?"?"+(new Date).getTime():"?"+mobileVisualizerStopCaching,"undefined"!=typeof stantonCreateARugInfo&&stantonCreateARugInfo.overrideRender&&(p=h+"Test Rug-"+stantonCreateARugInfo.ref+"-"+stantonCreateARugInfo.size+"-"+stantonCreateARugInfo.binding+"_c.jpg"),C=!0;var A={colourTexture:p,normalTexture:null,lighting:"matt",rotate:y.decorationRotate,x:y.x,y:y.y,dpi:25},S=!0;"WhitneyKiosk"==mobileVisualizerConfigType&&(S=!1),si.addRug(s.id,A,S,function(){pt(),"BuyCarpet"==mobileVisualizerConfigType&&j(),t()})}}C||t()}Pt.showMessage("Rendering",!0),"Pano"==Zt&&setTimeout(t,1),"Pano"!=Zt&&setTimeout(o,1)}function fe(e){function t(){var t=[],o=25;mobileVisualizerConfig.UseHalfSizedtextures&&(o=12.5),mobileVisualizerConfig.overrideDPI!=-1&&(o=mobileVisualizerConfig.overrideDPI);for(var i in Co){var r=Co[i];if(null!=r.decoration){var n=ve(r.sku),a=mobileVisualizerConfig.assetsPrefix+"textures/";void 0!=n.assetPath&&""!=n.assetPath&&(a+=n.assetPath+"/");var s="png";void 0!=n.assetFileExt&&""!=n.assetFileExt&&(s=n.assetFileExt);var l=a+r.decoration+"_c."+s;l+="?"+mobileVisualizerStopCaching;var u=null;mobileVisualizerConfig.isTextureNormals&&(u=l.replace("_c.","_n.")),mobileVisualizerConfig.isTextureNormals&&"FLAT_NORMAL"==n.normalAssetRef&&(u=a+"FlatNormal_n."+s);var c={groutColour:"#Transparent",colourTexture:l,normalTexture:u,pattern:"Linear",lighting:"matt",rotate:r.decorationRotate,dpi:o};t.push({id:r.id,data:c})}}var m=[];si.enableSemiTransparentRendering(!0),si.renderAreasAndLayers(t,m,function(){si.enableSemiTransparentRendering(!1),Pt.showMessage(null),null!=e&&e()})}Pt.showMessage("Preparing",!0),setTimeout(t,1)}function pe(){function e(e){return/\d/.test(e)}if(void 0!=Vt.productFilters)for(var t=0;tt?1:0}):o.values.sort()}else void 0==o.fixOrder?o.values.sort():""==o.fixOrder&&o.values.sort();if(void 0!=oi.translate)for(var a=0;a0&&(o.values[a]+="/"),o.values[a]+=oi.translate(l[u],"Database")}Jt[o.id]=new Array}}function ge(e){var t=e.indexOf("@");if(t==-1)return!1;if(0==t)return!1;if(t==e.length-1)return!1;for(var o=0,i="",r=0;rt;)So.pop();VUtils.saveCookie(mobileVisualizerConfigType+"-MobileVisualizer-RecentlyUsed-"+mobileVisualizerConfig.savedRecentlyUsedRef,JSON.stringify(So))}}function Se(){To=VUtils.loadCookie(mobileVisualizerConfigType+"-MobileVisualizer-Favourites-"+mobileVisualizerConfig.savedFavouritesRef),To=null!=To?JSON.parse(To):new Array;for(var e=0;e"," ")),$(".m-editing-tools-popup .mm-title").html(mobileVisualizerConfig.editingToolsName.replace(" "," ")));var i=0;$(".m-landing-button").each(function(){"none"!=$(this).css("display")&&++i});var r=Math.ceil(i/4);"Phone"==Ft&&(r=Math.ceil(i/2)),$("body").addClass("cf-landing-page-button-rows-"+r),mobileVisualizerConfig.newLookTools&&$("body").addClass("cf-new-look-tools"),mobileVisualizerConfig.usLanguage&&($(".m-product-selector-heading").each(function(e){$(this).html($(this).html().replace("favourite","favorite")),$(this).html($(this).html().replace("favourite","favorite"))}),$(".m-tool-button-text").each(function(){$(this).html().indexOf("Favourite")!=-1&&$(this).html($(this).html().replace("Favourite","Favorite")),$(this).html().indexOf("favourite")!=-1&&$(this).html($(this).html().replace("favourite","favorite")),$(this).html().indexOf("Favourites")!=-1&&$(this).html($(this).html().replace("Favourites","Favorites"))}),$(".m-paint-selector-container .m-paint-selector-heading").html($(".m-paint-selector-container .m-paint-selector-heading").html().replace("colour","color"))),mobileVisualizerConfig.includeMetadata?"undefined"==typeof mobileVisualizerConfigMetadata?verror("Need to include Metadata .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigMetadata!=mobileVisualizerConfigType&&verror("Wrong Metadata .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigMetadata+")"):"undefined"!=typeof mobileVisualizerConfigMetadata&&verror("No Metadata .kit file required - is set to "+mobileVisualizerConfigMetadata),mobileVisualizerConfig.includeGoogleAnalytics?"undefined"==typeof mobileVisualizerConfigGoogleAnalytics?verror("Need to include Google Analytics .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigGoogleAnalytics!=mobileVisualizerConfigType&&verror("Wrong Google Analytics .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigGoogleAnalytics+")"):"undefined"!=typeof mobileVisualizerConfigGoogleAnalytics&&verror("No Google Analytics .kit file required - is set to "+mobileVisualizerConfigGoogleAnalytics),mobileVisualizerConfig.includeExtraHTML1?"undefined"==typeof mobileVisualizerConfigExtraHTML1?verror("Need to include extra HTML1 .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigExtraHTML1!=mobileVisualizerConfigType&&verror("Wrong extra HTML2 .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigExtraHTML1+")"):"undefined"!=typeof mobileVisualizerConfigExtraHTML1&&verror("No extra HTML1 .kit file required - is set to "+mobileVisualizerConfigExtraHTML1),mobileVisualizerConfig.includeExtraHTML2?"undefined"==typeof mobileVisualizerConfigExtraHTML2?verror("Need to include extra HTML2 .kit file for: "+mobileVisualizerConfigType):mobileVisualizerConfigExtraHTML2!=mobileVisualizerConfigType&&verror("Wrong extra HTML2 .kit file included - needs: "+mobileVisualizerConfigType+" (is "+mobileVisualizerConfigExtraHTML2+")"):"undefined"!=typeof mobileVisualizerConfigExtraHTML2&&verror("No extra HTML2 .kit file required - is set to "+mobileVisualizerConfigExtraHTML2),"FactoryDirectFlooring"==mobileVisualizerConfigType?void 0==$(".m-landing-container .mm-container.mm-fdf").html()&&verror("Factory Direct Flooring needs it's specific landing page html enabled."):void 0!=$(".m-landing-container .mm-container.mm-fdf").html()&&verror("Non-Factory Direct Flooring needs it's specific landing page html disabled or see it's image loads fail in console."),"WorldOfTiles"==mobileVisualizerConfigType?void 0==$(".m-landing-container .mm-container.mm-wot").html()&&verror("World Of Tiles needs it's specific landing page html enabled."):void 0!=$(".m-landing-container .mm-container.mm-wot").html()&&verror("Non-World Of Tiles needs it's specific landing page html disabled or see it's image loads fail in console.")}function Je(){function e(){var e=$(".m-scene-render").width(),o=$(".m-scene-render").height(),i=e/o,r=document.getElementById("id-visualizer-plugin-render-canvas"),n=r.width,a=r.height,s=n/a;if($("body").removeClass("disable-horizontal-scrolling"),$("body").removeClass("disable-vertical-scrolling"),$(".visualizer-plugin-render-canvas").removeClass("mm-fill-width"),$(".visualizer-plugin-render-canvas").removeClass("mm-fill-height"),_t())return $("body").addClass("disable-horizontal-scrolling"),$("body").addClass("disable-vertical-scrolling"),void(s>=i?$(".visualizer-plugin-render-canvas").addClass("mm-fill-width"):$(".visualizer-plugin-render-canvas").addClass("mm-fill-height"));if(s>=i){if(t||$("body").addClass("disable-vertical-scrolling"),$(".visualizer-plugin-render-canvas").addClass("mm-fill-height"),!t){var l=(n*o/a-e)/2;$(window).scrollLeft(l)}}else if(t||$("body").addClass("disable-horizontal-scrolling"),$(".visualizer-plugin-render-canvas").addClass("mm-fill-width"),!t){var l=1.5*(a*e/n-o)/2;$(window).scrollTop(l)}}if(null!=Zt&&"Pano"!=Zt){var t=!1;$("body").hasClass("m-desktop")&&(t=!0),Ut=10,t&&(Ut=1),e(),null!=Lt&&clearInterval(Lt),Lt=setInterval(function(){--Ut,0==Ut&&(clearInterval(Lt),Lt=null),e()},25)}}function Ze(e){if($(".m-phone-popup-message").is(":visible")){var t=85,o=54,i=!1;switch(window.orientation){case 0:e.beta>=o&&e.beta<=180-t&&(i=!0);break;case 90:(e.gamma>=-89.999&&e.gamma<=-o||e.gamma<=89.999&&e.gamma>=t)&&(i=!0);break;case-90:(e.gamma>=o&&e.gamma<=89.999||e.gamma>=-89.999&&e.gamma<=-t)&&(i=!0);break;case 180:}location.href.indexOf("ignorecameravertical")!=-1&&(i=!0),(Ot||i!=Dt)&&($(".m-phone-popup-message .m-phone-popup-message-take-photo-button").removeClass("m-phone-not-close-to-vertical"),i||$(".m-phone-popup-message .m-phone-popup-message-take-photo-button").addClass("m-phone-not-close-to-vertical")),location.href.indexOf("showcameraangle")!=-1&&$(".m-phone-popup-message .m-phone-popup-message-take-photo-button p").html(window.orientation+" Beta: "+e.beta.toFixed(1)+" Gamma: "+e.gamma.toFixed(1)),Dt=i,Ot=!1}}function et(){function e(o){o&&null!==o.alpha&&null!==o.beta&&null!==o.gamma&&(window.removeEventListener("deviceorientation",e),clearTimeout(t),t=null,Bt=!0)}if(window.DeviceOrientationEvent){var t=setTimeout(function(){t=null},1e3);window.addEventListener("deviceorientation",e)}}function tt(){function e(e){e.changedTouches[0].force>=.1&&e.preventDefault()}$(".visualizer-plugin-render-canvas").bind("mousedown mousemove mouseup mouseout touchstart touchmove touchend",function(e){ot(e)}),document.getElementById("m-save-photo-disable-3d-touch").addEventListener("touchforcechange",e)}function ot(e){if("UYOEditingFloor"!=Qt&&"UYOEditingWall"!=Qt){var t=$(".visualizer-plugin-render-canvas")[0],o=t.getBoundingClientRect(),i=t.width/o.width,r=t.height/o.height,n=0,a=0;switch(e.clientX&&e.clientY?(n=(e.clientX-o.left)*i,a=(e.clientY-o.top)*r):e.originalEvent.targetTouches&&e.originalEvent.targetTouches.length>0&&(n=(e.originalEvent.targetTouches[0].clientX-o.left)*i,a=(e.originalEvent.targetTouches[0].clientY-o.top)*r),Qt){case"WaitingForPaintAreaSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=Ne(n,a);null!=s&&I(s)&&se(s)}break;case"WaitingForPatternAreaSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=Ne(n,a);null!=s&&re(s)}break;case"WaitingForGroutAreaSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=Ne(n,a);null!=s&&E().indexOf(s)!=-1&&ne(s)}break;case"WaitingForFloorSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=Ne(n,a);null!=s&&le(s)}return;case"WaitingForFloorOrWallSelection":if("mousedown"==e.type||"touchstart"==e.type){var s=Ne(n,a);vout(s),null!=s&&le(s)}return;case"WaitingForRotateFloorOrWallSelection":if("mousedown"==e.type||"touchstart"==e.type){
var s=Ne(n,a);if(null!=s){var l=Co[s];l.decoration.indexOf("#")==-1&&me(s)}}return;case"WaitingForRugPlacement":if("mousedown"==e.type||"touchstart"==e.type){var s=Ne(n,a);if(null!=s){if(F(s)){Pt.showInstructionFor("You can't put rugs on stairs",3e3);break}ue(s,n,a)}}return;case"WaitingForRotateSelection":if("mousedown"==e.type||"touchstart"==e.type)for(var s in Co){var l=Co[s];if("texture"==l.type){if(null!=l.rugDecoration&&null!=si.getRugAtXY(n,a))return void de(s);if(null!=l.decoration&&Ne(n,a)==s)return void me(s)}}return}switch(e.type){case"mousedown":case"touchstart":si.checkStartDraggingRug(n,a),Yt=n,Ht=a;break;case"mousemove":case"touchmove":if(!si.checkDragRug(n,a))break;qt=n-Yt,Kt=a-Ht,e.preventDefault();break;case"mouseout":case"mouseup":case"touchend":si.checkStopDraggingRug(function(e){if(null!=e){Wt+=qt,Gt+=Kt;for(var t in Co){var o=Co[t];if("texture"==o.type&&null!=o.rugDecoration){Co[t].rugDecoration.x=Wt,Co[t].rugDecoration.y=Gt,Co[t].rugDecoration.x=e.x,Co[t].rugDecoration.y=e.y;break}}Pt.showMessage(null)}},function(){Pt.showMessage("Rendering",!0)})}}}function it(){$(".visualizer-plugin-render-canvas").css("cursor","pointer")}function rt(){$(".visualizer-plugin-render-canvas").css("cursor","default")}function nt(e){Ko=mobileVisualizerConfigType+"-"+VUtils.getGUID().replace(/-/g,"").substr(0,6);var t="https://qr.viziserve.com/?photocode="+Ko+"&name="+document.title;void 0!=e&&(t+="&type="+e),void 0!=oi.getLanguage&&(t+="&lang="+oi.getLanguage()),null==qo?qo=new QRCode(document.getElementById("qr-code-container"),{text:t,width:256,height:256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.L}):(qo.clear(),qo.makeCode(t))}function at(){if(mobileVisualizerConfig.enableRunVisualizerViaQRCode&&"Desktop"==Ft){$(".m-menu-container .mm-run-visualizer-on-phone").show(),"FactoryDirectFlooring"==mobileVisualizerConfigType&&$(".m-menu-container .mm-fdf-qr-instructions").show();var e=location.href;new QRCode(document.getElementById("run-on-phone-qr-code-container"),{text:e,width:256,height:256,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRCode.CorrectLevel.L})}}function st(e,t){$.ajax({type:"GET",url:e,dataType:"text",crossDomain:!0,success:function(e){t(e)},error:function(t,o,i){verror("loadTextFromURL(): "+e+" - ajax error: jqXHR.status=["+t.status+"] textStatus=["+o+"] errorThrown=["+i+"]")},statusCode:{404:function(){verror("loadTextFromURL(): "+e+" - 404 page not found")},405:function(){verror("loadTextFromURL(): "+e+" - 405 page not found")}}})}function lt(){Ct()&&(xo=-1,null!=$o&&($o.width=0,$o.height=0),$o=null,Po=0,Fo=!0,vt(!1),Uo=[])}function ut(){function e(e){e.preventDefault(),"touchstart"==e.type&&(Io=!0),$(".m-before-after-viewer .mm-slider-help").hide(),r=!0,setTimeout(function(){r=!1,Qt=""},300),Io?(document.ontouchend=o,document.ontouchmove=t):(document.onmouseup=o,document.onmousemove=t),i=Io?e.touches[0].clientX-document.getElementById("m-before-after-viewer-slider").offsetLeft:e.clientX-document.getElementById("m-before-after-viewer-slider").offsetLeft}function t(e){var t;t=Io?e.touches[0].clientX:e.clientX,t-=i,xo=parseInt(t+25);var o=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft,r=document.getElementById("id-visualizer-plugin-render-canvas"),n=r.getBoundingClientRect();xo-o<3?xo=o+3:xo>o+n.width-25&&(xo=o+n.width-25),Vo=!0,Fo=!1,gt()}function o(){document.onmouseup=null,document.onmousemove=null,document.ontouchend=null,document.ontouchmove=null;var e=document.getElementById("id-visualizer-plugin-render-canvas"),t=e.getContext("2d"),o=e.getBoundingClientRect(),i;i=_t()?o.left+3:-o.left+3,i=parseInt(i),vout("sliderSplitX="+xo+" viewLeftX="+i);const n=25;return Vo&&xo>=i-n&&xo<=i+n&&ht(),r?(xo=Fo?-2:-1,Fo=!Fo,void gt()):void(Vo=!1)}var i=0,r;document.getElementById("m-before-after-viewer-slider").onmousedown=e,document.getElementById("m-before-after-viewer-slider").ontouchstart=e}function ct(){if(wt()){var e=document.getElementById("id-visualizer-plugin-render-canvas"),t=e.getContext("2d"),o=e.getBoundingClientRect(),i=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft,r=xo;r-=i,r*=$o.width/o.width;var n=r/$o.width*100;n<25?(xo=-1,Fo=!0):(xo=-2,Fo=!1),gt()}}function mt(){return null==Zt&&vout("No room loaded yet"),"Pano"==Zt?void vout("Not pano room"):void(Fo?ht():gt())}function dt(){return"Pano"==Zt?void vout("Not pano room"):void setTimeout(function(){ht()},100)}function ht(){xo=-1,Fo=!0,wt()&>()}function ft(e,t){if(Ct()){Uo=VUtils.clone(te()),void 0!=t&&++Po;var o=si.getRenderedScene();null==$o&&($o=document.createElement("canvas"),_o=$o.getContext("2d"),$o.width=o.width,$o.height=o.height),_o.drawImage(o,0,0)}}function pt(){Ct()&&wt()&>()}function gt(){var e=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft;bt();var t=document.getElementById("id-visualizer-plugin-render-canvas"),o=t.getContext("2d"),i=t.getBoundingClientRect();if(Fo)o.drawImage(si.getRenderedScene(),0,0);else{var r=xo;r-=e,r*=$o.width/i.width,o.drawImage(si.getRenderedScene(),0,0),o.drawImage($o,0,0,r,$o.height,0,0,r,$o.height)}vt(!0)}function bt(){var e=document.getElementById("id-visualizer-plugin-render-canvas").clientHeight;document.getElementById("m-before-after-viewer-divider").style.height=e+"px";var e=10+$(".m-tools-container").outerHeight(!1),t=$(window).scrollTop();t+=e,document.getElementById("m-before-after-viewer-slider").style.top=t+"px",t=e,document.getElementById("m-before-after-viewer-slider-locked").style.top=t+"px",e=40,t=$(window).scrollTop(),t+=e,document.getElementById("id-m-before-product-details").style.top=t+"px",document.getElementById("id-m-after-product-details").style.top=t+"px";var o=document.getElementById("id-visualizer-plugin-render-canvas"),i=o.getContext("2d"),r=o.getBoundingClientRect();xo==-1?(xo=_t()?r.left+3:-r.left+3,xo=parseInt(xo)):xo==-2&&(xo=_t()?$(".m-scene-render").width()/2:-r.left+$(".m-scene-render").width()/2,xo=parseInt(xo));var n=parseInt(xo-25);document.getElementById("m-before-after-viewer-slider").style.left=n+"px",n=parseInt(xo-3),document.getElementById("m-before-after-viewer-divider").style.left=n+"px";var a=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft;n=a,document.getElementById("m-before-after-viewer-slider-locked").style.left=n+"px",document.getElementById("m-before-after-viewer-divider-locked").style.left=n+"px";var a=document.getElementById("id-visualizer-plugin-render-canvas").offsetLeft,s="auto",l=25-(xo-a);if(l>0){var s="rect(0px,50px,50px,[LEFT]px)";s=s.replace("[LEFT]",l)}$(".m-before-after-viewer .mm-unlocked .mm-slider").css("clip",s),Fo?($(".m-before-after-viewer .mm-locked .mm-divider").show(),$(".m-before-after-viewer .mm-locked .mm-slider").show(),$(".m-before-after-viewer .mm-unlocked .mm-divider").addClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-unlocked .mm-slider").addClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-before-after-product-details").hide(),$(".m-current-product-details").show()):($(".m-before-after-viewer .mm-locked .mm-divider").hide(),$(".m-before-after-viewer .mm-locked .mm-slider").hide(),$(".m-before-after-viewer .mm-unlocked .mm-divider").removeClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-unlocked .mm-slider").removeClass("mm-locked-so-nearly-hide"),$(".m-before-after-viewer .mm-before-after-product-details.mm-after").show(),xt.getBeforeUsedProducts().length>0?$(".m-before-after-viewer .mm-before-after-product-details.mm-before").show():$(".m-before-after-viewer .mm-before-after-product-details.mm-before").hide(),$(".m-current-product-details").hide())}function vt(e){$(".m-before-after-viewer").hide(),wt()&&($(".m-before-after-viewer").hide(),e&&$(".m-before-after-viewer").show())}function wt(){return!!Ct()&&!(Po<2)}function Ct(){return!!mobileVisualizerConfig.enableBeforeAfterViewer&&(!(!visualizerPluginConfig.enableBeforeAfterViewerForPhone&&"Phone"==Ft)&&"Pano"!=Zt)}function yt(e){Zo=e,At()}function At(){$(".m-rug-size-popup").show()}function St(e,t,o,i){Pt.showMessage("Creating Rug or Runner");var r="mobile/config/"+mobileVisualizerConfigType+"/textures/jpg90/"+e+"_c.jpg";Tt(r,function(e){var r=e.getContext("2d");ti.width=Math.floor(25*t),ti.height=Math.floor(25*o);var n=ti.getContext("2d");n.fillStyle="#"+Et(e),n.fillRect(0,0,ti.width,ti.height);var a=n.createPattern(e,"repeat");n.fillStyle=a;var s=50;n.fillRect(s,s,ti.width-2*s,ti.height-2*s),Rt(ti,function(){Pt.showMessage(null),i()})})}function Tt(e,t){var o=new Image;o.crossOrigin="Anonymous",o.onerror=function(){t(null)},o.onload=function(){ei.width=o.width,ei.height=o.height,ei.getContext("2d").drawImage(o,0,0),t(ei)},VUtils.isInternetExplorerBrowser()||(o.src=""),o.src=e}function Rt(e,t){var o="mobile/config/StantonCarpet/textures/jpg90/",i=o+"UserCreatedRug_c.jpg";kt(e,o,i,.8,function(){t()})}function kt(e,t,o,i,r){var n={base64Data:e.toDataURL("image/jpeg",i).replace(/^data:image\/(png|jpeg);base64,/,""),folder:t,filename:o};$.post("vsavebase64.php",n,function(e){null!=r&&r()})}function Et(e){function t(e){var t=e.toString(16);return 1==t.length?"0"+t:t}for(var o=30,i=0,r=0,n=0,a=e.width,s=e.height,l=e.getContext("2d"),u=0;u0)for(var d=$(".m-current-product-details").offset().top+$(".m-current-product-details").height(),h=$(".m-current-product-details").offset().left+$(".m-current-product-details").width(),f=50,p=50;c-p/2*1.20},this.isPatternsAvailable=function(){return E().length>0},this.isPaintAvailable=function(){if(!mobileVisualizerConfig.enablePaintButton)return!1;if(mobileVisualizerConfig.useTargets)return!!I(Ro);if(mobileVisualizer.getNumWalls()>0){if("UYO"!=mobileVisualizer.getCurRoomId())return!0;if(!mobileVisualizerConfig.noUYOWallPaint)return!0}return!1},this.openUYOOptionsPopup=function(){$(".m-uyo-options-popup").show()},this.closeUYOOptionsPopup=function(){$(".m-uyo-options-popup").hide()},this.getAnalytics=function(){return ii},this.deviceType=function(){return Ft},this.getMode=function(){return Qt},this.addWallOutline=function(){Qt="UYOEditingWall",Pt.hideHelp(),d(),si.uyoStartSurfaceEdit(),No="UniqueAreaId-"+Ke(),si.uyoAddWallArea(No),$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-creating-new-outline").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("[Tap] around the wall and onto the first point to finish, or [DELETE] to cancel",Yo)},this.toggleUYODimensions=function(){Ao=!Ao,s()},this.scaleUYODimensions=function(e){e?si.scaleUYOAreasDimensions(1,Ao):si.scaleUYOAreasDimensions(-1,Ao),s()},this.adjustUYODimensionA=function(e){e>0?Bo<20&&(Bo+=.5):Bo>2&&(Bo-=.5),si.setUYOAreaDimensionA(Bo)},this.adjustUYODimensionB=function(e){e>0?Mo<20&&(Mo+=.5):Mo>2&&(Mo-=.5),si.setUYOAreaDimensionB(Mo)},this.finishedAdjustingDimensions=function(){si.uyoEditAreaFinished()},this.deleteOutline=function(){null==No?(No=null,"UYOEditingFloor"==Qt?m():si.uyoEditDeleteOutline()):xt.abortAdjustingOutlines(),$t()},this.finishedAdjustingOutline=function(){si.uyoEditFinishedAdjustingOutline()},this.finishedAdjustingPerspective=function(){si.uyoEditFinishedAdjustingPerspective()},this.editOutlines=function(){Qt="UYOEditingWall",Pt.hideHelp(),d(),si.uyoStartSurfaceEdit(),$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-adjusting-outline-not-started").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("[Tap] a wall area to adjust",Yo)},this.abortAdjustingOutlines=function(){mobileVisualizerGUI.showMessageFor("Updating"),Qt="",$(".m-uyo-tools").hide(),Pt.showInstruction(null),si.uyoFinishSurfaceEdit(),Pt.updateCurrentProduct(),Pt.updateTools(),he(function(){h()})},this.addMaskOutline=function(){Qt="UYOEditingWall",Pt.hideHelp(),d(),si.uyoStartSurfaceEdit(),si.uyoAddMask(),$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-creating-new-outline").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("[Tap] around the area to exclude from decorating and back on the first point to finish, or [DELETE] to cancel",Yo)},this.patchFloorArea=function(){mobileVisualizerConfig.enableToolsFloorPatchAndMask&&$(".m-tool-button.mm-patch-floor-area").hasClass("mm-disabled")||(Qt="UYOEditingFloor",Pt.hideHelp(),d(),$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-creating-new-outline").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("[Tap] around the floor area and back on the first point to finish.",5e3),$(".m-current-product-details").hide(),si.patchFloorArea(function(){Qt="",$(".m-uyo-tools").hide(),he(function(){h(),Pt.updateTools(),Pt.updateCurrentProduct()})},function(){Pt.showInstruction(null)}))},this.maskFloorArea=function(){mobileVisualizerConfig.enableToolsFloorPatchAndMask&&$(".m-tool-button.mm-mask-floor-area").hasClass("mm-disabled")||(Pt.hideHelp(),Qt="UYOEditingFloor",d(),$(".m-current-product-details").hide(),fe(function(){$(".m-uyo-tools .m-uyo-tool-button").hide(),$(".m-uyo-tools .m-uyo-tool-button.mm-creating-new-outline").show(),$(".m-uyo-tools").show(),Pt.showInstructionFor("[Tap] around the area to exclude from decorating and back on the first point to finish",5e3),si.maskFloorArea(function(){Qt="",$(".m-uyo-tools").hide(),he(function(){h(),Pt.updateTools(),Pt.updateCurrentProduct()})},function(){Pt.showInstruction(null)})}))},this.closeFloorOrStairsPopup=function(){$(".m-floor-or-stairs-popup").hide(),jo&&Pt.showLandingContent(!0),Je(),Re()},this.hideFloorOrStairsPopup=function(){$(".m-floor-or-stairs-popup").hide()},this.setFloorOrStairsSelection=function(e){xt.closeFloorOrStairsPopup(),$(".m-floor-or-stairs-popup").hide(),Pt.showMessage("Loading Photo",!0),si.setFloorOrStairsSelection(e)},this.openEditingToolsPopup=function(){$(".m-editing-tools-popup .mm-add-wall-outline").hide(),mobileVisualizerConfig.enableWallOutlining&&$(".m-editing-tools-popup .mm-add-wall-outline").show(),$(".m-editing-tools-popup .mm-edit-wall-outline").hide(),Qe()>0&&$(".m-editing-tools-popup .mm-edit-wall-outline").show(),$(".m-editing-tools-popup .mm-mask-floor-area").show(),$(".m-editing-tools-popup .mm-mask-outline").hide(),mobileVisualizerConfig.enableWallOutlining&&Qe()>0&&($(".m-editing-tools-popup .mm-mask-floor-area").hide(),$(".m-editing-tools-popup .mm-mask-outline").show()),mobileVisualizerConfig.enableFloorPatchAndMask||($(".m-editing-tools-popup .mm-patch-floor-area").hide(),$(".m-editing-tools-popup .mm-mask-floor-area").hide()),$(".m-editing-tools-popup").show()},this.closeEditingToolsPopup=function(){$(".m-editing-tools-popup").hide()},this.saveRoom=function(){if("Pano"!=Zt&&(mobileVisualizer.isDecoratedFloor()||mobileVisualizer.isRug())){Pt.showMessageFor("Saving",2e3);var e=new Object;if(e.roomId=Zt,e.roomData=Co,"UYO"==Zt&&(io=!1),"UYO"==Zt){var t=.5;e.uyoData=JSON.parse(si.getUYOEditData()),e.uyoOriginalRoomImage=JSON.parse(si.getUYOOriginalRoomImage(t)),"Mannington"==mobileVisualizerConfigType&&mobileVisualizer.isStairsRoom()&&(e.uyoData.colourUYOStairsRiser=visualizerPluginConfig.colourUYOStairsRiser)}e.thumbnail=S(400,266).toDataURL("image/jpeg",.5),to.unshift(e);for(var o=0;oe&&--oo[o]:(oo.splice(o,1),t=!0,--o);Pt.updateQuickSelector(),Pt.updateRoomSelector(!0)},this.getSavedRooms=function(){return to},this.getThisSessionSavedUYORooms=function(){return oo},this.showQuickSelectorLastSavedUYORoom=function(){return io},this.getOCRReader=function(){return Wo},this.getLastPlacedProduct=function(){return ao},this.getLastPlacedFloor=function(){return so},this.getLastPlacedRug=function(){return co},this.editStairs=function(){xt.isDecoratedFloor()&&(lt(),Je(),si.editStairs())},this.isStairsRoom=function(){return!("Mannington"!=mobileVisualizerConfigType||!mobileVisualizerConfig.enableStairs||"Room99"!=Zt)||"UYO"==Zt&&vitStairsRoom},this.isDecoratedFloor=function(){if("Pano"==Zt)return!0;for(var e in Co){var t=Co[e];if("texture"==t.type&&null!=t.decoration)return!0}return!1},this.getNumFloors=function(){return je()},this.getNumWalls=function(){return Qe()},this.getNumTexturedWalls=function(){return We()},this.getNumDecoratedFloors=function(){if("Pano"==Zt)return 0;var e=0;for(var t in Co){var o=Co[t];"texture"==o.type&&o.gridName.indexOf("FLOOR")!=-1&&null!=o.decoration&&++e}return e},this.getNumDecoratedTexturedWalls=function(){if("Pano"==Zt)return 0;var e=0;for(var t in Co){var o=Co[t];"texture"==o.type&&o.gridName.indexOf("WALL")!=-1&&null!=o.decoration&&o.decoration.indexOf("#")==-1&&++e}return e},this.isStairsStockRoom=function(){return L()},this.isRug=function(){if("Pano"==Zt)return!1;for(var e in Co){var t=Co[e];if("texture"==t.type&&null!=t.rugDecoration)return!0}return!1},this.savePhoto=function(){ii.track("@SavePhotoStart"),Q(!0,function(e){$(".m-save-photo-popup-container img").attr("src",e.toDataURL("image/jpeg",1)),$(".m-save-photo-popup").show()})},this.savePhotoClose=function(){$(".m-save-photo-popup").hide()},this.exportOriginal=function(){var e=si.getOriginalScene();e.toBlob(function(e){saveAs(e,"My Original Room Photo.jpg")})},this.exportJPG=function(){function e(){var e=!0;mobileVisualizerConfig.noproductDetailsOnExportJPG&&(e=!1),Q(e,function(e){e.toBlob(function(e){saveAs(e,"My Room Image.jpg")},"image/jpeg",.9)})}return ii.track("@SavedJPG"),Pt.showMessageFor("Preparing your photo for download so you can share or email it to your friends",4e3,function(){e()}),!0},this.printPDF=function(){return ii.track("@PrintedPDF"),$(".m-export-pdf-frame").attr("src","mobile/exportpdf.html?print&"+mobileVisualizerStopCaching),!0},this.exportPDF=function(){return ii.track("@SavedPDF"),$(".m-export-pdf-frame").attr("src","mobile/exportpdf.html?"+mobileVisualizerStopCaching),!0},this.getExportPDFData=function(e){var t=new Object;Q(!0,function(o){t.sceneRender=o.toDataURL("image/jpeg",1),e(t)})},this.getCurRoomId=function(){return Zt},this.getCurUYORoomIsStock=function(){return eo},this.getProduct=function(e){return ve(e)},this.curRoomSupportsProductTypeSubType=function(e,t){if(null==Zt)return!0;if("Pano"==Zt)return"Carpet"!=e||"Rug"!=t;if(xt.isStairsRoom()){if("FlooringDirect"==mobileVisualizerConfigType)return"Carpet"==t;if("Mannington"==mobileVisualizerConfigType)return"SimpleStairs"==t;if("Demo"==mobileVisualizerConfigType&&"Runner"==e)return!0;if("StairsOnlyDemo"!=mobileVisualizerConfigType&&"HughMackay"!=mobileVisualizerConfigType&&("Carpet"!=e||"Carpet"==e&&"Rug"==t))return!1}if("Demo"==mobileVisualizerConfigType&&L()&&"Runner"==e)return!0;if("Demo"==mobileVisualizerConfigType&&!xt.isStairsRoom()&&"Runner"==e)return!1;var o=be(Zt);if(null==o)return!0;if(o.productTypesAllowed.indexOf("All")!=-1)return!0;var i=e;return""!=t&&t.indexOf("!")==-1&&(i+="-"+t),o.productTypesAllowed.indexOf(i)!=-1},this.setCameraHeight=function(e,t){ii.track("@SelectedHeight");var o=10,i=VUtils.GetQueryStringParam("height");null!=i&&(e=i,alert("Override person height to "+e+" inches (camera height is "+(e-o)+" inches)"));var r=.0254*(e-o);si.setAutoFindFloorCameraHeight(r),Y(!0)},this.switchLanguage=function(e){var t=location.href;t.indexOf("lang=")!=-1?t="hebrew"==e?t.replace("english","hebrew"):t.replace("hebrew","english"):t+=t.indexOf("?")==-1?"?lang="+e:"&lang="+e,location.href=t},this.linkToMainVisualizer=function(){"Mannington"==mobileVisualizerConfigType&&oi.linkToMainManningtonVD()},this.linkToHomepage=function(){null!=mobileVisualizerConfig.headerLink&&(ii.track("@Link","Homepage"),window.open(mobileVisualizerConfig.headerLink))},this.hideProductDetails=function(){return"HughMackay"==mobileVisualizerConfigType?void oi.showProductDetails(null):"VictoriaCarpets"==mobileVisualizerConfigType?void oi.showProductDetails(null):void 0},this.showProductDetails=function(){if(!mobileVisualizerConfig.noProductDetailLinks){if("HughMackay"==mobileVisualizerConfigType)return oi.showProductDetails(ao),void ii.track("@Link","HughMackayProductDetails");if("VictoriaCarpets"==mobileVisualizerConfigType)return oi.showProductDetails(ao),void ii.track("@Link","VictoriaCarpetsProductDetails");for(var e=te(),t=0;t
','
','
','
','
','
','
'],o=t[e];$("div").hasClass("m-3d-carpets")||$("body").prepend(''),$(".m-3d-carpets").html(o),$(".m-3d-carpets").show()},this.hide3DCarpet=function(){"undefined"!=typeof vit3DCarpetsDemo&&$(".m-3d-carpets").hide()},this.selectProduct=function(e,t){"undefined"!=typeof stantonCreateARugInfo&&(stantonCreateARugInfo.dummySelect?stantonCreateARugInfo.dummySelect=!1:stantonCreateARugInfo.overrideRender=!1);var o=ve(e);if(null!=o){if("BuyCarpet"==mobileVisualizerConfigType){var i=!1,r=!1,n=!1,a=M();if(null!=a&&(r=!0,o.baseName==N().baseName&&(n=!0)),void 0!=t&&(i=!0),!i&&Pt.selectRugSizePopup(o))return void Pt.closeProductSelector(function(){})}if("undefined"!=typeof vit3DCarpetsDemo)return"Carpet3DTest1"==e?xt.show3DCarpet(0):"Carpet3DTest2"==e?xt.show3DCarpet(1):"Carpet3DTest3"==e?xt.show3DCarpet(2):"Carpet3DTest4"==e?xt.show3DCarpet(3):"Carpet3DTest5"==e?xt.show3DCarpet(4):"Carpet3DTest6"==e?xt.show3DCarpet(5):"Carpet3DTest7"==e&&xt.show3DCarpet(6),void Pt.closeProductSelector();if(0)return alert("Stairs room decorating in development"),void finishedCallback();if(y(),"undefined"!=typeof vitRugMaker&&"UserCreatedRug"!=e&&"Carpet"==o.type&&"Rug"==o.subType)return void Pt.closeProductSelector(function(){yt(e)});if("Pano"==Zt&&o.subType.indexOf("Carpet")!=-1)return void Pt.showMessageFor("Pano 360 not yet available for carpets",3e3);mobileVisualizerConfig.showLastSelectedProduct&&("StantonCarpet"==mobileVisualizerConfigType?($(".m-last-selected-product").hide(),"UserCreatedRug"==o.assetRef&&($(".m-last-selected-product img").attr("src","mobile/config/"+mobileVisualizerConfigType+"/textures/jpg90/"+o.assetRef+"_c.jpg?"+Math.random()),$(".m-last-selected-product").show())):($(".m-last-selected-product img").attr("src","mobile/config/"+mobileVisualizerConfigType+"/samples/"+o.assetRef+".jpg"),$(".m-last-selected-product").show())),"StantonCarpet"==mobileVisualizerConfigType?ii.track("@SelectedProduct",o.type+"|"+o.subType+"|"+e):ii.track("@SelectedProduct",e),Pt.closeProductSelector(function(){if("Pano"==Zt)return no=o,Ae(no.sku),so=no,lo=no,void he(function(){Pt.updateTools(),Pt.updateCurrentProduct()});if("RunRug"==mobileVisualizerConfigType&&runrugFloorNotStairs)return uo=fo,ho=fo,Qt="WaitingForRugPlacement",void Pt.showInstructionFor("[Tap] to place the runner",2e3);if("Carpet"==o.type&&"Rug"==o.subType)return uo=o,ho=o,Qt="WaitingForRugPlacement",void("WhitneyKiosk"==mobileVisualizerConfigType?Pt.showInstructionFor("[Tap] on wall to place",2e3):Pt.showInstructionFor("[Tap] to place the rug",2e3));no=o;var e=!1;if(mobileVisualizerConfig.useTargets)return void le(Ro);if(D()&&"Carpet"!=no.type&&"Runner"!=no.type)for(var t in Co){var i=Co[t];if("texture"==i.type&&!F(t)){le(t);break}}else if(D())Qt="WaitingForFloorSelection",Pt.showInstructionFor("[Tap] to select floor or stairs",2e3);else if(L())for(var t in Co){var i=Co[t];if("texture"==i.type){le(t);break}}else if(xt.isStairsRoom())for(var t in Co){var i=Co[t];if("texture"==i.type){le(t);break}}else if(1==k().length){var t=k()[0];le(t)}else if(0==k().length)Qt="WaitingForFloorOrWallSelection";else if(!e&&je()+We()>1)Qt="WaitingForFloorOrWallSelection",0!=je()&&Ye(no)?Pt.showInstructionFor("[Tap] floor or wall to decorate",4e3):Pt.showInstructionFor("[Tap] wall to decorate",4e3);else if(1==je()||1==We())for(var t in Co){var i=Co[t];if("texture"==i.type){"Mannington"==mobileVisualizerConfigType&&(Qt="WaitingForFloorOrWallSelection"),le(t);break}}else je()>0?Qt="WaitingForFloorSelection":Pt.showInstructionFor("No floors or walls exist to decorate",2e3)})}},this.adjustRunnerLength=function(e){for(var t in Co){var o=Co[t];if("texture"==o.type&&null!=o.rugDecoration)return void(visualizerPluginConfig.runnerLengthInches+e>=24&&(visualizerPluginConfig.runnerLengthInches+=e,si.adjustedRunnerLength(o.id,function(){Pt.updateTools(),Pt.updateCurrentProduct()})))}},this.deleteRug=function(){for(var e in Co){var t=Co[e];if("texture"==t.type&&null!=t.rugDecoration)return t.rugDecoration=null,uo=null,co=null,void si.deleteRug(t.id,function(){Pt.updateTools(),Pt.updateCurrentProduct()})}},this.selectRotate=function(){if(Pt.hideHelp(),"Pano"==Zt)return yo=90-yo,void he(function(){Pt.updateTools(),Pt.updateCurrentProduct()});var e=0,t=0,o=null,i=null;for(var r in Co){var n=Co[r];"texture"==n.type&&(n.gridName.indexOf("FLOOR")!=-1?(null!=n.decoration&&(o=r),null!=n.rugDecoration&&(o=r,++t)):n.gridName.indexOf("WALL")!=-1&&null!=n.decoration&&(i=r))}0==xt.getNumDecoratedFloors()&&0==t&&0==xt.getNumDecoratedTexturedWalls()||(xt.getNumDecoratedFloors()>0&&xt.getNumDecoratedTexturedWalls()>0?(Qt="WaitingForRotateFloorOrWallSelection",Pt.showInstructionFor("[Tap] to rotate floor or wall",2e3)):0==xt.getNumDecoratedFloors()&&1==xt.getNumDecoratedTexturedWalls()?(me(i),ae()):0==xt.getNumDecoratedFloors()&&xt.getNumDecoratedTexturedWalls()>1?(Qt="WaitingForRotateFloorOrWallSelection",Pt.showInstructionFor("[Tap] to rotate wall",2e3)):xt.getNumDecoratedFloors()+t==1?null!=Co[o].decoration?me(o):de(o):(Qt="WaitingForRotateSelection",1==t?Pt.showInstructionFor("[Tap] to rotate floor or rug",2e3):Pt.showInstructionFor("[Tap] to rotate floor or stairs",2e3)))},this.toggleFilterItem=function(e,t){var o=Jt[e].indexOf(t);return o==-1?(Jt[e].push(t),vobj(Jt),!1):(Jt[e].splice(o,1),!0)},this.filterItemIsOn=function(e,t){return Jt[e].indexOf(t)!=-1},this.getRecentlyUsed=function(){return So},this.addToFavourites=function(){if(null!=ao){var e=ao.sku;if("undefined"==typeof vitRugMaker||"UserCreatedRug"!=e){To.indexOf(e)!=-1&&To.splice(To.indexOf(e),1),To.unshift(e);for(var t=24;To.length>t;)To.pop();VUtils.saveCookie(mobileVisualizerConfigType+"-MobileVisualizer-Favourites-"+mobileVisualizerConfig.savedFavouritesRef,JSON.stringify(To)),Pt.updateTools(),Pt.updateRecentyUsedAndFavourites()}}},this.getFavourites=function(){return To},this.canGoOnTargetArea=function(e){if(null==Ro)return!1;if("floor"==Co[Ro].surface){if(e.suitableFor.indexOf("floor")==-1)return!1}else if("wall"==Co[Ro].surface&&e.suitableFor.indexOf("wall")==-1)return!1;if("outside"==Co[Ro].where){if(e.suitableFor.indexOf("outside")==-1)return!1}else if("inside"==Co[Ro].where&&e.suitableFor.indexOf("inside")==-1)return!1;return!0},this.openPhonePhotoUploadQRCodePopup=function(e){function t(){if(r){if(i)return;$(".m-scan-qr-code-popup .mm-waiting").css("opacity","1.0"),setTimeout(t,800)}else{if(i)return;$(".m-scan-qr-code-popup .mm-waiting").css("opacity","0.0"),setTimeout(t,100)}r=!r}function o(){st("https://qr.viziserve.com/vphotouploaded.php?photocode="+Ko,function(e){return"true"==e?($(".m-scan-qr-code-popup .mm-waiting").css("opacity","1.0"),i=!0,$(".m-scan-qr-code-popup .mm-waiting").hide(),$(".m-scan-qr-code-popup .mm-found").show(),void $(".m-scan-qr-code-popup .mm-load-my-photo").show()):void(Jo&&setTimeout(o,2e3))})}void 0==e&&(e=Xo),Xo=e,mobileVisualizerConfig.enableStairs?nt(Xo):nt(),$(".m-landing-content-container").hide(),$(".m-scan-qr-code-popup .mm-waiting").show(),$(".m-scan-qr-code-popup .mm-found").hide(),$(".m-scan-qr-code-popup .mm-load-my-photo").hide(),$(".m-scan-qr-code-popup .mm-title").hide(),mobileVisualizerConfig.enableStairs?"Floor"==e?$(".m-scan-qr-code-popup .mm-title.mm-floor").show():$(".m-scan-qr-code-popup .mm-title.mm-stairs").show():$(".m-scan-qr-code-popup .mm-title.mm-just-floor").show(),$(".m-scan-qr-code-popup").show(),Jo=!0,o();var i=!1,r=!0;t()},this.closeQRCodePopup=function(){$(".m-landing-content-container").show(),$(".m-scan-qr-code-popup").hide(),Jo=!1},this.loadQRCodeUploadedPhoto=function(){lt();var e="https://qr.viziserve.com/vgetphoto.php?photocode="+Ko;K(e,Xo)},this.getShowCurrentDetails=function(){return!Ct()||!!Fo},this.canUseBeforeAfter=function(){return wt()},this.closeRugSizePopup=function(){$(".m-rug-size-popup").hide()},this.enteredRugSizeOK=function(){const e=18,t=72;var o=$(".m-rug-size-popup .mm-dimension-width").val(),i=$(".m-rug-size-popup .mm-dimension-height").val();if(""==o||""==i)return Pt.showMessageFor("Please enter dimensions for both the width and length",2e3),!1;var o=parseInt(o),i=parseInt(i);if(ot||it)return Pt.showMessageFor("Please enter rug dimensions in the range 18 to 72 inches",2e3),!1;var r=ve(Zo);return St(r.assetRef,o,i,function(){sku="UserCreatedRug",r=ve(sku),r.width=25*o,r.height=25*i,xt.selectProduct("UserCreatedRug")}),!0},this.selectTarget=function(e){Ro=e,"texture"==Co[Ro].type?mobileVisualizerConfig.sidebarSelector?mobileVisualizerGUI.openSidebarProductSelector():mobileVisualizerGUI.openProductSelector():mobileVisualizerGUI.openPaintSelector()},this.updateTargets=function(e){$t(e)},this.decorateWithUserTexture=function(){function e(e){li||($("input[type=file].v-hidden-user-texture-load-trigger-button").change(function(t){var o=t.target.files[0].name;VUtils.loadImageFile(t.target.files[0],function(t){e(t,o)}),this.value=null}),li=!0),$("input[type=file].v-hidden-user-texture-load-trigger-button").trigger("click")}function t(e,t,o,i){var r=4;null!=VUtils.GetQueryStringParam("scale")&&(r=parseFloat(VUtils.GetQueryStringParam("scale"))),alert("scale="+r);var n=document.createElement("canvas");n.width=e.width/r,n.height=e.height/r,context.drawImage(e,0,0,e.width,e.height,0,0,n.width,n.height);var a={base64Data:n.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),folder:t,filename:o};$.post("vsavebase64.php",a,function(e){null!=i&&(e.indexOf("ERROR")!=-1?(alert("savePNGFile() Error:"+e),i(!1)):i(!0))})}function o(e,t,o,i,r){var n=.25;null!=VUtils.GetQueryStringParam("scale")&&(n=parseFloat(VUtils.GetQueryStringParam("scale"))),alert("scale="+n);var a=document.createElement("canvas");a.width=e.width*n,a.height=e.height*n,a.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,a.width,a.height);var s={base64Data:a.toDataURL("image/jpeg",i).replace(/^data:image\/(png|jpeg);base64,/,""),folder:t,filename:o};$.post("vsavebase64.php",s,function(e){null!=r&&(e.indexOf("ERROR")!=-1?(alert("saveJPGFile() Error:"+e),r(!1)):r(!0))})}e(function(e,t){mobileVisualizerGUI.showMessage("Preparing For Rendering");var i="TestUserTexture-"+Math.random(),r="mobile/config/"+mobileVisualizerConfigType+"/textures",n=r+"/"+i+"_c.jpg";o(e,r,n,1,function(e){return e?(Vt.products[0].name==t,Vt.products[0].savePhotoName=t,Vt.products[0].savePhotoCode="",Vt.products[0].assetRef=i,Vt.products[0].assetPath="",Vt.products[0].assetFileExt="jpg",Vt.products[0].normalAssetRef="FLAT_NORMAL",Vt.products[0].type="Carpet",Vt.products[0].lighting="matt",Vt.products[0].suitableFor=["inside","wall","floor"],Vt.products[0].forcePattern="",void xt.selectProduct(Vt.products[0].sku)):void alert("IMAGE FILE TOO LARGE")})})}}var QRCode;!function(){function e(e){this.mode=u.MODE_8BIT_BYTE,this.data=e,this.parsedData=[];for(var t=[],o=0,i=this.data.length;i>o;o++){var r=this.data.charCodeAt(o);r>65536?(t[0]=240|(1835008&r)>>>18,t[1]=128|(258048&r)>>>12,t[2]=128|(4032&r)>>>6,t[3]=128|63&r):r>2048?(t[0]=224|(61440&r)>>>12,t[1]=128|(4032&r)>>>6,t[2]=128|63&r):r>128?(t[0]=192|(1984&r)>>>6,t[1]=128|63&r):t[0]=r,this.parsedData=this.parsedData.concat(t)}this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function t(e,t){this.typeNumber=e,this.errorCorrectLevel=t,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}function o(e,t){if(void 0==e.length)throw new Error(e.length+"/"+t);for(var o=0;o=r;r++){var a=0;switch(t){case c.L:a=p[r][0];break;case c.M:a=p[r][1];break;case c.Q:a=p[r][2];break;case c.H:a=p[r][3]}if(a>=i)break;o++}if(o>p.length)throw new Error("Too long data");return o}function l(e){var t=encodeURI(e).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return t.length+(t.length!=e?3:0)}e.prototype={getLength:function(){return this.parsedData.length},write:function(e){for(var t=0,o=this.parsedData.length;o>t;t++)e.put(this.parsedData[t],8)}},t.prototype={addData:function(t){var o=new e(t);this.dataList.push(o),this.dataCache=null},isDark:function(e,t){if(0>e||this.moduleCount<=e||0>t||this.moduleCount<=t)throw new Error(e+","+t);return this.modules[e][t]},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(e,o){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var i=0;i=7&&this.setupTypeNumber(e),null==this.dataCache&&(this.dataCache=t.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,o)},setupPositionProbePattern:function(e,t){for(var o=-1;7>=o;o++)if(!(-1>=e+o||this.moduleCount<=e+o))for(var i=-1;7>=i;i++)-1>=t+i||this.moduleCount<=t+i||(this.modules[e+o][t+i]=o>=0&&6>=o&&(0==i||6==i)||i>=0&&6>=i&&(0==o||6==o)||o>=2&&4>=o&&i>=2&&4>=i)},getBestMaskPattern:function(){for(var e=0,t=0,o=0;8>o;o++){this.makeImpl(!0,o);var i=d.getLostPoint(this);(0==o||e>i)&&(e=i,t=o)}return t},createMovieClip:function(e,t,o){var i=e.createEmptyMovieClip(t,o),r=1;this.make();for(var n=0;n=n;n++)for(var a=-2;2>=a;a++)this.modules[i+n][r+a]=-2==n||2==n||-2==a||2==a||0==n&&0==a}},setupTypeNumber:function(e){for(var t=d.getBCHTypeNumber(this.typeNumber),o=0;18>o;o++){var i=!e&&1==(1&t>>o);this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3]=i}for(var o=0;18>o;o++){var i=!e&&1==(1&t>>o);this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)]=i}},setupTypeInfo:function(e,t){for(var o=this.errorCorrectLevel<<3|t,i=d.getBCHTypeInfo(o),r=0;15>r;r++){var n=!e&&1==(1&i>>r);6>r?this.modules[r][8]=n:8>r?this.modules[r+1][8]=n:this.modules[this.moduleCount-15+r][8]=n}for(var r=0;15>r;r++){var n=!e&&1==(1&i>>r);8>r?this.modules[8][this.moduleCount-r-1]=n:9>r?this.modules[8][15-r-1+1]=n:this.modules[8][15-r-1]=n}this.modules[this.moduleCount-8][8]=!e},mapData:function(e,t){for(var o=-1,i=this.moduleCount-1,r=7,n=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;2>s;s++)if(null==this.modules[i][a-s]){var l=!1;n>>r));var u=d.getMask(t,i,a-s);u&&(l=!l),this.modules[i][a-s]=l,r--,-1==r&&(n++,r=7)}if(i+=o,0>i||this.moduleCount<=i){i-=o,o=-o;break}}}},t.PAD0=236,t.PAD1=17,t.createData=function(e,o,n){for(var a=i.getRSBlocks(e,o),s=new r,l=0;l8*c)throw new Error("code length overflow. ("+s.getLengthInBits()+">"+8*c+")");for(s.getLengthInBits()+4<=8*c&&s.put(0,4);0!=s.getLengthInBits()%8;)s.putBit(!1);for(;!(s.getLengthInBits()>=8*c)&&(s.put(t.PAD0,8),!(s.getLengthInBits()>=8*c));)s.put(t.PAD1,8);return t.createBytes(s,a)},t.createBytes=function(e,t){for(var i=0,r=0,n=0,a=new Array(t.length),s=new Array(t.length),l=0;l=0?p.get(g):0}}for(var b=0,m=0;mm;m++)for(var l=0;lm;m++)for(var l=0;l=0;)t^=d.G15<=0;)t^=d.G18<>>=1;return t},getPatternPosition:function(e){return d.PATTERN_POSITION_TABLE[e-1]},getMask:function(e,t,o){switch(e){case m.PATTERN000:return 0==(t+o)%2;case m.PATTERN001:return 0==t%2;case m.PATTERN010:return 0==o%3;case m.PATTERN011:return 0==(t+o)%3;case m.PATTERN100:return 0==(Math.floor(t/2)+Math.floor(o/3))%2;case m.PATTERN101:return 0==t*o%2+t*o%3;case m.PATTERN110:return 0==(t*o%2+t*o%3)%2;case m.PATTERN111:return 0==(t*o%3+(t+o)%2)%2;default:throw new Error("bad maskPattern:"+e)}},getErrorCorrectPolynomial:function(e){for(var t=new o([1],0),i=0;e>i;i++)t=t.multiply(new o([1,h.gexp(i)],0));return t},getLengthInBits:function(e,t){if(t>=1&&10>t)switch(e){case u.MODE_NUMBER:return 10;case u.MODE_ALPHA_NUM:return 9;case u.MODE_8BIT_BYTE:return 8;case u.MODE_KANJI:return 8;default:throw new Error("mode:"+e)}else if(27>t)switch(e){case u.MODE_NUMBER:return 12;case u.MODE_ALPHA_NUM:return 11;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 10;default:throw new Error("mode:"+e)}else{if(!(41>t))throw new Error("type:"+t);switch(e){case u.MODE_NUMBER:return 14;case u.MODE_ALPHA_NUM:return 13;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 12;default:throw new Error("mode:"+e)}}},getLostPoint:function(e){for(var t=e.getModuleCount(),o=0,i=0;t>i;i++)for(var r=0;t>r;r++){for(var n=0,a=e.isDark(i,r),s=-1;1>=s;s++)if(!(0>i+s||i+s>=t))for(var l=-1;1>=l;l++)0>r+l||r+l>=t||(0!=s||0!=l)&&a==e.isDark(i+s,r+l)&&n++;n>5&&(o+=3+n-5)}for(var i=0;t-1>i;i++)for(var r=0;t-1>r;r++){var u=0;e.isDark(i,r)&&u++,e.isDark(i+1,r)&&u++,e.isDark(i,r+1)&&u++,e.isDark(i+1,r+1)&&u++,(0==u||4==u)&&(o+=3)}for(var i=0;t>i;i++)for(var r=0;t-6>r;r++)e.isDark(i,r)&&!e.isDark(i,r+1)&&e.isDark(i,r+2)&&e.isDark(i,r+3)&&e.isDark(i,r+4)&&!e.isDark(i,r+5)&&e.isDark(i,r+6)&&(o+=40);for(var r=0;t>r;r++)for(var i=0;t-6>i;i++)e.isDark(i,r)&&!e.isDark(i+1,r)&&e.isDark(i+2,r)&&e.isDark(i+3,r)&&e.isDark(i+4,r)&&!e.isDark(i+5,r)&&e.isDark(i+6,r)&&(o+=40);for(var c=0,r=0;t>r;r++)for(var i=0;t>i;i++)e.isDark(i,r)&&c++;var m=Math.abs(100*c/t/t-50)/5;return o+=10*m}},h={glog:function(e){if(1>e)throw new Error("glog("+e+")");return h.LOG_TABLE[e]},gexp:function(e){for(;0>e;)e+=255;for(;e>=256;)e-=255;return h.EXP_TABLE[e]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},f=0;8>f;f++)h.EXP_TABLE[f]=1<f;f++)h.EXP_TABLE[f]=h.EXP_TABLE[f-4]^h.EXP_TABLE[f-5]^h.EXP_TABLE[f-6]^h.EXP_TABLE[f-8];for(var f=0;255>f;f++)h.LOG_TABLE[h.EXP_TABLE[f]]=f;o.prototype={get:function(e){return this.num[e]},getLength:function(){return this.num.length},multiply:function(e){for(var t=new Array(this.getLength()+e.getLength()-1),i=0;ia;a++)for(var s=o[3*a+0],l=o[3*a+1],u=o[3*a+2],c=0;s>c;c++)n.push(new i(l,u));return n},i.getRsBlockTable=function(e,t){switch(t){case c.L:return i.RS_BLOCK_TABLE[4*(e-1)+0];case c.M:return i.RS_BLOCK_TABLE[4*(e-1)+1];case c.Q:return i.RS_BLOCK_TABLE[4*(e-1)+2];case c.H:return i.RS_BLOCK_TABLE[4*(e-1)+3];default:return}},r.prototype={get:function(e){var t=Math.floor(e/8);return 1==(1&this.buffer[t]>>>7-e%8)},put:function(e,t){for(var o=0;t>o;o++)this.putBit(1==(1&e>>>t-o-1))},getLengthInBits:function(){return this.length},putBit:function(e){var t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var p=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]],g=function(){var e=function(e,t){this._el=e,this._htOption=t};return e.prototype.draw=function(e){function t(e,t){var o=document.createElementNS("http://www.w3.org/2000/svg",e);for(var i in t)t.hasOwnProperty(i)&&o.setAttribute(i,t[i]);return o}var o=this._htOption,i=this._el,r=e.getModuleCount();Math.floor(o.width/r),Math.floor(o.height/r),this.clear();var n=t("svg",{viewBox:"0 0 "+String(r)+" "+String(r),width:"100%",height:"100%",fill:o.colorLight});n.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink"),i.appendChild(n),n.appendChild(t("rect",{fill:o.colorDark,
width:"1",height:"1",id:"template"}));for(var a=0;r>a;a++)for(var s=0;r>s;s++)if(e.isDark(a,s)){var l=t("use",{x:String(a),y:String(s)});l.setAttributeNS("http://www.w3.org/1999/xlink","href","#template"),n.appendChild(l)}},e.prototype.clear=function(){for(;this._el.hasChildNodes();)this._el.removeChild(this._el.lastChild)},e}(),b="svg"===document.documentElement.tagName.toLowerCase(),v=b?g:n()?function(){function e(){this._elImage.src=this._elCanvas.toDataURL("image/png"),this._elImage.style.display="block",this._elCanvas.style.display="none"}function t(e,t){var o=this;if(o._fFail=t,o._fSuccess=e,null===o._bSupportDataURI){var i=document.createElement("img"),r=function(){o._bSupportDataURI=!1,o._fFail&&_fFail.call(o)},n=function(){o._bSupportDataURI=!0,o._fSuccess&&o._fSuccess.call(o)};return i.onabort=r,i.onerror=r,i.onload=n,void(i.src="data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==")}o._bSupportDataURI===!0&&o._fSuccess?o._fSuccess.call(o):o._bSupportDataURI===!1&&o._fFail&&o._fFail.call(o)}if(this._android&&this._android<=2.1){var o=1/window.devicePixelRatio,i=CanvasRenderingContext2D.prototype.drawImage;CanvasRenderingContext2D.prototype.drawImage=function(e,t,r,n,a,s,l,u){if("nodeName"in e&&/img/i.test(e.nodeName))for(var c=arguments.length-1;c>=1;c--)arguments[c]=arguments[c]*o;else"undefined"==typeof u&&(arguments[1]*=o,arguments[2]*=o,arguments[3]*=o,arguments[4]*=o);i.apply(this,arguments)}}var r=function(e,t){this._bIsPainted=!1,this._android=a(),this._htOption=t,this._elCanvas=document.createElement("canvas"),this._elCanvas.width=t.width,this._elCanvas.height=t.height,e.appendChild(this._elCanvas),this._el=e,this._oContext=this._elCanvas.getContext("2d"),this._bIsPainted=!1,this._elImage=document.createElement("img"),this._elImage.style.display="none",this._el.appendChild(this._elImage),this._bSupportDataURI=null};return r.prototype.draw=function(e){var t=this._elImage,o=this._oContext,i=this._htOption,r=e.getModuleCount(),n=i.width/r,a=i.height/r,s=Math.round(n),l=Math.round(a);t.style.display="none",this.clear();for(var u=0;r>u;u++)for(var c=0;r>c;c++){var m=e.isDark(u,c),d=c*n,h=u*a;o.strokeStyle=m?i.colorDark:i.colorLight,o.lineWidth=1,o.fillStyle=m?i.colorDark:i.colorLight,o.fillRect(d,h,n,a),o.strokeRect(Math.floor(d)+.5,Math.floor(h)+.5,s,l),o.strokeRect(Math.ceil(d)-.5,Math.ceil(h)-.5,s,l)}this._bIsPainted=!0},r.prototype.makeImage=function(){this._bIsPainted&&t.call(this,e)},r.prototype.isPainted=function(){return this._bIsPainted},r.prototype.clear=function(){this._oContext.clearRect(0,0,this._elCanvas.width,this._elCanvas.height),this._bIsPainted=!1},r.prototype.round=function(e){return e?Math.floor(1e3*e)/1e3:e},r}():function(){var e=function(e,t){this._el=e,this._htOption=t};return e.prototype.draw=function(e){for(var t=this._htOption,o=this._el,i=e.getModuleCount(),r=Math.floor(t.width/i),n=Math.floor(t.height/i),a=['