function BuildLocatorHTML(){var t;if($("#locatorMapView").length>0){var n=JSON.parse(localStorage.getItem("lj")),i=new google.maps.Map(document.getElementById("locator_map"),{center:new google.maps.LatLng(n.lat+.0859,n.long),zoom:10,mapTypeId:google.maps.MapTypeId.ROADMAP,scrollwheel:!1,disableDoubleClickZoom:!0}),r=new google.maps.InfoWindow,u=new google.maps.Marker({position:new google.maps.LatLng(n.lat,n.long),map:i,title:n.name,icon:"/images/map-pins/marker_jdgreenborderdot.png"});google.maps.event.addListener(u,"click",function(t){return function(){r.setContent(createMarkerWindow(n));r.open(i,t)}}(u));n&&($("#locatorMapView").show(),$("#aLocatorLink").attr("href",n.link),$("#aLocatorLink").text(n.name),t=n.AddressHTML,localStorage.getItem("lp")!=null&&(t=t+"<br>"+getPhoneIcon()+localStorage.getItem("lp").toString()),localStorage.getItem("le")!=null&&(t=t+"<br>"+getEmailIcon()+localStorage.getItem("le").toString()),$("#liLocatorAddr").html(t),$("#liLocatorHours").html("<b>Hours:<\/b> "+n.hours))}}function createMarkerWindow(n){var t="<span><b>"+n.name+"<\/b><\/span><br />";return t+(n.AddressHTML+"<br>")}function setDefaultLocatorValues(){$("#locationLocator").hide();$("#locationFindPreferred").hide();$("#locationDD").removeClass("mobile-drop");$("#locationViewLocations").show();$("#locationPhone").hide();$("#locationEmail").hide()}function GetPhoneHTML(n){return getPhoneIcon()+"<a target='_blank' href='tel:"+n+"'>"+n+"<\/a>"}function GetEmailHTML(n){return getEmailIcon()+"<a target='_blank' href='mailto:"+n+"'>"+n+"<\/a>"}function setLocatorLocation(n,t){var i={},r;i.IsLookup=n;i.LID=t;i.Latitude=locatorLatitude;i.Longitude=locatorLongitude;i.Zipcode=$("#zipcodeLocator").val();r={lh:i};$.ajax({type:"POST",url:"/calls/locator.aspx/GetLocation",data:JSON.stringify(r),contentType:"application/json; charset=utf-8",dataType:"json",success:function(t){n||(setLSHtml(t.d.StoreHTML,t.d.StoreDetailHTML,t.d.PhoneHTML,t.d.EmailHTML),localStorage.setItem("lj",t.d.LocJSON),$("#locationLocator").html(t.d.StoreHTML),$("#locationLocator").show(),t.d.PhoneHTML.length>0&&($("#locationPhone").html(GetPhoneHTML(t.d.PhoneHTML)),$("#locationPhone").show(),$(".sunequip_phone").length&&$(".sunequip_phone").attr("href","tel:"+t.d.PhoneHTML)),t.d.EmailHTML.length>0&&($("#locationEmail").html(GetEmailHTML(t.d.EmailHTML)),$("#locationEmail").show()),BuildLocatorHTML());$("#locationLocatorDetail").html(t.d.StoreDetailHTML)},error:function(n){n.responseText!=""&&(alert("We encountered an error retrieving data: "+n.responseText),$("#locationLocatorDetail").html("<li>An error occured selecting finding a store<\/li>"))}})}function setLocatorVariables(){locatorLatitude=localStorage.getItem("latitude");locatorLongitude=localStorage.getItem("longitude");locatorL=localStorage.getItem("ll");locatorD=localStorage.getItem("lld");locatorP=localStorage.getItem("lp");locatorE=localStorage.getItem("le")}function setLSHtml(n,t,i,r){n!=null&&n.length>0&&localStorage.setItem("ll",n);t!=null&&t.length>0&&localStorage.setItem("lld",t);i!=null&&i.length>0&&localStorage.setItem("lp",i);r!=null&&r.length>0&&localStorage.setItem("le",r)}function isHTTPS(){return location.protocol=="https:"}function FindNewLocations(){$("#locationLocatorDetail").html("<li><img src='/images/loading-blocks.gif' /><\/li>");setLocatorLocation(!0,0)}function setNewLocation(n){$("#zipcodeLocator").val("");$(".CartNav").slideToggle("fast");setLocatorLocation(!1,n)}function showFindPreferred(){$("#locationFindPreferred").show()}function getPhoneIcon(){return"<i class='fa fa-phone'><\/i> "}function getEmailIcon(){return"<i class='fa fa-envelope'><\/i> "}function clearLocalStorage(){localStorage.getItem("isCleared")||(localStorage.removeItem("lj"),localStorage.removeItem("ll"),localStorage.removeItem("lp"),localStorage.removeItem("le"),localStorage.removeItem("lld"),localStorage.removeItem("latitude"),localStorage.removeItem("longitude"),localStorage.setItem("isCleared","true"))}clearLocalStorage();var locatorLatitude=0,locatorLongitude=0,locatorL="",locatorP="",locatorE="",locatorD="",doLookup=!0;setLocatorVariables();doLookup=isHTTPS();locatorL!=null&&($("#locationLocator").show(),$("#locationLocator").html(locatorL),BuildLocatorHTML(),showFindPreferred(),doLookup=!1);locatorD!=null&&($("#locationLocatorDetail").html(locatorD),showFindPreferred(),doLookup=!1);locatorP!=null&&($("#locationPhone").show(),$("#locationPhone").html(GetPhoneHTML(locatorP)),$(".sunequip_phone").length&&$(".sunequip_phone").attr("href","tel:"+locatorP));locatorE!=null&&($("#locationEmail").show(),$("#locationEmail").html(GetEmailHTML(locatorE)));doLookup?locatorLatitude!=null&&locatorLongitude!=null&&locatorLatitude!=0&&locatorLongitude!=0?(setLocatorLocation(!1,0),showFindPreferred()):navigator.geolocation?(navigator.geolocation.getCurrentPosition(function(n){localStorage.setItem("latitude",n.coords.latitude);localStorage.setItem("longitude",n.coords.longitude);setLocatorVariables();setLocatorLocation(!1,0)}),showFindPreferred()):setDefaultLocatorValues():doLookup||isHTTPS()||setDefaultLocatorValues()