$(document).ready(function(){function l(){var n=$("#event-type-container");a()?n.removeClass("hide").slideDown():n.slideUp(400,"swing",function(){n.addClass("hide")})}function o(){var n=$("#event-name-container");v()?n.removeClass("hide").slideDown():($("#BasicInfo_EventName").val(""),n.slideUp(400,"swing",function(){n.addClass("hide")}))}function s(){var n=$("#copy-shipping-values").prop("checked");n?(e(),$.each($("#checkout-shipping-address-container input, #checkout-shipping-address-container select"),function(){i($(this))}),$("#checkout-billing-details input").prop("readonly",!0),$("#checkout-billing-details select").prop("disabled",!0),$("#checkout-billing-details").addClass("hide")):($("#checkout-billing-details input").prop("readonly",!1),$("#checkout-billing-details select").prop("disabled",!1),$("#checkout-billing-details").removeClass("hide"))}function tt(){var t=$(this),i=t.val(),n=$("#"+t.data("update-target"));n.find(".shipping-state-option").addClass("hide");i==="US"?n.children('.shipping-state-option[data-country="US"]').removeClass("hide"):i==="CA"?n.children('.shipping-state-option[data-country="CA"]').removeClass("hide"):n.children('.shipping-state-option[data-country="other"]').removeClass("hide");g()}function d(){$("#paypal-button-container").html("");var t=$("#Payment_Balance").val(),i=$("#Payment_Subtotal").val(),r=$("#Payment_Tax").val(),u=$("#Payment_Shipping").val(),f=$("#Payment_Promo").val(),n=$("#paypal_env").val();console.log(n);paypal.Button.render({env:n,style:{layout:"horizontal",size:"responsive",shape:"rect",color:"silver"},funding:{allowed:[paypal.FUNDING.CARD],disallowed:[]},commit:!0,client:{sandbox:"Ad0uSJYdjSmEeNJP98W42ZHi7tGys_SuyOMHH0Cqw6h6qxh1YCE0hLT73MjLA2WD1jbUWHDlnJQ5gBPN",production:"AUC4Ev8CjqU_-9fkWZevRyfTfiY440cJ1JUqeWCd35zrMN-URWikIGDcMUP5bIaH9bvWnmMJyFmhnV8X"},payment:function(n,e){return e.payment.create({payment:{transactions:[{amount:{total:t,currency:"USD",details:{subtotal:i,tax:r,shipping:u,discount:f}},description:"ºÚÁÏÍø Purchase"}]}})},onAuthorize:function(n,t){return t.payment.execute().then(function(){$.ajax({url:"/checkout/paypal-start",data:n,type:"POST",success:function(n){window.location=n}})})}},"#paypal-button-container")}function g(){let n=$("#ShippingAddress_Country").val()==="US";$('input[name="paymenttype"]').prop("checked","");n?($("#checkout-payment-options .payment-option").removeClass("hide"),$("#international-payment-option-text").addClass("hide")):($(".sezzle-option, .credit-card-option").addClass("hide"),$(".paypal-option, .gift-card-option").removeClass("hide"),$("#international-payment-option-text").removeClass("hide"));$('.payment-option:not(.hide) input[name="paymenttype"]').first().click()}function nt(n){n&&($element=$(n),$element&&$("html, body").animate({scrollTop:$element.offset().top-200},500))}var c=$('input[name="__RequestVerificationToken"]').val(),e,a,v,i,n,y,p,t,h,ut,k,r,u;const f=$("#phone-order-promise-date");$(".panel-heading h4").on("click",function(n){var t=$(this);t.parents(".panel").children(".panel-collapse").hasClass("in")&&n.stopPropagation();setTimeout(function(){theOffset=t.offset();$("body,html").animate({scrollTop:theOffset.top-100})},310)});$(".panel").on("show.bs.collapse",function(n){var r=$(this),t=r.data("step"),i=$("#checkout-container-basics .checkout-step-status").hasClass("complete"),u=$("#checkout-container-shipping .checkout-step-status").hasClass("complete");t!==3||i&&u||(n.preventDefault(),$.sticky("You must complete steps 1 & 2 first",{classList:"error"}));t!==2||i||(n.preventDefault(),$.sticky("You must complete step 1 first",{classList:"error"}))});$("#checkout-container").on("keypress change","#checkout-shipping-address-container input, #checkout-shipping-address-container select",function(){$("#copy-shipping-values").prop("checked")&&(i($(this)),$(this).prop("id")==="ShippingAddress_Country"&&e())});e=function(){var t=$("#ShippingAddress_Country").val(),n=$("#BillingAddress-address-state");n.find(".shipping-state-option").addClass("hide");t==="US"?n.children('.shipping-state-option[data-country="US"]').removeClass("hide"):t==="CA"?n.children('.shipping-state-option[data-country="CA"]').removeClass("hide"):n.children('.shipping-state-option[data-country="other"]').removeClass("hide")};$("#checkout-container").on("change","#copy-shipping-values",function(){s()});$("#checkout-container").on("change","#check-subscribe",function(){$("#BasicInfo_Subscribe").val($("#check-subscribe").prop("checked"))});$("#checkout-container").on("change","#ShippingAddress_State",l);$("#checkout-container").on("change","#ShippingAddress_State",o);$("#checkout-container").on("change","#BasicInfo_EventType",o);a=function(){return t()&&$("#cart-has-dress").val()==="true"};v=function(){var n=$("#BasicInfo_EventType").val();return(n==="Homecoming"||n==="Prom"||n==="Winter Formal")&&t()&&$("#cart-has-dress").val()=="true"};i=function(n){var t=n.data("property"),i=n.val(),r;(t!="Country"||t=="Country"&&(i=="US"||i=="CA"))&&(r=$("#BillingAddress_"+t),r.val(i))};$("#checkout-container").on("click",".checkout-button.next",function(){var n=$(this),t=$("#"+n.data("form-name"));t.validate();t.valid()&&($("#shipping-address-validated").val()==="true"?(t.find("input, select").removeAttr("disabled"),$.post("/checkout/save-form/"+n.data("step"),t.serialize(),function(){}).done(function(t){if(n.data("update-section")&&it(n.data("update-section"),n.data("update-target")),n.data("step")===1){t.Data.Shipping.UseEstimatedShippingDates==!0?($("#checkout-shipping-calendar").hide(),$("#shipping-options-container").removeClass("col-md-6").addClass("col-md-12")):($("#checkout-shipping-calendar").show(),$("#shipping-options-container").removeClass("col-md-12").addClass("col-md-6"));k(t.Data.Shipping.MinimumNeedDateString);w($("#Shipping_NeedDate").val());let n=$("#Payment_CardholderName");n&&n.val().length==0&&n.val($("#BasicInfo_FirstName").val()+" "+$("#BasicInfo_LastName").val())}b(n.data("target-panel"),n.data("home-panel"),!0);window._loq=window._loq||[];n.data("target-panel")=="checkout-container-shipping"?window._loq.push(["tag","checkout/shipping"]):n.data("target-panel")=="checkout-container-payment"&&(window._loq.push(["tag","checkout/payment"]),$("#ShippingAddress_Country").val()=="US"?$(".sezzle-option").show():$(".sezzle-option").hide())})):y())});y=function(){var i=$("#ShippingAddress_Address1").val(),t=$("#ShippingAddress_Address2").val(),r=$("#ShippingAddress_City").val(),u=$("#ShippingAddress_State").val(),f=$("#ShippingAddress_Zip").val(),e=$("#ShippingAddress_Country").val(),o="/checkout/validate-address?street="+encodeURI(i+" "+t)+"&city="+encodeURI(r)+"&state="+encodeURI(u)+"&zip="+encodeURI(f)+"&country="+encodeURI(e);$.get(o,function(e){if(e.Status===0){n=e.AddressCandidates;var o=i;t.length>0&&(o+=""+t);o+=""+r+" "+u+" "+f;$("#submitted-address").html(o);p();$("#validate-shipping-address-modal").modal({show:!0,backdrop:"static",keyboard:!1})}else $("#shipping-address-validated").val("true"),$("#checkout-submit-basic").click()})};p=function(){for(var i,r=$("#suggested-addresses"),t=0;tSuggested Address<\/h4>'+n[t].Street+""+n[t].Region+'<\/div>Use this Address<\/button><\/div>',r.append(i)};$("#checkout-container").on("click",".confirm-shipping-address",function(){var r=$(this),u=r.data("use-address")==="suggested",t;u&&(t=r.data("index"),$("#ShippingAddress_Address1").val(n[t].Street),$("#ShippingAddress_Address2").val(""),$("#ShippingAddress_City").val(n[t].City),$("#ShippingAddress_State").val(n[t].State),$("#ShippingAddress_Zip").val(n[t].Postcode+"-"+n[t].PostcodeExtension),$("#copy-shipping-values").prop("checked")&&$.each($("#checkout-shipping-address-container input, #checkout-shipping-address-container select"),function(){i($(this))}));$("#shipping-address-validated").val("true");$("#validate-shipping-address-modal").modal("toggle");$("#checkout-submit-basic").click()});$("#checkout-container").on("click","#payment-complete-order",function(){var n=$(this),t;if(n.addClass("disabled"),$(".processing").removeClass("hide"),t=$("#checkout-form-payment"),t.validate(),t.valid())if(n.data("sezzle"))$.post("/checkout/sezzle-start",function(){}).done(function(n){window.location=n}).error(function(){$(".processing").addClass("hide")});else{let i=t.serialize(),r=$("#IsPhoneOrder");r&&(i+="&PhoneOrderPromiseDate="+f.val()+"&PhoneOrderNotes="+$("#phone-order-notes").val()+"&PhoneOrderBypassPayment="+$("#phone-order-bypass").is(":checked")+"&PhoneOrderIsFinalSale="+$("#phone-order-final-sale").is(":checked"));i+="&__RequestVerificationToken="+c;$.ajax({url:"/checkout/complete-order",type:"POST",contentType:"application/x-www-form-urlencoded",data:i,success:function(t){t.IsError?($.sticky(t.Message,{classList:"error",autoclose:7e3}),n.removeClass("disabled")):t.Data!=undefined&&t.Data.RedirectUrl!=undefined&&(window.location=t.Data.RedirectUrl)},error:function(){n.removeClass("disabled")}})}else n.removeClass("disabled"),$(".processing").addClass("hide")});jQuery.validator.addMethod("noPoBox",function(n){if(n.length===0)return!0;return!n.match(/^ *((#\d+)|((box|bin)[-. \/\\]?\d+)|(.*p[ \.]? ?(o|0)[-. \/\\]? *-?((box|bin)|b|(#|num)?\d+))|(p(ost)? *(o(ff(ice)?)?)? *((box|bin)|b)? *\d+)|(p *-?\/?(o)? *-?box)|post office box|((box|bin)|b) *(number|num|#)? *\d+|(num|number|#) *\d+)/i)});t=function(){var n=$("#ShippingAddress_State").val();return n==="WI"||n==="IL"||n==="IA"||n==="IN"};$("#checkout-form-basic").validate({ignore:"",rules:{"BasicInfo.FirstName":{required:!0},"BasicInfo.LastName":{required:!0},"BasicInfo.Email":{required:!0,email:!0},"BasicInfo.Phone":{required:!0,minlength:7,maxlength:20},"BasicInfo.EventType":{required:{depends:function(){return t()&&$("#cart-has-dress").val()=="true"}}},"BasicInfo.EventName":{required:{depends:function(){var n=$("#BasicInfo_EventType").val();return t()&&(n==="Prom"||n==="Homecoming"||n==="Winter Formal")}}},"ShippingAddress.Address1":{required:!0,noPoBox:!0},"ShippingAddress.Address2":{required:!1,noPoBox:!0},"ShippingAddress.City":{required:!0},"ShippingAddress.State":{required:!0},"ShippingAddress.Zip":{required:!0,isValidZipCode:!0}},messages:{"ShippingAddress.Address1":{noPoBox:"We cannot ship to PO Boxes"},"ShippingAddress.Address2":{noPoBox:"We cannot ship to PO Boxes"},"ShippingAddress.Zip":{required:"Zip Code is required",isValidZipCode:"Zip Code is invalid"}},focusInvalid:!1,invalidHandler:function(n,t){t.numberOfInvalids()&&nt(t.errorList[0].element)}});$("#checkout-form-shipping").validate({ignore:"",rules:{"Shipping.NeedDate":{required:!0},"Shipping.ShippingCost":{required:!0},"Shipping.ShippingMethod":{required:!0}},messages:{"Shipping.ShippingMethod":{required:"You must select a shipping method"},"Shipping.ShippingCost":{required:""},"Shipping.NeedDate":{required:"Please select your need date"}}});jQuery.validator.addMethod("requiredIfOrderHasBalance",function(n,t){let i=parseFloat($("#Payment_Balance").val())>0,r=$("#payment-complete-order").data("sezzle"),u=$("#IsPhoneOrder"),f=$("#phone-order-bypass").is(":checked");return r||u&&f?!0:i?$(t).val().length>0:!0});jQuery.validator.addMethod("isValidZipCode",function(n,t){let i=$(t),r=i.data("address-type"),u=$("#"+r+"_Country").val();return u=="US"?/(^\d{5}$)|(^\d{5}-\d{4}$)/.test(i.val()):!0});$("#checkout-form-payment").validate({ignore:"",rules:{"Payment.CardholderName":{requiredIfOrderHasBalance:!0},"Payment.CVV":{requiredIfOrderHasBalance:!0},AgreedToTerms:{required:!0},"BillingAddress.Address1":{requiredIfOrderHasBalance:!0},"BillingAddress.City":{requiredIfOrderHasBalance:!0},"BillingAddress.State":{requiredIfOrderHasBalance:!0},"BillingAddress.Zip":{requiredIfOrderHasBalance:!0,isValidZipCode:!0}},messages:{"Payment.CardholderName":"Cardholder name is required","Payment.CCNumber":{requiredIfOrderHasBalance:"Credit Card number is required",creditcard:"Credit Card is invalid"},"Payment.CVV":"Security Code is required","BillingAddress.Address1":"Billing Street Address is required","BillingAddress.City":"Billing City is required","BillingAddress.Zip":{requiredIfOrderHasBalance:"Zip Code is required",isValidZipCode:"Zip Code is invalid"},AgreedToTerms:"Terms and Conditions are required"},invalidHandler:function(n,t){if(t.numberOfInvalids()>0){t.showErrors();let n=$(":input.error").first();if(!n.is(":visible")){let t=n.parents(".checkout-option").find('input[type="radio"]');t&&t.click()}nt(n)}}});$("#checkout-container").on("click",".checkout-button.back",function(){var n=$(this);b(n.data("target-panel"),n.data("home-panel"),!1)});$("#checkout-container").on("click","#checkout-shipping-rates .shipping-option",function(){var n=$(this);$("#Shipping_ShippingCost").val(n.data("shipping-cost"));$("#Shipping_ShippingMethod").val(n.data("shipping-method"));n.data("shipping-need-date")!=undefined&&$("#Shipping_NeedDate").val(n.data("shipping-need-date"))});$("#checkout-container").on("change",".address-state select, .address-state input",function(){var n=$(this);$("#"+n.data("update-target")).val(n.val()).trigger("change")});$("#checkout-container").on("change",".address-country",tt);$("#ShippingAddress_Country").change();h=!1;$("#checkout-container").on("change","#ShippingAddress_Country",function(){var n=$(this).val();n==="US"||h||($("#duties-and-taxes-modal").modal({show:!0,backdrop:"static",keyboard:!1}),h=!0)});$("#checkout-container").on("click","#apply-gift-card, #apply-promo-code",function(){var n=$(this),r=$("#"+n.data("message-elementid")),t=$("#"+n.data("value-elementid")),u=n.data("submit-url"),i;r.addClass("hide").removeClass("error");i=t.val();$.post(u,{code:i},function(n){n.IsError?$.sticky(n.Message,{classList:"error"}):(t.val(""),$("#checkout-payment-summary").html(n.Data),$.sticky(n.Message,{classList:"success"}))})});var w=function(n){if(Date.parse(n)){var t=$("#checkout-form-shipping");t.validate();$("#Shipping_NeedDate").val(n);$("#Shipping_ShippingCost").val("");$("#Shipping_ShippingMethod").val("");$("#checkout-shipping-rates").html("Getting Shipping Rates...");$.ajax({url:"/checkout/get-shipping-options",type:"POST",contentType:"application/x-www-form-urlencoded",data:{NeedDate:n,__RequestVerificationToken:c},success:function(n){$("#checkout-shipping-rates").html(n)}})}},it=function(n,t){$.get("/checkout/update-section/"+n,function(n){$("#"+t).html(n)})},b=function(n,t,i){$("#"+n+" .checkout-step-status").addClass("editing").removeClass("complete").removeClass("incomplete");i?$("#"+t+" .checkout-step-status").addClass("complete").removeClass("editing").removeClass("incomplete"):$("#"+t+" .checkout-step-status").addClass("incomplete").removeClass("editing").removeClass("complete");$("#"+n+" .panel-heading h4").click()},rt=function(){var n=$("#PreventShippingValue").val();n==3?($.each($("#ShippingAddress_Country option"),function(){var n=$(this);n.val()!="US"&&n.remove()}),$("#prevent-shipping-message").removeClass("hide")):n==1&&($.each($("#ShippingAddress_Country option"),function(){var n=$(this);n.val()!="US"&&n.val()!="CA"&&n.remove()}),$("#prevent-shipping-message").removeClass("hide"),$("#prevent-shipping-message span").removeClass("hide"));$("#prevent-shipping-message-spacer").attr("style","height:"+$("#prevent-shipping-message").height()+"px;")};$("#checkout-shipping-need-date").datepicker({onSelect:function(n){w(n)},minDate:$("#MinDate").val(),dateFormat:"mm/dd/yy",numberOfMonths:1});f&&f.datepicker({dateFormat:"mm/dd/yy",numberOfMonths:1});ut=function(n,t){var i=new Date(n);return i.setDate(i.getDate()+t),i};k=function(n){$("#MinDate").val(n);$("#checkout-shipping-need-date").datepicker("option","minDate",n)};s();l();o();rt();r=!1;u=!1;$("body").on("change","#AgreedToTerms",function(){r=$(this).prop("checked");u&&(r?($("#paypalagree").hide(),d()):($("#paypal-button-container").html(""),$("#paypalagree").show(),$.sticky("Please Agree to Terms & Condtions",{classList:"error"})))});$("body").on("click","#paypalagree",function(){$.sticky("Please Agree to Terms & Condtions",{classList:"error"})});$("body").on("click","#credit-select, #gift-select, #sezzle-select, #paypal-select",function(){var t=$(this),n=$("#payment-complete-order");$(".pay-credit-card").hide();$(".pay-gift-card").hide();$(".pay-sezzle").hide();$(".pay-paypal").hide();$("#paypal-button-container").html("");$("#paypalagree").hide();u=!1;n.html("Complete Order");t.attr("id")=="gift-select"?(n.data("sezzle",!1),$(".pay-gift-card").show(),n.show()):t.attr("id")=="credit-select"?(n.data("sezzle",!1),$(".pay-credit-card").show(),n.show()):t.attr("id")=="sezzle-select"?(n.data("sezzle",!0),$(".pay-sezzle").show(),n.html("Complete with Sezzle"),n.show()):t.attr("id")=="paypal-select"&&($(".pay-paypal").show(),n.hide(),u=!0,r?($("#paypalagree").hide(),d()):$("#paypalagree").show())});g();$(".garment-bag-checkout .btn").on("click",function(n){n.preventDefault();let t=$(this).data("productid");$.get("/cart/add-to-cart/"+t).done(function(){$.get("/checkout/get-cart-display").done(function(n){$("#checkout-cart-display").html(n.Data);$(".garment-bag-checkout").remove();let i=$("#cart-count-big"),t=parseInt(i.html());t++;i.html(t);let r=$("#cart-count-small");r.html(t)})})});$("#credit-select").click();$("#ShippingAddress_Zip, #BillingAddress_Zip").on("keyup",n=>{let t=$(n.target);if(t.val().length==5){let n=t.data("address-type"),i=$("#"+n+"_Country").val();i=="US"&&$.post("/checkout/address-lookup-by-zip/"+t.val(),t=>{if(!t.IsError){$("#"+n+"_City").val(t.Data.city);$("#"+n+"_dropdown-us").val(t.Data.state);let i=$("#"+n+"_State");i.val(t.Data.state);i.change();s()}})}})});$(document).ready(function(){$(".cart-container").on("click",".cart-item-remove-button",function(n){var t,i;n.preventDefault();t=$(this);$(".delete-confirm").data("id",t.data("id"));$("#cart-item-delete-modal .modal-product-name").html(t.data("name"));$("#cart-item-delete-modal .modal-body img").attr("src",t.data("thumbnail"));i=t.data("id");$("#cart-item-delete-modal").modal({backdrop:"static",keyboard:!1}).one("click",".delete-confirm",function(){var n="/cart/remove-from-cart/"+i;$.get(n,function(n){var t,i;$("#cart-grid-container").html(n);t=$("#cart-count-big");t.html(t.html()-1);i=$("#cart-count-small");i.html(i.html()-1)}).done(function(){$.sticky(t.data("name")+" removed",{classList:"success"})})})})})