storeLocatorJS={resultGeocodeLatitude:null,resultGeocodeLongitude:null,resultCityId:null,resultFromPage:null,resultSearchTerm:null,gmarkers:null,initProvinceSelections:function(){var b=dojo.byId("selectCountry").selectedIndex;if(b>-1){var a=b;var c=storeLocatorJS.getSavedCountrySelectionIndex();if(c!=null&&c!=b){a=c;dojo.byId("selectCountry").options[a].selected=true}wc.render.updateContext("provinceSelectionsContext",{countryId:dojo.byId("selectCountry").options[a].value})}},initZipCodeSelections:function(){var b=PhysicalStoreCookieJS.getValueFromCookie("WC_stFind");var a=PhysicalStoreCookieJS.getValueFromCookie("WC_stZip");if(a!=null){dojo.byId("searchByGeoNodeForm").textZipPostalCode.value=a;if(b!=null){if(b==2){storeLocatorJS.preRefreshResultsFromZip(dojo.byId("searchByGeoNodeForm"),dojo.byId("searchByGeoNodeForm").pageName.value)}}}},refreshCities:function(){var c=PhysicalStoreCookieJS.getValueFromCookie("WC_stFind");var b=dojo.byId("selectState").selectedIndex;if(b>-1){var a=b;var d=storeLocatorJS.getSavedProvinceSelectionIndex();if(d!=null&&d!=b){a=d;dojo.byId("selectState").options[a].selected=true}wc.render.updateContext("citySelectionsContext",{provinceId:dojo.byId("selectState").options[a].value})}},refreshSearchResults:function(f){var c=PhysicalStoreCookieJS.getValueFromCookie("WC_stFind");var e=dojo.byId("selectCity").selectedIndex;if(e>-1){var a=e;var d=storeLocatorJS.getSavedCitySelectionIndex();if(d!=null&&d!=e){a=d;dojo.byId("selectCity").options[a].selected=true}if(c!=null){if(c==1){wc.render.updateContext("storeLocatorResultsContext",{cityId:dojo.byId("selectCity").options[a].value,geoCodeLatitude:"-888",geoCodeLongitude:"-888",fromPage:f})}}}var b=PhysicalStoreCookieJS.getValueFromCookie("WC_stZip");if(b!=null){dojo.byId("searchByGeoNodeForm").textZipPostalCode.value=b;if(c!=null){if(c==2){storeLocatorJS.preRefreshResultsFromZip(dojo.byId("searchByGeoNodeForm"))}}}},addPhysicalStore:function(a,b){if(PhysicalStoreCookieJS.isAddOneStoreIdExceedMax()==true){if(document.getElementById("addPhysicalStoreToCookieButton"+b)!=null){MessageHelper.formErrorHandleClient("addPhysicalStoreToCookieButton"+b,MessageHelper.messages.EXCEED_PHYSICAL_STORE_SIZE);return false}else{MessageHelper.displayErrorMessage(MessageHelper.messages.EXCEED_PHYSICAL_STORE_SIZE);return false}}PhysicalStoreCookieJS.addToCookie(a);storeLocatorJS.showRemoveOption(a);return true},removePhysicalStore:function(a){PhysicalStoreCookieJS.removeFromCookie(a);PhysicalStoreCookieJS.clearPickUpStoreIdFromCookie(a);storeLocatorJS.showAddOption(a)},showRemoveOption:function(c){var b=dojo.byId("addPhysicalStoreToCookieDisabled"+c);var a=dojo.byId("addPhysicalStoreToCookie"+c);if(b!=null&&b!="undefined"){b.style.display="block"}if(a!=null&&a!="undefined"){a.style.display="none"}},showAddOption:function(c){var b=dojo.byId("addPhysicalStoreToCookieDisabled"+c);var a=dojo.byId("addPhysicalStoreToCookie"+c);if(b!=null&&b!="undefined"){b.style.display="none"}if(a!=null&&a!="undefined"){a.style.display="block"}},manageCookieFromCity:function(){PhysicalStoreCookieJS.setValueToCookie("WC_stFind",1)},refreshResultsFromCity:function(a,b){if(a.textZipPostalCode.value!=null&&a.textZipPostalCode.value!=""){storeLocatorJS.preRefreshResultsFromZip(a)}},refreshStoreList:function(a){wc.render.updateContext("selectedStoreListContext",{fromPage:a})},hideStoreList:function(){var c=dojo.byId("selectedStoreList");var b=dojo.byId("showStoreListHeader");var a=dojo.byId("hideStoreListHeader");if(c!=null&&c!="undefined"){c.style.display="none"}if(b!=null&&b!="undefined"){b.style.display="block"}if(a!=null&&a!="undefined"){a.style.display="none"}},showStoreList:function(){var c=dojo.byId("selectedStoreList");var b=dojo.byId("showStoreListHeader");var a=dojo.byId("hideStoreListHeader");if(c!=null&&c!="undefined"){c.style.display="block"}if(b!=null&&b!="undefined"){b.style.display="none"}if(a!=null&&a!="undefined"){a.style.display="block"}},changeCountrySelection:function(b){PhysicalStoreCookieJS.setValueToCookie("WC_stCntry",b);PhysicalStoreCookieJS.clearValueFromCookie("WC_stProv");PhysicalStoreCookieJS.clearValueFromCookie("WC_stCity");PhysicalStoreCookieJS.clearValueFromCookie("WC_stFind");wc.render.updateContext("provinceSelectionsContext",{countryId:b});var a="";PhysicalStoreCookieJS.clearValueFromCookie("WC_stZip");document.getElementById("textZipPostalCode").value=""},changeProvinceSelection:function(b){PhysicalStoreCookieJS.setValueToCookie("WC_stProv",b);PhysicalStoreCookieJS.clearValueFromCookie("WC_stCity");PhysicalStoreCookieJS.clearValueFromCookie("WC_stFind");wc.render.updateContext("citySelectionsContext",{provinceId:b});var a="";PhysicalStoreCookieJS.clearValueFromCookie("WC_stZip");document.getElementById("textZipPostalCode").value=""},changeCitySelection:function(b){PhysicalStoreCookieJS.setValueToCookie("WC_stCity",b);PhysicalStoreCookieJS.clearValueFromCookie("WC_stFind");var a="";PhysicalStoreCookieJS.clearValueFromCookie("WC_stZip");document.getElementById("textZipPostalCode").value=""},getSavedCountrySelectionIndex:function(){var b=null;var a=PhysicalStoreCookieJS.getValueFromCookie("WC_stCntry");if(a!=null){var d=dojo.byId("selectCountry");if(d!=null&&d!="undefined"){var c=d.options.length;for(i=0;i<c;i++){if(a==d.options[i].value){b=i;i=c}}}}return b},getSavedProvinceSelectionIndex:function(){var b=null;var d=PhysicalStoreCookieJS.getValueFromCookie("WC_stProv");if(d!=null){var a=dojo.byId("selectState");if(a!=null&&a!="undefined"){var c=a.options.length;for(i=0;i<c;i++){if(d==a.options[i].value){b=i;i=c}}}}return b},getSavedCitySelectionIndex:function(){var a=null;var c=PhysicalStoreCookieJS.getValueFromCookie("WC_stCity");if(c!=null){var d=dojo.byId("selectCity");if(d!=null&&d!="undefined"){var b=d.options.length;for(i=0;i<b;i++){if(c==d.options[i].value){a=i;i=b}}}}return a},manageCookieFromZip:function(a){PhysicalStoreCookieJS.setValueToCookie("WC_stZip",a);PhysicalStoreCookieJS.setValueToCookie("WC_stFind",2)},saveResults:function(a){storeLocatorJS.resultGeocodeLatitude=a.properties.geoCodeLatitude;storeLocatorJS.resultGeocodeLongitude=a.properties.geoCodeLongitude;storeLocatorJS.resultFromPage=a.properties.fromPage;storeLocatorJS.resultSearchTerm=a.properties.searchTerm},displayMap:function(o,h){var e=new google.maps.InfoWindow();var g,f=0;var j;var b="//maps.gstatic.com/intl/en_us/mapfiles/";var m=dojo.byId("map_canvas");if(o!=null&&o.centerLatitude!=null&&o.centerLatitude!="undefined"&&o.centerLatitude!=""){var d=o.centerLatitude;var p=o.centerLongitude;var l=o.resultSize;var c=storeLocatorJS.resultSearchTerm;if(l>0){gmarkers=new Array();var a=new google.maps.Map(document.getElementById("map_canvas"),{zoom:8,center:new google.maps.LatLng(d,p),mapTypeId:google.maps.MapTypeId.ROADMAP});var k="http://www.google.com/intl/en_us/mapfiles/ms/micons/green.png";g=new google.maps.Marker({position:new google.maps.LatLng(d,p),map:a,icon:k});for(var f=0;f<l;f++){var n=o.physicalStore[f].htmlStoreHours;j=new google.maps.MarkerImage(b+"marker"+String.fromCharCode(65+f)+".png",new google.maps.Size(20,34),new google.maps.Point(0,0),new google.maps.Point(10,34));g=new google.maps.Marker({position:new google.maps.LatLng(o.physicalStore[f].latitude,o.physicalStore[f].longitude),map:a,icon:j});google.maps.event.addListener(g,"click",(function(q,r){return function(){var u=o.physicalStore[r].htmlAddress1+" "+o.physicalStore[r].htmlCity+" "+o.physicalStore[r].htmlState+" "+o.physicalStore[r].htmlZipcode;var t='<table id="sl-infowindow"><tr><td class="sl-iw1"><b>West Marine '+o.physicalStore[r].htmlCity+"</b><br />"+o.physicalStore[r].htmlAddress1+"<br/>"+o.physicalStore[r].htmlCity+", "+o.physicalStore[r].htmlState+"<br/>"+o.physicalStore[r].htmlZipcode+"<br/>"+o.physicalStore[r].htmlPhone+'<br/><a target="_blank" href="http://maps.google.com/maps?f=d&hl=en&saddr=&daddr='+u+'&sll=&sspn=&ie=UTF8&z=16"/>Get Directions</a></td>';if(storeLocatorJS.resultFromPage=="StoreLocator"){t=t+'<td class="sl-iw2a">'+o.physicalStore[r].htmlStoreHours+"</td></tr></table>"}if(storeLocatorJS.resultFromPage!="StoreLocator"){if(o.physicalStore[r].htmlSiteToStore=="false"){var s=o.physicalStore[r].htmlStoreId;t=t+'<td class="sl-iw2b">'+o.physicalStore[r].htmlStoreHours+'<br /><a class="btn1" href="Javascript:PhysicalStoreCookieJS.setPickUpStoreIdToCookie('+s+');ShipmodeSelectionExtJS.submitStoreSelectionForm(document.orderItemStoreSelectionForm);" id="storeSelection_NextButton" onmouseout="JavaScript:this.blur();" onblur="JavaScript:this.blur();">Ship to this Store</a></td></tr></table>'}else{t=t+'<td class="sl-iw2b">'+o.physicalStore[r].htmlStoreHours+'<br /><b class="redtxt">Temporarily unavailable<br>for Ship to Store</b></td></tr></table>'}}e.setContent(t);e.open(a,q)}})(g,f));gmarkers[f]=g}}}},infoWindow:function(a){google.maps.event.trigger(gmarkers[a],"click")},getInvalidChars:function(a,d){var e=new Array();for(var c=0;c<a.length;c++){var b=a.charAt(c);if(d.indexOf(b)>=0){e[e.length]=b}}return e},preRefreshResultsFromZip:function(c,f){var b="true";reWhiteSpace=new RegExp(/^\s+$/);if(c.textZipPostalCode.value==""){MessageHelper.formErrorHandleClient(c.textZipPostalCode.id,MessageHelper.messages.MISSING_ZIPCODE_FIELD);return}if(reWhiteSpace.test(c.textZipPostalCode.value)){MessageHelper.formErrorHandleClient(c.textZipPostalCode.id,MessageHelper.messages.MISSING_ZIPCODE_FIELD);return}var a=document.getElementById("textZipPostalCode").value;var e=storeLocatorJS.getInvalidChars("!@$%^&*()+=[]\\'/{}|\":<>?",a);if(e.length==0){dojo.byId("ErrorMessageText").innerHTML="";dojo.byId("MessageArea").style.display="none";storeLocatorJS.manageCookieFromZip(a);var d=new google.maps.Geocoder();d.geocode({address:a},function(k,g){if(g==google.maps.GeocoderStatus.OK){var j=k[0].geometry.location.toString().split(",");var l=parseFloat(j[0].substring(1));var h=parseFloat(j[1].substring(0,j[1].length-1));b="false"}else{l="36.9102778";h="-121.7558333";b="true"}wc.render.updateContext("storeLocatorResultsContext",{geoCodeLatitude:l,geoCodeLongitude:h,searchTerm:a,fromPage:f,noGeoCode:b})})}else{dojo.byId("ErrorMessageText").innerHTML="Your search contains prohibitied character(s). Please remove [ "+e.join().replace(/,/g," ")+" ] and try again.";dojo.byId("MessageArea").style.display="block";return}}};
