storeLocatorJS={googleMapAPIKey:null,resultGeocodeLatitude:null,resultGeocodeLongitude:null,resultCityId:null,cityHash:[],hideResultDiv:!1,setGoogleMapAPIKey:function(a){storeLocatorJS.googleMapAPIKey=a},getGoogleMapAPIKey:function(){return storeLocatorJS.googleMapAPIKey},initProvinceSelections:function(){var a=dojo.byId("selectCountry").selectedIndex;if(a>-1){var b=a,c=storeLocatorJS.getSavedCountrySelectionIndex();null!=c&&c!=a&&(b=c,dojo.byId("selectCountry").options[b].selected=!0),wc.render.updateContext("provinceSelectionsContext",{countryId:dojo.byId("selectCountry").options[b].value})}},saveResults:function(a){storeLocatorJS.resultGeocodeLatitude=a.properties.geoCodeLatitude,storeLocatorJS.resultGeocodeLongitude=a.properties.geoCodeLongitude,storeLocatorJS.resultCityId=a.properties.cityId},refreshCities:function(){var a=dojo.byId("selectState").selectedIndex;if(a>-1){var b=a,c=storeLocatorJS.getSavedProvinceSelectionIndex();null!=c&&c!=a&&(b=c,dojo.byId("selectState").options[b].selected=!0),wc.render.updateContext("citySelectionsContext",{provinceId:dojo.byId("selectState").options[b].value})}},refreshSearchResults:function(a){var b=PhysicalStoreCookieJS.getValueFromCookie("WC_stFind"),c=dojo.byId("selectCity").selectedIndex;if(c>-1){var d=c,e=storeLocatorJS.getSavedCitySelectionIndex();null!=e&&e!=c&&(d=e,dojo.byId("selectCity").options[d].selected=!0);var f=PhysicalStoreCookieJS.getValueFromCookie("WC_stZip");null!=f&&(dojo.byId("searchByGeoNodeForm").textZipPostalCode.value=f,null!=b&&(1==b?wc.render.updateContext("storeLocatorResultsContext",{cityId:dojo.byId("selectCity").options[d].value,geoCodeLatitude:"-888",geoCodeLongitude:"-888",fromPage:a,storeSearch:document.getElementById("inputLocation").value}):2==b&&storeLocatorJS.preRefreshResultsFromZip(dojo.byId("searchByGeoNodeForm"))))}},addPhysicalStore:function(a,b){return 1==PhysicalStoreCookieJS.isAddOneStoreIdExceedMax()?(MessageHelper.formErrorHandleClient("addPhysicalStoreToCookieButton"+b,MessageHelper.errorMessages.EXCEED_PHYSICAL_STORE_SIZE),!1):(PhysicalStoreCookieJS.addToCookie(a),storeLocatorJS.showRemoveOption(a),storeLocatorJS.showStoreList(),!0)},removePhysicalStore:function(a){PhysicalStoreCookieJS.removeFromCookie(a),PhysicalStoreCookieJS.clearPickUpStoreIdFromCookie(a),storeLocatorJS.showAddOption(a)},showRemoveOption:function(a){var b=dojo.byId("addPhysicalStoreToCookieDisabled"+a),c=dojo.byId("addPhysicalStoreToCookie"+a);null!=b&&"undefined"!=b&&(b.style.display="block"),null!=c&&"undefined"!=c&&(c.style.display="none")},showAddOption:function(a){var b=dojo.byId("addPhysicalStoreToCookieDisabled"+a),c=dojo.byId("addPhysicalStoreToCookie"+a);null!=b&&"undefined"!=b&&(b.style.display="none"),null!=c&&"undefined"!=c&&(c.style.display="block")},hideMap:function(){var a=dojo.byId("hideMap"),b=dojo.byId("mapImpl"),c=dojo.byId("showMap");a.style.display="none",b.style.display="none",c.style.display="block"},showMap:function(){var a=dojo.byId("hideMap"),b=dojo.byId("mapImpl"),c=dojo.byId("showMap");if(a.style.display="block",b.style.display="block",c.style.display="none",null==storeLocatorJS.resultGeocodeLatitude){storeLocatorJS.displayMap(null,null)}else{var d={};d.geoCodeLatitude=storeLocatorJS.resultGeocodeLatitude,d.geoCodeLongitude=storeLocatorJS.resultGeocodeLongitude,d.cityId=storeLocatorJS.resultCityId,dojo.xhrPost({url:"AjaxStoreLocatorMapResultsView",handleAs:"json-comment-optional",content:d,service:this,load:storeLocatorJS.displayMap,error:function(a,b){alert("Store Locator JS - showMap: "+a.toString())}})}},syncMapDisplayStyle:function(){dojo.byId("mapImpl").style.display="block"},manageCookieFromCity:function(){PhysicalStoreCookieJS.setValueToCookie("WC_stFind",1)},manageCookieFromZip:function(a){PhysicalStoreCookieJS.setValueToCookie("WC_stZip",a),PhysicalStoreCookieJS.setValueToCookie("WC_stFind",2)},refreshResultsFromCity:function(a,b,c){var d="",e="",f="";"v1"===c?(console.log(a),d=a.cityName,e=a.cityId,f=a.cityName):(d=a.inputLocation.value.toLowerCase(),e=document.getElementById(d).value,f=document.getElementById("inputLocation").value),storeLocatorJS.manageCookieFromCity(),wc.render.updateContext("storeLocatorResultsContext",{cityId:e,geoCodeLatitude:"-888",geoCodeLongitude:"-888",fromPage:b,storeSearch:f})},preRefreshResultsFromZip:function(a){reWhiteSpace=new RegExp(/^\s+$/),storeLocatorJS.manageCookieFromZip(a.inputLocation.value);var b=null,c=null,d=null,e="Australia";"2000"==a.inputLocation.value&&(e="");var f=e+" "+a.inputLocation.value;(b=new google.maps.Geocoder)&&b.geocode({address:f,region:"AU"},function(a,b){b==google.maps.GeocoderStatus.OK?(c=a[0].geometry.location.lat(),d=a[0].geometry.location.lng(),wc.render.updateContext("storeLocatorResultsContext",{geoCodeLatitude:c,geoCodeLongitude:d,cityId:"-888",fromPage:StoreLocatorContextsJS.fromPage,storeSearch:document.getElementById("inputLocation").value})):MessageHelper.XmarkFieldValidationError("inputLocation",MessageHelper.messages.MISSING_CITY)})},preRefreshResultsFromGeoLocation:function(a){var b=null,c=null;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(a){console.log(a),null!=a?(b=a.coords.latitude,c=a.coords.longitude,console.log(b),console.log(c),wc.render.updateContext("storeLocatorResultsContext",{geoCodeLatitude:b,geoCodeLongitude:c,cityId:"-888",fromPage:StoreLocatorContextsJS.fromPage,storeSearch:document.getElementById("inputLocation").value})):MessageHelper.XmarkFieldValidationError("inputLocation","Error in getting current location")})},preRefreshResultsFromZipMobile:function(a){if(reWhiteSpace=new RegExp(/^\s+$/),null!=a.zipOrCity&&reWhiteSpace.test(a.zipOrCity.value)||""==a.zipOrCity.value)return void alert("Error in postcode/city format");var b=null,c="Australia "+a.zipOrCity.value;(b=new google.maps.Geocoder)&&b.geocode({address:c,region:"AU"},function(b,c){c==google.maps.GeocoderStatus.OK?(a.geoCodeLongitude.value=b[0].geometry.location.lng(),a.geoCodeLatitude.value=b[0].geometry.location.lat(),a.submit()):alert(a.zipOrCity.value+" could not be found")})},displayMap:function(a,b){storeLocatorJS.syncMapDisplayStyle();var c=""===StoreLocatorContextsJS.fromPage?"StoreLocator":StoreLocatorContextsJS.fromPage,d=dojo.byId("mapImpl"),e=!0;if("none"==d.style.display&&(e=!1),1==e&&null!=a&&null!=a.centerLatitude&&"undefined"!=a.centerLatitude&&""!=a.centerLatitude){var f=a.centerLatitude,g=a.centerLongitude,h=a.resultSize,i=new google.maps.LatLng(f,g),j={zoom:10,center:i,mapTypeId:google.maps.MapTypeId.ROADMAP,styles:[{featureType:"all",elementType:"all",stylers:[{visibility:"on"},{hue:"#ffb300"},{saturation:-100},{lightness:25}]}]};"ShoppingCart"===c&&(j={zoom:17,center:i,zoomControl:!1,disableDoubleClickZoom:!0,mapTypeControl:!1,scaleControl:!1,scrollwheel:!0,panControl:!1,streetViewControl:!1,draggable:!0,overviewMapControl:!0,overviewMapControlOptions:{opened:!1},mapTypeId:google.maps.MapTypeId.ROADMAP,styles:[{featureType:"all",elementType:"all",stylers:[{visibility:"on"},{hue:"#ffb300"},{saturation:-100},{lightness:25}]}]});var k=new google.maps.Map(dojo.byId("mapImpl"),j);if($(".store-information-box").removeClass("hide"),h>0){var l,m=new Array(h),n=new google.maps.InfoWindow({maxWidth:300}),o=document.URL;-1!=o.indexOf("://")&&o.substring(0,o.indexOf("://")),"true"==a.targetStore&&jQuery(".store-information-box").html("<label> "+a.physicalStore[0].htmlIdentifier+"</label><address>"+a.physicalStore[0].htmlAddress1+'<br></address><span class="opening-hours">'+a.physicalStore[0].htmlAddress5.replace(/,/g,"<br>")+"</span>");for(var p=0;p<h;p++){for(var q="<div class='name-sec'>",r=a.physicalStore[p].htmlAddress5;null!=r&&""!=r&&" "!=r;){var s=r.indexOf("  ")+4,t=r.length,u=r.substring(0,s),v=u.indexOf(":"),w="<span class='hour'>"+u.substring(0,v)+"</span>",x="<span class='hour-rent'>"+u.substring(v+1,u.length)+"</span><br>";r=r.substring(s,t),q=q+w+x}q+="</div>";var y=a.physicalStore[p].htmlIdentifier;y=y.replace(" ","+");var z="/store-detail/"+y,A="<a class='view_store_detail_btn button' href='"+z+"'> VIEW STORE DETAILS </a>";m[p]="<div class='store_popul tiny'><div class='left store_popul_name'><strong>"+a.physicalStore[p].htmlIdentifier+"</strong><br/>"+a.physicalStore[p].htmlAddress1+"<br/>"+a.physicalStore[p].htmlAddress2+"<br/><p class='store_phone_number'>"+a.physicalStore[p].htmlAddress3+"</p></div><div class='left store_popul_day'> </div><div class='left store_popul_time'>"+q+"<br/></div><div style='clear:both;'></div><div class='left store_popul_time_btn'>"+A+"</div></div>";var B=new google.maps.MarkerImage("/wcsstore/KmartStorefrontAssetStore/images/kmart-map-icon@2x.png",null,null,null,new google.maps.Size(41,40));"ShoppingCart"===c?(l=new google.maps.Marker({position:new google.maps.LatLng(a.physicalStore[p].latitude,a.physicalStore[p].longitude),map:k,clickable:!1,icon:B}),google.maps.event.addListener(l,"click",!1),XAddToCartJS.displayOverlay("storeLocatorDialog","model_bg_storelocator")):(l=new google.maps.Marker({position:new google.maps.LatLng(a.physicalStore[p].latitude,a.physicalStore[p].longitude),map:k,clickable:!0,icon:B}),google.maps.event.addListener(l,"click",function(a,b){return function(){n.setContent(m[b]),n.open(k,a)}}(l,p)))}}}},refreshStoreList:function(a){wc.render.updateContext("selectedStoreListContext",{fromPage:a})},hideStoreList:function(){var a=dojo.byId("selectedStoreList"),b=dojo.byId("showStoreListHeader"),c=dojo.byId("hideStoreListHeader");null!=a&&"undefined"!=a&&(a.style.display="none"),null!=b&&"undefined"!=b&&(b.style.display="block"),null!=c&&"undefined"!=c&&(c.style.display="none")},showStoreList:function(){var a=dojo.byId("selectedStoreList"),b=dojo.byId("showStoreListHeader"),c=dojo.byId("hideStoreListHeader");null!=a&&"undefined"!=a&&(a.style.display="block"),null!=b&&"undefined"!=b&&(b.style.display="none"),null!=c&&"undefined"!=c&&(c.style.display="block")},changeCountrySelection:function(a){PhysicalStoreCookieJS.setValueToCookie("WC_stCntry",a),PhysicalStoreCookieJS.clearValueFromCookie("WC_stProv"),PhysicalStoreCookieJS.clearValueFromCookie("WC_stCity"),PhysicalStoreCookieJS.clearValueFromCookie("WC_stFind"),wc.render.updateContext("provinceSelectionsContext",{countryId:a})},changeProvinceSelection:function(a){PhysicalStoreCookieJS.setValueToCookie("WC_stProv",a),PhysicalStoreCookieJS.clearValueFromCookie("WC_stCity"),PhysicalStoreCookieJS.clearValueFromCookie("WC_stFind"),wc.render.updateContext("citySelectionsContext",{provinceId:a})},changeCitySelection:function(a){PhysicalStoreCookieJS.setValueToCookie("WC_stCity",a),PhysicalStoreCookieJS.clearValueFromCookie("WC_stFind")},getSavedCountrySelectionIndex:function(){var a=null,b=PhysicalStoreCookieJS.getValueFromCookie("WC_stCntry");if(null!=b){var c=dojo.byId("selectCountry");if(null!=c&&"undefined"!=c){var d=c.options.length;for(i=0;i<d;i++)b==c.options[i].value&&(a=i,i=d)}}return a},getSavedProvinceSelectionIndex:function(){var a=null,b=PhysicalStoreCookieJS.getValueFromCookie("WC_stProv");if(null!=b){var c=dojo.byId("selectState");if(null!=c&&"undefined"!=c){var d=c.options.length;for(i=0;i<d;i++)b==c.options[i].value&&(a=i,i=d)}}return a},getSavedCitySelectionIndex:function(){var a=null,b=PhysicalStoreCookieJS.getValueFromCookie("WC_stCity");if(null!=b){var c=dojo.byId("selectCity");if(null!=c&&"undefined"!=c){var d=c.options.length;for(i=0;i<d;i++)b==c.options[i].value&&(a=i,i=d)}}return a},showResults:function(){var a=dojo.byId("storeResults"),b=dojo.byId("showRes"),c=dojo.byId("hideRes");null!=a&&"undefined"!=a&&(a.style.display="block"),null!=b&&"undefined"!=b&&(b.style.display="none"),null!=c&&"undefined"!=c&&(c.style.display="block")},hideResults:function(){var a=dojo.byId("storeResults"),b=dojo.byId("showRes"),c=dojo.byId("hideRes");null!=a&&"undefined"!=a&&(a.style.display="none"),null!=b&&"undefined"!=b&&(b.style.display="block"),null!=c&&"undefined"!=c&&(c.style.display="none")},selectedStoreDetailDisplayMap:function(a,b,c){var d={};d.geoCodeLatitude=b,d.geoCodeLongitude=c,d.cityId=a,dojo.xhrGet({url:getAbsoluteURL()+"AjaxStoreLocatorMapResultsView",handleAs:"json-comment-optional",content:d,load:storeLocatorJS.displayMap,error:function(a,b){}});var e=dojo.byId("bopis_table"),f=dojo.byId("no_store_message"),g=dojo.byId("mapImpl");null!=f&&"undefined"!=f?f.focus():null!=g&&"undefined"!=g?g.focus():null!=e&&"undefined"!=e&&e.focus()},validateInputLocation:function(a,b){if(void 0==document.getElementById("inputLocation")||null==document.getElementById("inputLocation"))return void MessageHelper.XmarkFieldValidationError("inputLocation",MessageHelper.messages.MISSING_CITY);var c=document.getElementById("inputLocation").value;if(""!=c&&"postcode / town / street"!=c){c=c.toLowerCase();var d=document.getElementById(c);void 0!=d&&null!=d?(this.changeCitySelection(d.value),this.refreshResultsFromCity(a,b)):this.preRefreshResultsFromZip(a)}},validatePostCode:function(a){function b(a){return d(a)?1!=b.arguments.length&&1==b.arguments[1]:c(a)&&(a.length==e||a.length==f)}function c(a){var b=/^\d+$/;return d(a)?1==c.arguments.length?g:1==c.arguments[1]:b.test(a)}function d(a){return null==a||0==a.length}reNumber=new RegExp(/^(\d|-|\(|\)|\s)+$/);var e=4,f=9,g=!1;return!!reNumber.test(a)&&!!b(a)}};