').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('
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.
').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('
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.
').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('
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.
');
});
}
//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();
}
});