/*jslint browser: true*/ /*global $, jQuery, alert*/ var $ = jQuery.noConflict(); //LOCATION / PROXIMITY var geocoder; var geocodeCache; var luru; var map; var currentView = 'locations'; var currentMap = ''; var browserLat = 0; var browserLng = 0; var currentZoom = 11; var currentMarkerClickId = ''; //LANGUAGE var langTextNearestLocation = 'YOUR NEAREST LOCATION'; var langTextHoverMouseMap = 'Hover over a location to display a map'; var langTextStoresNear = 'Stores Near '; var langTextStoresNearCurrentLoc = 'Stores Near Your Current Location'; var langTextWesternUnion = 'Western Union™'; var langTextMoneyGram = 'MoneyGram™'; var langTextCheckCashing = 'Check Cashing'; var langTextLicenseServices = 'License Services'; var langTextNetspend = 'NetSpend™'; var langTextGreendot = 'GreenDot™'; var langTextWeBuyGold = 'We Buy Gold'; var langTextPrepaidCell = 'Prepaid Cellular'; var langTextBoost = 'Boost'; var langTextBillPayment = 'Bill Payments'; var langTextMoneyOrder = 'Money Orders'; var langTextATM = 'ATM'; var langTextLoans = 'Personal Loans'; var langTextBusinessChecking = 'Business Check Cashing'; var langTextSeHablaEspanol = 'Se Habla Español'; var langTextBackToStoreList = 'Back to Store List'; var langTextOtherStoresNearby = 'Other Stores Nearby'; var langTextBitcoinServices = 'Bitcoin Services' var doingScroll = false; function getURLParameter(name) { return decodeURI( (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1] ); } function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) { var R = 6371; // Radius of the earth in km var dLat = deg2rad(lat2 - lat1); // deg2rad below var dLon = deg2rad(lon2 - lon1); var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon / 2) * Math.sin(dLon / 2) ; var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); var d = R * c; // Distance in km return d; } function deg2rad(deg) { return deg * (Math.PI / 180) } function initialize() { geocoder = new google.maps.Geocoder(); } function displayLocationMap(loclat, loclng, mapType) { var currentLocObj; var mapEl = 'map'; if (mapType != 'map') { mapEl = mapType; } if (doingScroll) { return; } else { /*doingScroll = true; $('html, body').animate({ scrollTop: $("#" + currentView).offset().top }, 1000, 'swing', function () { doingScroll = false; });*/ } if ($('#' + mapEl).length > 0) { if (currentMap != '' + mapType + '|' + loclat + '|' + loclng) { if(map) currentZoom = map.getZoom(); uluru = { lat: loclat - 0, lng: loclng - 0 }; map = new google.maps.Map(document.getElementById(mapEl), { zoom: currentZoom, center: uluru }); //Add surrounding locations $('#loc-list-new ul#list li').each(function () { var locDist = $(this).find('input[type=hidden].locationDistance').val(); if (locDist < 15 && '' + mapType + '|' + loclat + '|' + loclng != '' + mapType + '|' + $(this).find('input[type=hidden].locationLat').val() + '|' + $(this).find('input[type=hidden].locationLong').val()) //If less than than 3 mi away, add marker { var uluruClose = { lat: $(this).find('input[type=hidden].locationLat').val() - 0, lng: $(this).find('input[type=hidden].locationLong').val() - 0 }; var marker = new google.maps.Marker({ position: uluruClose, map: map, title: $(this).find('.loc-name').text(), //icon: BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE) }); marker.set('id', $(this).prop('id')); google.maps.event.addListener(marker, "click", function () { //infowindow.setContent(this.html); //infowindow.open(map, this); //map.setCenter(this.getPosition()); //map.setZoom(10); doingScroll = true; currentMarkerClickId = this.get('id'); $('html, body').animate({ scrollTop: $("#" + this.get('id')).offset().top - 50 }, 1000, 'swing', function () { $("html, body").animate({ scrollTop: $(document).scrollTop() + 25 }, 100); $("#" + currentMarkerClickId).trigger('mouseover'); doingScroll = false; }); //$("#" + this.get('id')).trigger('mouseover'); /*displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val(), 'map');*/ }); } else { if ( mapType + '|' + loclat + '|' + loclng == '' + mapType + '|' + $(this).find('input[type=hidden].locationLat').val() + '|' + $(this).find('input[type=hidden].locationLong').val() ) { currentLocObj = this; } } }); //Add hovered location var marker = new google.maps.Marker({ position: uluru, map: map, animation: google.maps.Animation.BOUNCE, title: $(currentLocObj).find('.loc-name').text(), //icon: BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE) }); marker.set('id', currentView); google.maps.event.addListener(marker, "click", function () { //infowindow.setContent(this.html); //infowindow.open(map, this); //map.setCenter(this.getPosition()); //map.setZoom(10); doingScroll = true; currentMarkerClickId = this.get('id'); $('html, body').animate({ scrollTop: $("#" + this.get('id')).offset().top - 50 }, 1000, 'swing', function () { $("html, body").animate({ scrollTop: $(document).scrollTop() + 25 }, 100); $("#" + currentMarkerClickId).trigger('mouseover'); doingScroll = false; }); //$("#" + this.get('id')).trigger('mouseover'); /*displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val(), 'map');*/ }); } currentMap = '' + mapType + '|' + loclat + '|' + loclng; } } function geocodeZip(searchZipcode) { if (searchZipcode == '') { //Set distance of each location //if (($('#selectstate').val() == '0|0' || $('#selectstate').length == 0) && $('#keyword').val() == '' && ($('#selectservice').val() == '0' || $('#selectservice').length == 0)) if (!$('body').hasClass('page-id-55') || ($('body').hasClass('page-id-55') && (($('#selectstate').val() == '0|0' || $('#selectstate').length == 0) && $('#keyword').val() == '' && ($('#selectservice').val() == '0' || $('#selectservice').length == 0)) ) ) $('#loc-list-new ul#list li').each(function () { var locDist = getDistanceFromLatLonInKm(browserLat, browserLng, $(this).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val()) / 1.60934; $(this).find('input[type=hidden].locationDistance').val(locDist); $(this).find('.loc-dist').html(parseFloat($(this).find('input[type=hidden].locationDistance').val()).toFixed(1) + ' mi'); if (locDist > 30) //If more than than 30 mi away, remove/hide $(this).remove(); }); if ($('body').hasClass('page-id-55')) { //Attach show map event (mouseover) $('#loc-list-new ul#list li').hover(function (evt) { evt.preventDefault(); //Get location mouseover currentView = $(this).prop('id'); displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val(), 'map'); }); //Attach details event $('#loc-list-new ul#list li a.more-details').click(function (evt) { evt.preventDefault(); //Get location clicked var oldCV = currentView; currentView = $(this).parent().parent().parent().parent().prop('id'); //Set location URL window.history.pushState({ urlPath: '/locations/' + $('#' + currentView).find('.locationSlug').val() }, "Find Check Cashing Location Near You | CFSC | " + $('#' + currentView).find('.loc-name').text(), '/' + $('#' + currentView).find('.locationSlug').val()); /** * DETERMINE IF LOCATION IS IN INDIANA */ var addr3 = $(this).parent().siblings('.list-content').children('.list-content-left').children('.loc-addr3').text(), term = ', IN'; if( addr3.indexOf( term ) != -1 ) { $('.indiana').remove(); $('').prependTo('.leftlocdetaillist'); } else { $('.indiana').remove(); $('').prependTo('.leftlocdetaillist'); } $('#locations-left .nearby-stores').html('Your Nearest Store'); $('#locations-right .nearby-stores').html('< ' + langTextBackToStoreList + ' ' + langTextOtherStoresNearby); $('#lnkBacktoStoreList').click(function () { $('html, body').animate({ scrollTop: $("#submit").offset().top }, 1000, 'swing', function () { doingScroll = false; }); $('#submit').trigger('click'); }); //Move any existing detailed locations back to detail container list $('#detaillist li').appendTo('#locationdetaillistcontainer'); //Add location detail template to left $('#' + currentView.replace('cfsclocation', 'cfsclocationdetail')).appendTo('#detaillist'); $('#detaillist').show(); $('#detaillist li').show(); $('#list li').show(); //Hide clicked location in loc list $('#' + currentView).hide(); //Move locations list to right $('#map').remove(); $('#loc-list-new ul#list:first').appendTo('.map-wrapper #loc-list-new'); //Scroll to position $('html, body').animate({ scrollTop: $("#map-container-new").offset().top - 25 }, 1000, 'swing', function () { $("html, body").animate({ scrollTop: $(document).scrollTop() + 25 }, 100); doingScroll = false; }); //Add local posts $('#detaillist .list-content-right').append('
Gift Card Exchange
Do you have a stack of unused gift cards that keeps getting taller and taller? Bring them in to us and we can turn them into cash! Stop by today to put some extra cash into your pocket.
Learn More
'); //Set detail map displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $('#' + currentView).find('input[type=hidden].locationLong').val(), currentView.replace('cfsclocation', 'cfsclocationdetailmap')); }); } //Sort/Renumber locations sortLocations(); } else{ var address = searchZipcode; geocoder.geocode({ 'address': address }, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { //Set distance of each location $('#loc-list-new ul#list li').each(function () { var locDist = getDistanceFromLatLonInKm(results[0].geometry.location.lat(), results[0].geometry.location.lng(), $(this).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val()) / 1.60934; $(this).find('input[type=hidden].locationDistance').val(locDist); $(this).find('.loc-dist').html(parseFloat($(this).find('input[type=hidden].locationDistance').val()).toFixed(1) + ' mi'); if (locDist > 30) //If more than than 30 mi away, remove/hide $(this).remove(); }); if ($('#loc-list-new.leftloclist ul#list li').length == 0) { $('#loc-list-new.leftloclist ul#list').append('
  • No locations matched your search, please try again.
  • '); } //Attach show map event (mouseover) $('#loc-list-new ul#list li').hover(function (evt) { evt.preventDefault(); //Get location mouseover currentView = $(this).prop('id'); displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val(), 'map'); }); //Attach details event $('#loc-list-new ul#list li a.more-details').click(function (evt) { evt.preventDefault(); //Get location clicked var oldCV = currentView; currentView = $(this).parent().parent().parent().parent().prop('id'); //Set location URL window.history.pushState({ urlPath: '/locations/' + $('#' + currentView).find('.locationSlug').val() }, "Find Check Cashing Location Near You | CFSC | " + $('#' + currentView).find('.loc-name').text(), '/' + $('#' + currentView).find('.locationSlug').val()); $('
    test2
    ').prependTo('.leftlocdetaillist'); $('#locations-left .nearby-stores').html('Your Nearest Store'); $('#locations-right .nearby-stores').html('< ' + langTextBackToStoreList + ' ' + langTextOtherStoresNearby); $('#lnkBacktoStoreList').click(function () { $('#submit').trigger('click'); }); //Move any existing detailed locations back to detail container list $('#detaillist li').appendTo('#locationdetaillistcontainer'); //Add location detail template to left $('#' + currentView.replace('cfsclocation', 'cfsclocationdetail')).appendTo('#detaillist'); $('#detaillist').show(); $('#detaillist li').show(); $('#list li').show(); //Hide clicked location in loc list $('#' + currentView).hide(); //Move locations list to right $('#map').remove(); $('#loc-list-new ul#list:first').appendTo('.map-wrapper #loc-list-new'); //Scroll to position $('html, body').animate({ scrollTop: $("#map-container-new").offset().top - 25 }, 1000, 'swing', function () { doingScroll = false; $("html, body").animate({ scrollTop: $(document).scrollTop() + 25 }, 100); }); //Add local posts $('#detaillist .list-content-right').append('
    Gift Card Exchange
    Do you have a stack of unused gift cards that keeps getting taller and taller? Bring them in to us and we can turn them into cash! Stop by today to put some extra cash into your pocket.
    Learn More
    '); //Set detail map displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $('#' + currentView).find('input[type=hidden].locationLong').val(), currentView.replace('cfsclocation', 'cfsclocationdetailmap')); }); //Sort/Renumber locations sortLocations(); } else { alert("Geocode was not successful for the following reason: " + status); } }); } } function sortLocations() { var locationDistArr = $('#loc-list-new ul#list li input[type=hidden].locationDistance'); locationDistArr.sort(function (a, b) { // convert to float from string a = parseFloat($(a).val()); b = parseFloat($(b).val()); // compare if (a > b) { return 1; } else if (a < b) { return -1; } else { return 0; } }); for (i = 0; i < locationDistArr.length; i++) { $(locationDistArr[i]).parent().appendTo($('#sortContainer')); //$(locationDistArr[i]).parent().appendTo($('#loc-list-new ul#list li')); $(locationDistArr[i]).parent().appendTo($('ul#list')); } //Show closest store in header if (((!$('body').hasClass('page-id-55') && !$('body').hasClass('page-id-1449')) || (($('body').hasClass('page-id-55') || $('body').hasClass('page-id-1449')) && $('#selectstate').val() == '0|0' && $('#address').val() == '') ) && $('ul#list li:first').length > 0 && browserLat != 0) { var uluruhead = { lat: $('#loc-list-new ul#list li:first').find('.locationLat').val() - 0, lng: $('#loc-list-new ul#list li:first').find('.locationLong').val() - 0 }; var mapHead = new google.maps.Map(document.getElementById('nearest-location-map'), { zoom: 15, center: uluruhead }); //Add location marker var marker = new google.maps.Marker({ position: uluruhead, map: mapHead, //animation: google.maps.Animation.BOUNCE, title: $('ul#list li:first').find('.loc-name').text(), //icon: BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE) }); //#loc-list-new $('#nearest-location-details').html('' + langTextNearestLocation + '
    ' + $('#loc-list-new ul#list li:first').find('.loc-name').text() + '
    ' + $('#loc-list-new ul#list li:first').find('.loc-addr').text() + '
    ' + $('#loc-list-new ul#list li:first').find('.loc-addr3').text() + '
    ' + $('#loc-list-new ul#list li:first').find('.loc-phone').html() + '
    '); localStorage.setItem("lastLocName", $('ul#list li:first').find('.loc-name').text()); localStorage.setItem("lastLocAddr", $('ul#list li:first').find('.loc-addr').text()); localStorage.setItem("lastLocAddr3", $('ul#list li:first').find('.loc-addr3').text()); localStorage.setItem("lastLocPh", $('ul#list li:first').find('.loc-phone').html()); $('#nearest-location-details').hover( function() { $(this).css('cursor', 'pointer'); }, function() { $(this).css('cursor', 'default'); } ); $('#nearest-location-details').click(function () { window.open('/locations', '_self'); }); $('#nearest-location').show(); } //Re-number locations /*$('.locations .location').each(function (index) { $(this).find('.locationtitle .locationposition').html((index + 1) + '.'); $(this).show(); });*/ //Show state with closest location /*var currentClosestDist = 100000; var currentClosestState = ''; var currentSortState = ''; $('.resp-tab-content').each(function (idx) { currentSortState = $(this).attr('id'); $(this).find('.locations .location input[type=hidden].locationDistance:first').each(function (idx) { if (parseFloat($(this).val()) < currentClosestDist) { currentClosestDist = parseFloat($(this).val()); currentClosestState = currentSortState; } }); }); if (currentClosestState != '' && currentClosestState != 'Illinois') { $('#' + currentClosestState).trigger('click'); } $('.locations .location:first').trigger('mouseover');*/ } function showPosition(position) { /*for (var t in position) { t = t; }*/ /* $.ajax({ dataType: "json", url: 'https://maps.googleapis.com/maps/api/geocode/json?latlng=' + position.coords.latitude + ',' + position.coords.longitude + '&sensor=true', data: '', success: function(data, status, xhrObj) { data = data; } }); */ browserLat = position.coords.latitude; browserLng = position.coords.longitude; localStorage.setItem("lastLat", browserLat); localStorage.setItem("lastLng", browserLng); } //LOCATION / PROXIMITY function LoadLocations() { //Clear old locations, reset locations view $('ul#list').html(''); $('ul#detaillist').html(''); $('#locationdetaillistcontainer').html(''); $('ul#list').appendTo('#locations-left #loc-list-new.leftloclist'); currentView = 'locations'; $('#locations-left .nearby-stores').html(langTextHoverMouseMap); $('#locations-right .nearby-stores').html(' '); if($('#map').length == 0) $('#locations-right .map-wrapper').append('
    '); //Remove selected state if zip entered if ($('#address').val() != '') $('#selectstate').val('0|0'); //AJAX spinner $('#loc-list-new.leftloclist ul#list').append('
  • Loading Locations...
  • '); //Get browser location if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, function (error) { //alert('An error occurred getting your location. Error code: ' + error.code); console.log('An error occurred getting your location. Error code: ' + error.code); }, { maximumAge: 1800000, timeout: 2000, enableHighAccuracy: true }); } else { //Geolocation is not supported } //Get location data $.getJSON("/wp-content/themes/cfsc2017/js/storelocator/data/cfsc.php", function (data) { var items = []; var locCount = 1; $.each(data, function (key, val) { //Filter variables var addLocToList = true; //Blank data? if (val['name'] === null && val['address'] === null && val['city'] === null && val['state'] === null && val['zip'] === null) { addLocToList = false; } //Conceptual Keyword filter if($('#keyword').val().toLowerCase() != '' & addLocToList){ if (val['name'].toLowerCase().indexOf($('#keyword').val().toLowerCase()) == -1 && val['address'].toLowerCase().indexOf($('#keyword').val().toLowerCase()) == -1 && val['city'].toLowerCase().indexOf($('#keyword').val().toLowerCase()) == -1 && val['state'].toLowerCase().indexOf($('#keyword').val().toLowerCase()) == -1) { addLocToList = false; } } //Service filter if ($('#selectservice').val() != '0' & addLocToList) { //Filter out locs without selected service if ($('#selectservice').val() == 'Western Union' && val['wu'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Money Gram' && val['mg'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Check Cashing' && val['checkcash'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'License Services' && val['license'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Netspend' && val['netspend'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'GreenDot' && val['greendot'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'We Buy Gold' && val['gold'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Prepaid Cellular' && val['cellular'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Boost' && val['boost'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Bill Payment' && val['billpay'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Money Order' && val['moneyorder'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'ATM' && val['atm'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Loans' && val['loans'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Business Check Cashing' && val['commercialcheckcash'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Se Habla Espanol' && val['spanish'] != 'TRUE') addLocToList = false; if ($('#selectservice').val() == 'Bitcoin Services' && val['bitcoinservices'] != 'TRUE') addLocToList = false; } //State filter if ($('#selectstate').val() != '0|0' && $('#address').val() == '' && addLocToList) { //Filter out states other than selected var locselectedstate = $('#selectstate').val().split('|')[0]; if(locselectedstate != val['state']) addLocToList = false; } if(addLocToList) { //Copy template, add to dom var newLocation = $('#locationlisttemplate').clone(); $(newLocation).attr('id', 'cfsclocation' + key); $('#loc-list-new.leftloclist ul#list').append(newLocation); //Populate template with data //Hours if (val['hours'] === null) { $(newLocation).find('.list-24-hours').remove(); } else { if (val['hours'].toLowerCase().indexOf('24 hours') == -1 && val['hours'].toLowerCase().indexOf('24hours') == -1 && val['hours'].toLowerCase().indexOf('24hrs') == -1 && val['hours'].toLowerCase().indexOf('24 hrs') == -1) $(newLocation).find('.list-24-hours').remove(); } //Name, addr, phone, etc //$(newLocation).find('.list-label').html(locCount + '.'); $(newLocation).find('.list-label').html(''); $(newLocation).css('display', 'block'); $(newLocation).find('.loc-dist').html(''); if (val['name'] === null) val['name'] = 'CFSC ' + val['city']; $(newLocation).find('.loc-name').html(val['name']); $(newLocation).find('.loc-addr').html(val['address']); $(newLocation).find('.loc-addr2').html(''); $(newLocation).find('.loc-addr3').html(val['city'] + ', ' + val['state'] + ' ' + val['zip']); if (val['phone'] === null) val['phone'] = ''; $(newLocation).find('.loc-phone').html('' + val['phone'] + ''); $(newLocation).find('.loc-hours').html(val['hours']); $(newLocation).find('.loc-hours').html($(newLocation).find('.loc-hours').html().replace(/,/g, '
    ')); //Services var locServicesTxt = ''; if (val['checkcash'] == 'TRUE') locServicesTxt += ', ' + langTextCheckCashing; if (val['billpay'] == 'TRUE') locServicesTxt += ', ' + langTextBillPayment; if (val['license'] == 'TRUE') locServicesTxt += ', ' + langTextLicenseServices; if (val['moneyorder'] == 'TRUE') locServicesTxt += ', ' + langTextMoneyOrder; if (val['atm'] == 'TRUE') locServicesTxt += ', ' + langTextATM; if (val['wu'] == 'TRUE') locServicesTxt += ', ' + langTextWesternUnion; if (val['mg'] == 'TRUE') locServicesTxt += ', ' + langTextMoneyGram; if (val['netspend'] == 'TRUE') locServicesTxt += ', ' + langTextNetspend; if (val['greendot'] == 'TRUE') locServicesTxt += ', ' + langTextGreendot; if (val['cellular'] == 'TRUE') locServicesTxt += ', ' + langTextPrepaidCell; if (val['boost'] == 'TRUE') locServicesTxt += ', ' + langTextBoost; if (val['loans'] == 'TRUE') locServicesTxt += ', ' + langTextLoans; if (val['gold'] == 'TRUE') locServicesTxt += ', ' + langTextWeBuyGold; if (val['commercialcheckcash'] == 'TRUE') locServicesTxt += ', ' + langTextBusinessChecking; if (val['spanish'] == 'TRUE') locServicesTxt += ', ' + langTextSeHablaEspanol; if (val['bitcoinservices'] == 'TRUE') locServicesTxt += '
  • ' + langTextBitcoinServices + '
  • '; $(newLocation).find('.loc-services').html(locServicesTxt.substring(2, locServicesTxt.length)); //Map link & lat/lng $(newLocation).find('.loc-directions a.directions').attr('href', 'https://maps.google.com/maps?daddr=' + val['name'].replace('&', 'and') + ',+' + val['address'] + ',+' + val['city'] + ',+' + val['state'] + ',+' + val['zip']); $(newLocation).append(''); $(newLocation).append(''); //Create DETAILS template //Copy DETAILS template, add to dom var newLocationDetail = $('#locationdetaillisttemplate').clone(); $(newLocationDetail).attr('id', 'cfsclocationdetail' + key); $('#locationdetaillistcontainer').append(newLocationDetail); //Populate DETAILS template with data //Hours (DETAILS) if (val['hours'] === null) { $(newLocationDetail).find('.list-24-hours').remove(); } else { if (val['hours'].toLowerCase().indexOf('24 hours') == -1 && val['hours'].toLowerCase().indexOf('24hours') == -1 && val['hours'].toLowerCase().indexOf('24hrs') == -1 && val['hours'].toLowerCase().indexOf('24 hrs') == -1) $(newLocationDetail).find('.list-24-hours').remove(); } //Name, addr, phone, etc (DETAILS) $(newLocationDetail).find('.loc-dist').html(''); if (val['name'] === null) val['name'] = 'CFSC ' + val['city']; $(newLocationDetail).find('.loc-name').html(val['name']); $(newLocationDetail).find('.loc-addr').html(val['address']); $(newLocationDetail).find('.loc-addr2').html(''); $(newLocationDetail).find('.loc-addr3').html(val['city'] + ', ' + val['state'] + ' ' + val['zip']); if (val['phone'] === null) val['phone'] = ''; $(newLocationDetail).find('.loc-phone').html('' + val['phone'] + ''); $(newLocationDetail).find('.loc-hours').html(val['hours']); $(newLocationDetail).find('.loc-hours').html($(newLocationDetail).find('.loc-hours').html().replace(/,/g, '
    ')); //Services (DETAILS) var locServicesTxt = ''; if (val['checkcash'] == 'TRUE') locServicesTxt += '
  • ' + langTextCheckCashing + '
  • '; if (val['billpay'] == 'TRUE') locServicesTxt += '
  • ' + langTextBillPayment + '
  • '; if (val['license'] == 'TRUE') locServicesTxt += '
  • ' + langTextLicenseServices + '
  • '; if (val['moneyorder'] == 'TRUE') locServicesTxt += '
  • ' + langTextMoneyOrder + '
  • '; if (val['atm'] == 'TRUE') locServicesTxt += '
  • ' + langTextATM + '
  • '; if (val['wu'] == 'TRUE') locServicesTxt += '
  • ' + langTextWesternUnion + '
  • '; if (val['mg'] == 'TRUE') locServicesTxt += '
  • ' + langTextMoneyGram + '
  • '; if (val['netspend'] == 'TRUE') locServicesTxt += '
  • ' + langTextNetspend + '
  • '; if (val['greendot'] == 'TRUE') locServicesTxt += '
  • ' + langTextGreendot + '
  • '; if (val['cellular'] == 'TRUE') locServicesTxt += '
  • ' + langTextPrepaidCell + '
  • '; if (val['boost'] == 'TRUE') locServicesTxt += '
  • ' + langTextBoost + '
  • '; if (val['loans'] == 'TRUE') locServicesTxt += '
  • ' + langTextLoans + '
  • '; if (val['gold'] == 'TRUE') locServicesTxt += '
  • ' + langTextWeBuyGold + '
  • '; if (val['commercialcheckcash'] == 'TRUE') locServicesTxt += '
  • ' + langTextBusinessChecking + '
  • '; if (val['spanish'] == 'TRUE') locServicesTxt += '
  • ' + langTextSeHablaEspanol + '
  • '; if (val['bitcoinservices'] == 'TRUE') locServicesTxt += '
  • ' + langTextBitcoinServices + '
  • '; $(newLocationDetail).find('.loc-services ul').html(locServicesTxt); //Map link & lat/lng (DETAILS) $(newLocationDetail).find('.loc-map').attr('id', 'cfsclocationdetailmap' + key); $(newLocationDetail).find('.loc-directions a.more-details').attr('href', 'https://maps.google.com/maps?daddr=' + val['name'] + ',+' + val['address'] + ',+' + val['city'] + ',+' + val['state'] + ',+' + val['zip']); //Social Media (intern - eric an) /*$(newLocationDetail).find('.loc-fb').html(val['facebook']); $(newLocationDetail).find('.loc-google').html(val['google']); $(newLocationDetail).find('.loc-yelp').html(val['yelp']); */ if(val['google'] === null) { $(newLocationDetail).find('.fa.fa-google-plus').remove(); } else { $(newLocationDetail).find('.fa.fa-google-plus').attr('href', val['google']); } if(val['facebook'] === null) { $(newLocationDetail).find('.fa.fa-facebook').remove(); } else { $(newLocationDetail).find('.fa.fa-facebook').attr('href', val['facebook']); } if(val['yelp'] === null) { $(newLocationDetail).find('.fa.fa-yelp').remove(); } else { $(newLocationDetail).find('.fa.fa-yelp').attr('href', val['yelp']); } } locCount += 1; }); //Remove ajax spinner $('#locAjaxLoader').remove(); //Check if there are any matches if ($('#loc-list-new.leftloclist ul#list li').length == 0) { $('#loc-list-new.leftloclist ul#list').append('
  • No locations matched your search, please try again.
  • '); } else { //Sort locations if ($('#address').val() != '' || browserLat != 0) { if ($('#address').val() != '') $('#locations-left .nearby-stores').html(langTextStoresNear + $('#address').val()); else $('#locations-left .nearby-stores').html(langTextStoresNearCurrentLoc); geocodeZip($('#address').val()); //sortLocations(); } else { //Attach show map event (mouseover) $('#loc-list-new ul#list li').hover(function (evt) { evt.preventDefault(); //Get location mouseover currentView = $(this).prop('id'); displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val(), 'map'); }); //Attach details event $('#loc-list-new ul#list li a.more-details').click(function (evt) { evt.preventDefault(); //Get location clicked var oldCV = currentView; currentView = $(this).parent().parent().parent().parent().prop('id'); //Set location URL window.history.pushState({ urlPath: '/locations/' + $('#' + currentView).find('.locationSlug').val() }, "Find Check Cashing Location Near You | CFSC | " + $('#' + currentView).find('.loc-name').text(), '/' + $('#' + currentView).find('.locationSlug').val()); $('
    test3
    ').prependTo('.leftlocdetaillist'); $('#locations-left .nearby-stores').html('Your Nearest Store'); $('#locations-right .nearby-stores').html('< ' + langTextBackToStoreList + ' ' + langTextOtherStoresNearby); $('#lnkBacktoStoreList').click(function () { $('#submit').trigger('click'); }); //Move any existing detailed locations back to detail container list $('#detaillist li').appendTo('#locationdetaillistcontainer'); //Add location detail template to left $('#' + currentView.replace('cfsclocation', 'cfsclocationdetail')).appendTo('#detaillist'); $('#detaillist').show(); $('#detaillist li').show(); $('#list li').show(); //Hide clicked location in loc list $('#' + currentView).hide(); //Move locations list to right $('#map').remove(); $('ul#list').appendTo('.map-wrapper #loc-list-new.rightloclist'); //Scroll to position $('html, body').animate({ scrollTop: $("#map-container-new").offset().top - 25 }, 1000, 'swing', function () { doingScroll = false; }); //Set detail map displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $('#' + currentView).find('input[type=hidden].locationLong').val(), currentView.replace('cfsclocation', 'cfsclocationdetailmap')); //Add local posts $('#detaillist .list-content-right').append('
    Gift Card Exchange
    Do you have a stack of unused gift cards that keeps getting taller and taller? Bring them in to us and we can turn them into cash! Stop by today to put some extra cash into your pocket.
    Learn More
    '); }); } //Show first location by default //displayLocationMap($('#' + currentView).find('input[type=hidden].locationLat').val(), $(this).find('input[type=hidden].locationLong').val(), 'map'); $('#loc-list-new.leftloclist ul#list li:first').trigger('mouseover'); setTimeout(function (e) { $('#loc-list-new.leftloclist ul#list li:first').trigger('mouseover'); }, 200); } }).fail(function (jqxhr, textStatus, error) { //var err = textStatus + ", " + error; //console.log("Request Failed: " + err); }); } function LoadLocationsHeaderOnly() { //Check if got location before if (localStorage.getItem("lastLocName") != '' && localStorage.getItem("lastLocName") != null) { //Show closest store in header var uluruhead = { lat: localStorage.getItem("lastLat") - 0, lng: localStorage.getItem("lastLng") - 0 }; var mapHead = new google.maps.Map(document.getElementById('nearest-location-map'), { zoom: 15, center: uluruhead }); //Add location marker var marker = new google.maps.Marker({ position: uluruhead, map: mapHead, //animation: google.maps.Animation.BOUNCE, title: localStorage.getItem("lastLocName"), //icon: BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE) }); $('#nearest-location-details').html('' + langTextNearestLocation + '
    ' + localStorage.getItem("lastLocName") + '
    ' + localStorage.getItem("lastLocAddr") + '
    ' + localStorage.getItem("lastLocAddr3") + '
    ' + localStorage.getItem("lastLocPh") + '
    '); $('#nearest-location-details').hover( function () { $(this).css('cursor', 'pointer'); }, function () { $(this).css('cursor', 'default'); } ); $('#nearest-location-details').click(function () { window.open('/locations', '_self'); }); $('#nearest-location').show(); } //Get browser location if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showPosition, function (error) { //alert('An error occurred getting your location. Error code: ' + error.code); console.log('An error occurred getting your location. Error code: ' + error.code); }, { maximumAge: 1800000, timeout: 2000, enableHighAccuracy: true }); //Get location data $.getJSON("/wp-content/themes/cfsc2017/js/storelocator/data/cfsc.php", function (data) { var items = []; var locCount = 1; $('body').append(''); $.each(data, function (key, val) { //Filter variables var addLocToList = true; if (addLocToList) { //Copy template, add to dom //$('body').append('
    '); var newLocation = $('#locationlisttemplate').clone(); $(newLocation).attr('id', 'cfsclocation' + key); $('#loc-list-new ul#list').append(newLocation); //Populate template with data //Hours if (val['hours'] === null) { $(newLocation).find('.list-24-hours').remove(); } else { if (val['hours'].toLowerCase().indexOf('24 hours') == -1 && val['hours'].toLowerCase().indexOf('24hours') == -1 && val['hours'].toLowerCase().indexOf('24hrs') == -1 && val['hours'].toLowerCase().indexOf('24 hrs') == -1) $(newLocation).find('.list-24-hours').remove(); } //Name, addr, phone, etc //$(newLocation).find('.list-label').html(locCount + '.'); $(newLocation).find('.list-label').html(''); $(newLocation).css('display', 'block'); $(newLocation).find('.loc-dist').html(''); if (val['name'] === null) val['name'] = 'CFSC ' + val['city']; $(newLocation).find('.loc-name').html(val['name']); $(newLocation).find('.loc-addr').html(val['address']); $(newLocation).find('.loc-addr2').html(''); $(newLocation).find('.loc-addr3').html(val['city'] + ', ' + val['state'] + ' ' + val['zip']); if (val['phone'] === null) val['phone'] = ''; $(newLocation).find('.loc-phone').html('' + val['phone'] + ''); $(newLocation).find('.loc-hours').html(val['hours']); $(newLocation).find('.loc-hours').html($(newLocation).find('.loc-hours').html().replace(/,/g, '
    ')); $(newLocation).append(''); $(newLocation).append(''); } locCount += 1; }); //Sort locations if (browserLat != 0) { geocodeZip(''); //sortLocations(); } }).fail(function (jqxhr, textStatus, error) { //var err = textStatus + ", " + error; //console.log("Request Failed: " + err); }); } else { //Geolocation is not supported } } // AUTOGEOLOCATION $(document).ready(function ($) { "use strict"; //Init geolocation initialize(); //Spanish if ($('html').attr('lang') == 'es-ES') { langTextNearestLocation = 'SUCURSALES MÁS CERCANA'; langTextHoverMouseMap = 'Desplácese sobre una ubicación para mostrar un mapa'; langTextStoresNear = 'Sucursales cercanas '; langTextStoresNearCurrentLoc = 'Sucursales cercanas a su ubicación actual'; langTextWesternUnion = 'Western Union™'; langTextMoneyGram = 'MoneyGram™'; langTextCheckCashing = 'Cambio de Cheques'; langTextLicenseServices = 'Servicios de licencia'; langTextNetspend = 'NetSpend™'; langTextGreendot = 'GreenDot™'; langTextWeBuyGold = 'Compramos Oro'; langTextPrepaidCell = 'Servicios de Telefonía Celular Prepagos'; langTextBoost = 'Boost'; langTextBillPayment = 'Pago Electrónico de Facturas'; langTextMoneyOrder = 'Giros Postales'; langTextATM = 'Cajeros Automáticos'; langTextLoans = 'Préstamos de D�a de Pago'; langTextBusinessChecking = 'Cobro de Cheque Empresarial'; langTextSeHablaEspanol = 'Se Habla Español'; langTextBackToStoreList = 'Volver a la lista de la tienda'; langTextOtherStoresNearby = 'Otras tiendas cercanas'; langTextBitcoinServices = 'Servicios de Bitcoin'; } //Load location data if ($('body').hasClass('page-id-55') || $('body').hasClass('page-id-1449')) //if locations page { LoadLocations(); //Attach filtering $('button#submit').click(function (evt) { evt.preventDefault(); LoadLocations(); }); } else { if (getURLParameter('testhead') != null || true) LoadLocationsHeaderOnly(); } });