var atmSearch=function(){var e,t,a,i="https://maps.googleapis.com/maps/api/js",n="AIzaSyAg3tGLHJDNU4GRNwscNl6QEPAyz__bmiU",r=(location.pathname,new URI(window.location.search)),s=[];$.ajaxSetup({cache:!1});var o=$.ajax({url:"data/epos_atm_all.json",dataType:"json"});this.intPrefSearch=function(){var e=r.search(!0).address;$("#search-pref").val(e),$("#search-button").on("click",function(){location.href=window.location.pathname+"?address="+$("#search-pref").val()}),o.done(function(t,a,i){if(prefSelectSet(t,e),!e||""==e)return!1;result=prefSearch(t,e),$("#listTemplate").tmpl(result).appendTo("#searchResult")})},prefSearch=function(e,t){return result={list:[]},$.each(e.items,function(e,a){a.item.pref_id==t&&dateCheck(a.item)&&result.list.push({id:a.item.id,atm:a.item.atm,address:a.item.address,businesshour:a.item.businesshour})}),result},prefSelectSet=function(e,t){prefs={},$.each(e.items,function(e,t){dateCheck(t.item)&&(prefs[t.item.pref_id]=[t.item.pref_id,t.item.pref_name])}),$.each(prefs,function(e,t){$("#search-pref").append('")}),$("#search-pref").val(t)},this.intKeywordSearch=function(){var e=r.search(!0).word;if($("#search-text").val(e),$("#search-button").on("click",function(){location.href=window.location.pathname+"?word="+$("#search-text").val()}),$("#search-text").keypress(function(e){if(13==e.which)return location.href=window.location.pathname+"?word="+$("#search-text").val(),!1}),!e||""==e)return!1;o.done(function(t,a,i){result=keywordSearch(t,e),$("#listTemplate").tmpl(result).appendTo("#searchResult")})},keywordSearch=function(e,t){result={list:[]};var a=new RegExp(toHalfWidth(t));return $.each(e.items,function(e,t){var i=t.item.atm+t.item.address+t.item.ruby+t.item.landmark+t.item.keyword;i=toHalfWidth(i),a.test(i)&&dateCheck(t.item)&&result.list.push({id:t.item.id,atm:t.item.atm,address:t.item.address,businesshour:t.item.businesshour})}),result},this.intMapSearch=function(){var e=document.createElement("script");e.type="text/javascript",e.src=i+"?key="+n+"&callback=atm.getGeolocation",document.getElementsByTagName("head")[0].appendChild(e)},this.getGeolocation=function(){if(navigator.geolocation)navigator.geolocation.getCurrentPosition(function(e){var i=e.coords,n=i.latitude,r=i.longitude;t=n,a=r,setMapSearch(n,r)},function(e){var t=["原因不明のエラーが発生しました。","位置情報の取得が許可されませんでした。","電波状況などで位置情報が取得できませんでした。","位置情報の取得に時間がかかり過ぎてタイムアウトしました。"][e.code];alert(t),setMapSearch(null,null);var a=document.createElement("div"),i=document.createElement("p");a.setAttribute("class","js-warn"),i.setAttribute("class","js-warn-str"),i.innerHTML=t,a.appendChild(i),$("#map").parent().prepend(a)},{enableHighAccuracy:!0,timeout:1e4,maximumAge:0});else{alert("あなたの端末では、現在位置を取得できません。"),setMapSearch(null,null);var e=document.createElement("div"),i=document.createElement("p");e.setAttribute("class","js-warn"),i.setAttribute("class","js-warn-str"),i.innerHTML="あなたの端末では、現在位置を取得できません。",e.appendChild(i),$("#map").parent().prepend(e)}},setMapSearch=function(t,a){e=new google.maps.Map(document.getElementById("map"),{center:{lat:t,lng:a},zoom:15});new google.maps.Marker({position:{lat:t,lng:a},map:e});o.done(function(t,a,i){result=mapSearch(t),plotMarkers(result),google.maps.event.addListener(e,"idle",setVisibleMarkerList)}),$("#gMapLink").prop("href","https://www.google.co.jp/maps/dir/"+t+","+a+"/")},mapSearch=function(e,t){return result={list:[]},$.each(e.items,function(e,t){dateCheck(t.item)&&result.list.push({id:t.item.id,atm:t.item.atm,address:t.item.address,businesshour:t.item.businesshour,lat:t.item.lat,lng:t.item.lng})}),result},plotMarkers=function(t){var a;t.list.forEach(function(t){var i=new google.maps.LatLng(t.lat,t.lng),n=new google.maps.Marker({position:i,map:e,title:t.atm,_lat:t.lat,_lng:t.lng,_id:t.id,_address:t.address,_businesshour:t.businesshour}),r=new google.maps.InfoWindow({content:''+t.atm+""});n.addListener("click",function(){r.open(e,n),a&&a.close(),a=r}),s.push(n)})},setVisibleMarkerList=function(i,n){for(var r=e.getBounds(),o={list:[]},l=0;l0&&(objArraySort(n.list,"range"),$("#listTemplate").tmpl(n).appendTo("#nearResult"))}else detailNotfound()})},setDetailMap=function(t){e=new google.maps.Map(document.getElementById("map"),{center:{lat:parseFloat(t.lat),lng:parseFloat(t.lng)},zoom:15});var a=new google.maps.LatLng(t.lat,t.lng);new google.maps.Marker({position:a,map:e})},detailSearch=function(e,t){var a={},i=[];return $.each(e.items,function(e,n){n.item.id==t&&dateCheck(n.item)&&(images_array=n.item.image_path.split(","),$.each(images_array,function(e,t){i.push({img:t})}),zipcode_h=n.item.zipcode.slice(0,3)+"-"+n.item.zipcode.slice(3),a={id:n.item.id,atm:n.item.atm,ruby:n.item.ruby,zipcode:n.item.zipcode,address:n.item.address,businesshour:n.item.businesshour,lat:n.item.lat,lng:n.item.lng,landmark:n.item.landmark.replace(/\n/g,"
"),image_path:n.item.image_path,images:i,zipcode_h:zipcode_h})}),a},detailNearSearch=function(e,t,a,i){var n={list:[]};return $.each(e.items,function(e,r){if(r.item.id!=t&&dateCheck(r.item)){var s=geolib.getDistance({latitude:r.item.lat,longitude:r.item.lng},{latitude:a,longitude:i});s<1e4&&n.list.push({id:r.item.id,atm:r.item.atm,address:r.item.address,businesshour:r.item.businesshour,lat:r.item.lat,lng:r.item.lng,range:s,range_m:Math.floor(s/1e3*Math.pow(10,2))/Math.pow(10,2)+"km"})}}),n},detailNotfound=function(){alert("ご指定のATMが見つかりません。検索トップページに移動します。"),location.href="https://www.eposcard.co.jp/cashing/cd.html"},dateCheck=function(e){""==e.start_date&&(e.start_date=0),""==e.end_date&&(e.end_date=9999999999999);var t=new Date,a=Math.floor(t.getTime()/1e3);return a>=e.start_date&&a