function checkRegisterForm(n){var t=CheckEmailAddress(),i=CheckPhoneNumber(),r=CheckMobileNumber(),u=CheckPasswords(),f=CheckFName(),e=CheckLName();return t&&i&&r&&u&&f&&e?!0:(n.preventDefault(),!1)}function checkNewsletterForm(n){var t=CheckEmailAddress(),i=CheckFName(),r=CheckLName();return t&&i&&r?!0:(n.preventDefault(),!1)}function CheckSigninOrRegister(n){var t=CheckEmailAddress();return t?!0:(n.preventDefault(),!1)}function CheckFName(){var n,t;return($("span.error-fname").remove(),n=$("input[id$=Customer_FirstName]").val(),n==="")?!0:(t=/[a-zA-Z''-'\s]{1,40}$/,t.test(n)?!0:($("input[id$=Customer_FirstName]").after('<span class="error error-fname">Invalid characters.<\/span>'),!1))}function CheckLName(){var n,t;return($("span.error-lname").remove(),n=$("input[id$=Customer_LastName]").val(),n==="")?!0:(t=/[a-zA-Z''-'\s]{1,40}$/,t.test(n)?!0:($("input[id$=Customer_LastName]").after('<span class="error error-lname">Invalid characters.<\/span>'),!1))}function CheckEmailAddress(){var n,t;return($("span.error-email").remove(),n=$("input[id$=Customer_Email]").val(),n==="")?!0:(t=/^([\w-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/,t.test(n)?!0:($("input[id$=Customer_Email]").after('<span class="error error-email">Invalid Email Format.<\/span>'),!1))}function CheckPhoneNumber(){var n,t;return($("span.error-phone").remove(),n=$("#NewCustomer_Phone").val(),n==="")?!0:(t=/^\s*[+\-]?\s*[0-9]+(\.[0-9]+)?([+\-]?[Ee][+\-]?[1-9][0-9]*)?\s*$/,t.test(n)?!0:($("#NewCustomer_Phone").after('<span class="error error-phone">Invalid Phone Format.<\/span>'),!1))}function CheckMobileNumber(){var n,t;return($("span.error-mobile").remove(),n=$("#NewCustomer_Mobile").val(),n==="")?!0:(t=/^\s*[+\-]?\s*[0-9]+(\.[0-9]+)?([+\-]?[Ee][+\-]?[1-9][0-9]*)?\s*$/,t.test(n)?!0:($("#NewCustomer_Mobile").after('<span class="error error-mobile">Invalid Mobile Format.<\/span>'),!1))}function CheckPasswords(){$("span.error-passwords").remove();var n=$("#NewCustomer_Password").val(),t=$("#NewCustomer_PasswordRepeat").val();return n===""&&t===""?!0:n!==t?($("#NewCustomer_PasswordRepeat").after('<span class="error error-passwords">Passwords do not match.<\/span>'),!1):!0}function CheckCustomerEmail(n){var i=CheckEmailAddress(),t;if(i)t=$("input[id='Customer_Email']").val(),$.ajax({type:"POST",url:"/m/Account/CheckCustomersEmailM",data:{emailId:t,newsletter:!1},dataType:"json",responseType:"json"}).done(function(n){n.result?$.ajax({type:"POST",url:"https://"+location.hostname+"/m/Account/RegisterNewCustomer",data:{"NewCustomer.Email":t},datatype:"html",success:function(){document.location.href=isReturnUrl.length>0?"/m/account/register?model.Checkout="+isCheckout+"&model.ReturnURL="+isReturnUrl:"/m/account/register?model.Checkout="+isCheckout}}):($("#LoginPassword").removeClass("hidden"),$("#LoginForgotPassword").removeClass("hidden"),$("#LoginButton").removeClass("hidden"),$("#ShowLoginReg").addClass("hidden"))});else return n.preventDefault(),!1}$(function(){$("#NewCustomer_Email").change(function(){CheckEmailAddress()});$("#NewCustomer_Phone").change(function(){CheckPhoneNumber()});$("#NewCustomer_Mobile").change(function(){CheckMobileNumber()});$("#NewCustomer_PasswordRepeat").change(function(){CheckPasswords()});$("#btnRegister").click(function(){document.location.href="/m/account/register?model.NewCustomer.Email="+$("#NewCustomer_Email").val()+"&model.Checkout="+isCheckout});$("#btnGuestCheckout").click(function(){$.ajax({type:"POST",url:"https://"+location.hostname+"/m/Account/RegisterNewCustomer",data:{"NewCustomer.Email":$("#GuestEmail").val()},datatype:"html",success:function(){document.location.href="/m/account/register?skipreg=true&model.SkipReg=true&model.Checkout=true"}})});$("#SendEmailsForCurrentBrand").click(function(){$(".sendEmailsCategories").prop("checked",!1)});$(".sendEmailsCategories").click(function(){$("#SendEmailsForCurrentBrand").prop("checked",!1)});$("#btnSaveCataloguePreferences").click(function(){$.mobile.loading("show");var n=[];return $.each($(".cataloguepreference:checked"),function(){$(this).is(":checked")&&n.push({BrandId:$(this).attr("id")})}),n=JSON.stringify({cataloguePreferences:n}),$.ajax({contentType:"application/json; charset=utf-8",dataType:"json",responseType:"json",type:"POST",url:"https://"+location.hostname+"/m/Account/SaveCataloguePreferences",data:n}).done(function(n){n.result?handleFeedback("Your catalogue preferences have been saved successfully.","Success"):handleFeedback("Your catalogue preferences could not be saved!","Error");$.mobile.loading("hide")}),!1});$("#btnSaveEmailPreferences").click(function(){var t,i,n;return $.mobile.loading("show"),t=[],$.each($(".sendEmailsCategories"),function(){$(this).is(":checked")&&t.push({EmailName:$(this).attr("name")})}),i=[],$.each($(".sendEmailsForOtherBrands"),function(){$(this).is(":checked")&&i.push({BrandId:$(this).attr("name")})}),n={SendEmailsCategories:t,SendEmailsForCurrentBrand:$("#SendEmailsForCurrentBrand").is(":checked"),SendEmailsForOtherBrands:i},n=JSON.stringify({model:n}),$.ajax({contentType:"application/json; charset=utf-8",dataType:"json",responseType:"json",type:"POST",url:"https://"+location.hostname+"/m/Account/SaveEmailPreferences",data:n}).done(function(n){n.result?handleFeedback("Your email preferences have been saved successfully.","Success"):handleFeedback("An error occured while saving email preferences.","Error");$.mobile.loading("hide")}),!1});$("#btnCancelEditAccount").click(function(){document.location.href="/m/account/index"})})