function checkRegisterForm(n){var t=CheckEmailAddress(),i=CheckPasswords();return t&&i?!0:(n.preventDefault(),!1)}function checkContactForm(n){var t=CheckEmailAddress(),i=CheckPhoneNumber();return t&&i?(alert(" valid"),!0):(alert("not valid"),n.preventDefault(),!1)}function checkNewsletterForm(n){var t=CheckEmailAddress();return t?!0:(n.preventDefault(),!1)}function CheckSigninOrRegister(n){var t=CheckEmailAddress();return t?!0:(n.preventDefault(),!1)}function CheckEmailAddress(){$("span.error-email").remove();var n=$("input[id$=Customer_Email]").val();return/^([\w-\.\+]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.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(),$("input[id$=Customer_Phone]").length<=0)?!0:(n=$("input[id$=Customer_Phone]").val(),n==="")?!0:(t=/^[0-9]{10}$/,t.test(n)?(console.log("Blah phone"),!0):(console.log("Blah phone Error"),$("input[id$=Customer_Phone]").after('<span class="error error-phone">Invalid Phone Format.<\/span>'),!1))}function CheckMobileNumber(){var n,t;return($("span.error-mobile").remove(),$("input[id$=Customer_Mobile]").length<=0)?!0:(n=$("input[id$=Customer_Mobile]").val(),n==="")?!0:(t=/^[0-9]{10}$/,t.test(n)?(console.log("Blah mobile"),!0):(console.log("Blah mobile Error"),$("input[id$=Customer_Mobile]").after('<span class="error error-mobile">Invalid Mobile Format.<\/span>'),!1))}function CheckPasswords(){$(".error-passwords").remove();var n=$("input[id$=Customer_Password]").val(),t=$("input[id$=Customer_PasswordRepeat]").val();return n===""&&t===""?!0:n!==t?($("input[id$=Customer_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:"/Account/CheckCustomersEmailM",data:{emailId:t,newsletter:!1},dataType:"json",responseType:"json"}).done(function(n){if(console.log("checked for customersemail"+n.result),n.result){var r=!1,u=getUrlVars(),i="";$.each(u,function(n,t){n==="checkout"?r=t:n==="ReturnURL"&&t.indexOf("quickcheckout")>0?i=t+"=true":n==="ReturnURL"&&(i=t)});$.ajax({type:"POST",url:"https://"+location.hostname+"/Account/RegisterNewCustomer",data:{"NewCustomer.Email":t},datatype:"html",success:function(){document.location.href=i.length>0?"/account/register?ReturnURL="+i:"/account/register?checkout="+r}})}else $("#LoginPassword").removeClass("hidden"),$("#LoginButton").removeClass("hidden"),$("#ShowLoginReg").addClass("hidden"),$(".error").css({display:"none"}),$("#Customer_Password").focus().click(),$("#forgotPasswordHyp").attr("href","/account/forgotPassword?id="+t)});else return n.preventDefault(),!1}$(function(){$("#NewCustomer_Email").change(function(){CheckEmailAddress()});$("#NewCustomer_Phone").change(function(){});$("#NewCustomer_Mobile").change(function(){});$("#NewCustomer_PasswordRepeat").change(function(){CheckPasswords()});$("#btnSaveCataloguePreferences").click(function(){var n=[];return $.each($(".dgTabsSites.showborder"),function(){n.push({BrandId:$(this).find("div").attr("id")})}),n=JSON.stringify({cataloguePreferences:n}),console.log(n),$.ajax({contentType:"application/json; charset=utf-8",dataType:"json",responseType:"json",type:"POST",url:"https://"+location.hostname+"/Account/SaveCataloguePreferences",data:n}).done(function(n){n.result?$("#result").text("Your catalogue preferences have been saved successfully."):$("#result").text("Your catalogue preferences could not be saved!")}),!1});$("#btnSaveEmailPreferences").click(function(){var i=[],n,t;$.each($(".dgTabsCategories.showborder"),function(){i.push({EmailName:$(this).find("label").attr("id")})});n=[];$.each($(".dgTabsSites.showborder"),function(){n.push({BrandId:$(this).find("div").attr("id")})});t={SendEmailsCategories:i,SendEmailsForCurrentBrand:$("#sendemailfromcurrentbrand").is(":checked"),SendEmailsForOtherBrands:n};console.log(t);$.ajax({contentType:"application/json; charset=utf-8",dataType:"json",responseType:"json",type:"POST",url:"https://"+location.hostname+"/Account/SaveEmailPreferences",data:JSON.stringify(t)}).done(function(n){n.result?$("#result").text("Your email preferences have been saved successfully."):$("#result").text("An error occured while saving email preferences.")})});$("#btnSaveUnsubscibe").click(function(){var i=[],t;$.each($(".dgTabsCategories.showborder"),function(){i.push({EmailName:$(this).find("label").attr("id")})});var n="",r=getUrlVars();$.each(r,function(t,i){t==="email"&&(n=i)});console.log(n);t={SendEmailsCategories:i,UnsubscribeCustomer:$("#unsubscribeCustomer").is(":checked"),Email:n};console.log(t);$.ajax({contentType:"application/json; charset=utf-8",dataType:"json",responseType:"json",type:"POST",url:"https://"+location.hostname+"/Account/Unsubscribe",data:JSON.stringify(t)}).done(function(n){n.result?($("#unsubscribeContent").hide(),$("#result").css("color","black"),$("#result").html(n.message)):($("#result").css("color","red"),$("#result").html(n.message))})});$("#btnCancelEditAccount").click(function(){document.location.href="/accountocr.aspx"})});$(document).ready(function(){function i(n,t){if(console.log("1. GetFlatNo "+n),n!==""&&n!==undefined){var r=n.toLowerCase(),i=[];return t.forEach(function(n){r.indexOf(n)>=0&&(i=r.split(n))}),console.log("2. GetFlatNo "+i[1]),i[1]}}function r(n,t,i){return console.log("address typed - "+n),n.indexOf(",")>0&&(n=n.split(",")[1].trim()),$.ajax({url:"/account/ValidateAddressHWMVC",dataType:"jsonp",type:"POST",async:!0,contentType:"application/json; charset=utf-8",data:JSON.stringify({address:n,postcode:t,country:i}),complete:function(n){console.log(n)}})}var n,t;$("#BillAddress").css("display","none");$("#ShippAddress").css("display","none");n=function(){$("#BillAddress").length>0&&($("[id$='BillToAddress_Address1']").css("display","none"),$("#BillAddress").css("display","block").delay(100).focus(),$("#BillAddress").val(""))};$("[id$='BillToAddress_Address1']").keypress(function(){n()});$("[id$='BillToAddress_Address1']").click(n);t=function(){$("[id$='ShipToAddress_Address1']").css("display","none");$("#ShippAddress").css("display","block").delay(100).focus()};$("[id$='ShipToAddress_Address1']").keypress(function(){t()});$("[id$='ShipToAddress_Address1']").click(t);$("#ShippAddress").keydown(function(n){n.which===9&&($("[id$='ShipToAddress_Address1']").val($(this).val()),$("[id$='ShipToAddress_Address1']").css("display","block"),$(this).css("display","none"))});$("#ShippAddress").focusout(function(){$(this).val().length>0&&($("[id$='ShipToAddress_Address1']").val().length<=0&&$("[id$='ShipToAddress_Address1']").val($(this).val()),$("[id$='ShipToAddress_Address1']").css("display","block"),$(this).css("display","none"))});$("#BillAddress").keydown(function(n){n.which===9&&(console.log("inside keydown "+$(".ui-autocomplete.ui-widget:visible").length),$("[id$='BillToAddress_Address1']").val($(this).val()),$("[id$='BillToAddress_Address1']").css("display","block"),$(this).css("display","none"))});$("#BillAddress").focusout(function(){console.log("in focusout "+$(this).val());$(this).val().length>0&&(console.log("finally bye - focusout "+$(".ui-autocomplete.ui-widget:visible").length),$("[id$='BillToAddress_Address1']").val().length<=0&&$("[id$='BillToAddress_Address1']").val($(this).val()),$("[id$='BillToAddress_Address1']").css("display","block"),$(this).css("display","none"))});$(".manualBillAddr").click(function(n){n.preventDefault();var t=$("#BillAddress").val();$("[id$='BillToAddress_Address1']").css("display","block");$("[id$='BillToAddress_Address1']").val(t);$("[id$='BillToAddress_Address1']").focus();$("#BillAddress").css("display","none");$("#BillAddress").remove()});$(".manualShipAddr").click(function(n){n.preventDefault();var t=$("#ShippAddress").val();$("[id$='ShipToAddress_Address1']").css("display","block");$("[id$='ShipToAddress_Address1']").val(t);$("[id$='ShipToAddress_Address1']").focus();$("#ShippAddress").css("display","none");$("#ShippAddress").remove()});$("#chbDifferentShippingAddr").click(function(){$(".ShowBillingAddress.secondStep").hide();$(".ShowShippingAddress.secondStep").show()});$("#BillAddress").autocomplete({minLength:3,source:function(n,t){var f,e=$("[id$='BillToAddress_Zip']").val(),u;f=window.location.hostname.indexOf("au")!==-1?"AUS":"NZL";u=n.term;(u.length>3||u.indexOf(" ")>=0)&&r(u,e,f).then(function(){},function(n){var r=JSON.parse(n.responseText).listedAddresses,e,f;r.length!=="undefined"&&(console.log("value "+u),e=$.ui.autocomplete.escapeRegex(u),f=$.grep(r,function(n){var t;console.log("item.Street1"+n.Street1+"item.PremiseNo "+n.PremiseNo+" item.floorNo "+n.floorNo+" item.flat "+n.flat);var e=i(n.flat,["unit ","duplex ","suite ","shop ","flat "]),r=n.Street1.toLowerCase(),f=[];return f[0]=r,[" st"," pl"," ave"," hwy"," ln"," cres"," dr"," rd"," road"," street"," place"," avenue"," highway"," lane"," crescent"," drive"].forEach(function(n){r.indexOf(n)>=0&&(f=r.split(n))}),t=new RegExp("^((unit|u|Unit|Shop|shop|Flat|flat)\\s*)?(?<unit>"+e+")?(\\s+|/)?(\\s*,*\\s*)?(?<streetNo>"+n.PremiseNo.toLowerCase()+")\\s+(?<streetName>"+f[0]+")\\s+(?<streetType>w+)?(\\s*,*\\s*)?(?<suburb>"+n.Town.toLowerCase()+")?(\\s*,*\\s*)?(?<state>"+n.County.toLowerCase()+")?"),console.log(t+" matcher "+t.test(u)),t.test(u.toLowerCase())}),t($.map(f,function(n){console.log("ITEM "+n.FormattedAddress);var t={};return t.label=n.FormattedAddress,t.ShortAddress=n.ShortAddress,t.Street2=n.Street2,t.County=n.County,t.Town=n.Town,t.Postcode=n.Postcode,t})))})},select:function(n,t){var i=$("#BillAddress").val();t.item.label==="Continue with your address"?($("[id$='BillToAddress_Address1']").css("display","block"),$("[id$='BillToAddress_Address1']").val(i),$("[id$='BillToAddress_City']").focus()):($("[id$='BillToAddress_Address1']").css("display","block"),$("[id$='BillToAddress_Address1']").val(t.item.ShortAddress),$("[id$='BillToAddress_Address2']").val(t.item.Street2),$("[id$='BillToAddress_City']").val(t.item.Town),$("[id$='BillToAddress_State_Abbreviation']").val(t.item.County).change(),console.log("In Select ui.item.ShortAddress: "+t.item.ShortAddress+" ui.item.Street2: "+t.item.Street2+" ui.item.Town: "+t.item.Town+" ui.item.County: "+t.item.County));this.value="";console.log("In Select clear BillAddress "+$("#BillAddress").val()+"  "+$("[id$='BillToAddress_Address1']").val());$("#BillAddress").css("display","none")},response:function(n,t){if(!t.content.length){var i={value:this.value,label:"Continue with your address",id:"red"};t.content.push({value:"",label:"No results yet, keep typing... OR",id:"none"});t.content.push(i)}}});$("#ShippAddress").autocomplete({minLength:3,source:function(n,t){var f,e=$("[id$='ShipToAddress_Zip']").val(),u;f=window.location.hostname.indexOf("au")!==-1?"AUS":"NZL";u=n.term;(u.length>3||u.indexOf(" ")>=0)&&r(u,e,f).then(function(){},function(n){var r=JSON.parse(n.responseText),e,f;console.log(r);e=$.ui.autocomplete.escapeRegex(u);f=$.grep(r,function(n){var t;console.log("item.Street1"+n.Street1+"item.PremiseNo "+n.PremiseNo+" item.floorNo "+n.floorNo+" item.flat "+n.flat);var o=i(n.flat,["unit ","duplex ","suite ","shop "]),r=[" st"," pl"," ave"," hwy"," ln"," cres"," dr"," rd"],s=i(n.Street1,r),f=n.Street1.toLowerCase(),e=[];return r.forEach(function(n){f.indexOf(n)>=0&&(e=f.split(n))}),t=new RegExp("^((unit|u|Unit|Shop|shop)\\s*)?(?<unit>"+o+")?(\\s+|/)?(\\s*,*\\s*)?(?<streetNo>"+n.PremiseNo.toLowerCase()+")\\s+(?<streetName>"+e[0]+")\\s+(?<streetType>w+)?(\\s*,*\\s*)?(?<suburb>"+n.Town.toLowerCase()+")?(\\s*,*\\s*)?(?<state>"+n.County.toLowerCase()+")?"),console.log(t+" matcher "+t.test(u)),t.test(u.toLowerCase())});t($.map(f,function(n){var t={};return t.label=n.FormattedAddress,t.ShortAddress=n.ShortAddress,t.Street2=n.Street2,t.County=n.County,t.Town=n.Town,t.Postcode=n.Postcode,t}))})},select:function(n,t){var i=$("#ShippAddress").val();t.item.value==="continue"?($("[id$='ShipToAddress_Address1']").css("display","block"),$("[id$='ShipToAddress_Address1']").val(i),$("[id$='ShipToAddress_City']").focus()):($("[id$='ShipToAddress_Address1']").css("display","block"),$("[id$='ShipToAddress_Address1']").val(t.item.ShortAddress),$("[id$='ShipToAddress_Address2']").val(t.item.Street2),$("[id$='ShipToAddress_City']").val(t.item.Town),$("[id$='ShipToAddress_State_Abbreviation']").val(t.item.County).change());console.log("clear ShippAddress "+$("#ShippAddress").val());$("#ShippAddress").css("display","none")},response:function(n,t){if(!t.content.length)t.content.push({value:"",label:"No results yet, keep typing...OR",id:"none"}),t.content.push({value:"continue",label:"Continue with your address",id:"red"})}})})