var windowWidth=$(window).width(),windowHeight=$(window).height();function displayOverlay(){$(".dialog").each(function(){if($(this).css("z-index")>0&&"none"!=$(this).css("display"))return $(this).parents(".dialog").show(),$(".overlay").show(),!1})}function loadDTs(){$.ajax({url:"/custom-tools/des-dt-server.aspx?IDD="+designID+"&IDDT="+designTemplateID,cache:!1,success:function(o){$("#printSide").html(o)}})}function popout(o){mmClose(!1,this),$(o).fadeIn()}function openOptionDialog(o){mmClose(!1,o),$(".overlay").fadeIn("fast"),$(o).addClass("displayBlock").removeClass("displayNone")}function openToolsDialog(o){mmClose(!1,o),$(o).addClass("designerPage__leftColumn--show"),$(".overlay").fadeIn("fast")}function loadColours(){$.ajax({url:"/custom-tools/des-colour-server.aspx?PID="+productID+"&PMID="+productionMethodID,cache:!1,success:function(o){""!==o&&($("#colours").html(o),$("#colours a").length>0&&0==productSizeID&&(document.getElementById("OOSColourID"+productColourID)?(productColourID=document.getElementsByName("availableColourID")[0].value,loadSizes()):document.getElementById("availableColourID"+productColourID)||disableBuyBtn("Sorry, the selected colour has been discontinued for this product")))}})}function loadPMs(){$.ajax({url:"/custom-tools/des-productionmethod-server-2.aspx?PID="+productID+"&PMID="+productionMethodID,cache:!1,success:function(o){$(".designerTools__printMethod").html(o)}})}function changePM(o){$(".zoomIn").off(),productionMethodID!=o&&(dirtyPreview(!0),makeDirty,productionMethodID=o,$("#currentPrintType").html($("#printType"+productionMethodID).html()),$(".PMIcon").attr("src","/t-shirt-studio-artwork/designer/tools/print-option-"+o+".png"),previewLoading(),$.ajax({url:"/designertools/updateproductionmethod.aspx?IDP="+productID+"&IDD="+designID+"&IDPM="+o,cache:!1,success:function(o){var e=o.split("-");templateThemeID=e[0],designTemplateID=e[1],loadDTs(),loadDesignTools(!0),loadColours()}}))}function loadDesignTools(o){$.ajax({url:"/custom-tools/des-tool-server.aspx?DID="+designID+"&DTID="+designTemplateID+"&PID="+productID+"&PMID="+productionMethodID,cache:!1,success:function(e){$("#customTools").html(e),layoutID=$("#currentLayoutID").text(),showLayouts(),loadLayouts(layoutCatID),syncUpload(),$('[name="cleanText"]').val(""),addPlaceHolders(),o||preview()}})}function changeTT(vIDTT){0==arguments.length&&(vIDTT=$("#mugPrintPositionSelect").val()),$(".zoomIn").off(),templateThemeID!=vIDTT&&$.ajax({url:"/designertools/updateTemplateTheme.aspx?IDD="+designID+"&IDTTO="+templateThemeID+"&IDTTN="+vIDTT+"&IDP="+productID+"&IDPM="+productionMethodID,cache:!1,success:function(res){eval("dirtyDT.DT"+res+" = "+Math.random()),designTemplateID=res,mainViewIndex=0,loadViews(),templateThemeID=vIDTT,loadDTs(),loadMobileDTs(),loadDesignTools(),makeDirtyIfEdit()}})}function loadLayouts(o){layoutCatID=o,$.ajax({url:"/custom-tools/des-layout-server2.aspx?PMID="+productionMethodID+"&DTID="+designTemplateID+"&PID="+productID+"&CID="+o,cache:!1,success:function(o){$("#myLayouts").html(o)}})}function showLayouts(){$.ajax({url:"/custom-tools/des-layout-category-server.aspx?PMID="+productionMethodID+"&DTID="+designTemplateID+"&PID="+productID+"&CID="+layoutCatID,cache:!1,success:function(o){$("#layoutCategory").html(o)}})}function loadAssets(o,e){$.ajax({url:"/custom-tools/des-session-asset-server2.aspx?LID="+e+"&EID="+o+"&DTID="+designTemplateID+"&DID="+designID,cache:!1,success:function(e){$("#sessionAssets"+o).html(e),Modernizr.filereader||($("#fileupload"+o).attr("onclick","return false;"),$("#uploadBox").hide(),$("#sessionAssets"+o).append(""+"Sorry, this feature is only available in Internet Explorer version 10 and above, Firefox, Chrome and Safari."+""))}})}function imageAdd(o,e,t){openOptionDialog("#sessionAssetContainer"+o)}function resizeImg(o,e){var t;void 0===e&&(e=!1),(objQ=$(o)).removeClass("landscape portrait"),t=o.height/o.width$varInsertHere$' from My Pictures at TShirt Studio? (This will not affect any products you have designed using this image)",e))&&$.ajax({url:"/custom-tools/des-session-asset-update.aspx?IDSA="+o+"&ACT=D",cache:!1,success:function(){$(".SA"+o).parent().remove()}}),closeWindow("toolMenu")}function rotateImage(o,e,t){makeDirty(),previewLoading(),$.ajax({url:"/designerTools/RotateDesignUpload.aspx?IDD="+designID+"&IDE="+o+"&IDDT="+e+"&CW="+t,cache:!1,success:function(){loadImageCrop(o,e),preview()}}),mmClose()}function uploadComplete(o,e){makeDirty(),designTemplateID==e&&(0!=slickUploadFileID?window.location.hostname&&("new.tshirtstudio"==window.location.hostname.substring(0,window.location.hostname.lastIndexOf("."))?$("#addImage"+o).attr("src","https://testsessionassets.blob.core.windows.net/"+sessionID+"/"+slickUploadFileID+"-"+sessionID+"x200.png"+cloudToken+"&R="+Math.random()):$("#addImage"+o).attr("src","https://sessionassets.blob.core.windows.net/"+sessionID+"/"+slickUploadFileID+"-"+sessionID+"x200.png"+cloudToken+"&R="+Math.random())):$("#addImage"+o).attr("src","/showUploadThumb.aspx?ID_E="+o+"&ID_DT="+e+"&ID_D="+designID+"&mH=100&mW=100&R="+Math.random()),$("#imgToolBtnCtr"+o).html('edit"),loadImageCrop(o,e)),preview()}$(window).resize(function(){$(".overlay").hide(),$(window).width()>600?($("#customTools").show(),$("#colours").show(),$(".dialog").each(function(){if($(this).css("z-index")>0&&"none"!=$(this).css("display")&&("customTools"!=$(this).attr("id")||"colours"!=$(this).attr("id")))return $(".overlay").show(),!1})):displayOverlay()});var uploads=[],preventClose=!1;function doUpload(o,e){$.each($("#fileupload"+o)[0].files,function(t,s){var a=guid();uploads.push({uid:a,filename:s.name}),addSA(a,s.name);var n=new FormData;n.append("fileToUpload",s);var r=new XMLHttpRequest;r.upload.addEventListener("progress",function(o){ulProgress(o,a)},!1),r.addEventListener("load",function(t){ulComplete(t,a,e,o)},!1),r.addEventListener("error",function(o){ulFailed(o,a)},!1),r.addEventListener("abort",function(o){ulCanceled(o,a)},!1),r.open("POST","/imageupload/Uploadhandler.ashx"),r.send(n)}),$("#fileupload"+o).wrap("