{"id":3024,"date":"2021-05-02T23:02:47","date_gmt":"2021-05-02T23:02:47","guid":{"rendered":"https:\/\/scolicare.wpengine.com\/?page_id=3024"},"modified":"2021-05-02T23:02:47","modified_gmt":"2021-05-02T23:02:47","slug":"patients-find-a-clinic","status":"publish","type":"page","link":"https:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/","title":{"rendered":"Find a Clinic Near You"},"content":{"rendered":"\n<section class=\"backgroundgradient\">\n<div class=\"gb-element-4ae12919 grid-container\">\n<div class=\"wp-block-columns c_align_item is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\">\n<h1 class=\"gb-text gb-text-ab76d07f\">Find a Clinic Near You<\/h1>\n<\/div>\n<\/div>\n<\/div>\n<\/section>\n\n\n\n<section class=\"c_bread_crum\">\n<div class=\"gb-element-0bc33464 grid-container\">\n<div class=\"wp-block-columns c_align_item is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"flex-basis:100%\"><\/div>\n<\/div>\n\n\n<span><span><a href=\"https:\/\/scolicare.com\/denver-colorado\/\"><svg style=\"margin-bottom: -3px; padding-right: 5px;\" width=\"18\" height=\"20\" viewBox=\"0 0 18 21\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n<path d=\"M7.54916 1.45316C8.38719 0.746164 9.61281 0.746163 10.4508 1.45316L17.2008 7.1477C17.7076 7.57521 18 8.20446 18 8.86745V18.6704C18 19.6369 17.2165 20.4204 16.25 20.4204H13.25C12.2835 20.4204 11.5 19.6369 11.5 18.6704V13.6704C11.5 13.2562 11.1642 12.9204 10.75 12.9204H7.25C6.83579 12.9204 6.5 13.2562 6.5 13.6704V18.6704C6.5 19.6369 5.7165 20.4204 4.75 20.4204H1.75C0.783502 20.4204 0 19.6369 0 18.6704V8.86745C0 8.20446 0.292405 7.57521 0.799155 7.1477L7.54916 1.45316Z\" fill=\"#00B3D7\"\/>\n<\/svg><\/a><\/span><\/span>\n<\/div>\n<\/section>\n\n\n\n<div class=\"gb-element-08d570c3\">\n<div class=\"gb-element-496cb906\">\n<p class=\"gb-text gb-text-019a675d\">Select your \u2018Current Location\u2019 or enter a country, city or suburb to find your closest ScoliCare Clinic, ScoliBrace Provider or ScoliBalance Provider. ScoliCare Clinics are premium providers of ScoliBrace and ScoliBalance.<br><a href=\"https:\/\/scolicare.com\/adelaide\/\"><\/a><\/p>\n\n\n\n    <section id=\"locator\" class=\"content-block\" >\n        <div class=\"content-location container\">\n            <div class=\"location-filters row\">\n                <button id=\"current-location\" type=\"button\" class=\"btn btn-primary btn-block\">Use current location<\/button>\n                <input type=\"text\" id=\"alternate-address\" placeholder=\"Search City\/Suburb\">\n                <button id=\"reset-filters\" type=\"button\" class=\"btn btn-primary btn-block\">Reset all search fields<\/button>\n            <\/div>\n\n            <div class=\"ajax-loading d-none\" style=\"display: none\">\n                <span class=\"fas fa-spinner fa-spin fa-8x\"><\/span>\n            <\/div>\n\n            <div class=\"map-list\" style=\"margin-bottom: 0;\">\n                                    <div id=\"scolicare_map\" class=\"scolicare-map\"><\/div>\n                                \n                <!-- Rest of your existing HTML\/PHP code remains the same -->\n                <div id=\"scolicare_markers\" style=\"display: none;\">\n                    \n                    <div data-id='391' data-lat='-16.919255' data-lng='145.769377' data-html='<a href=\"http:\/\/scoilicare.com\" target=\"_blank\">ScoliCare Affiliate Clinic &#8211; Cairns<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300883884\">1300883884<\/a><\/div>' data-category='scolicare-affiliate'><\/div><div data-id='396' data-lat='-42.8661536' data-lng='147.3040991' data-html='<a href=\"http:\/\/scoilicare.com\" target=\"_blank\">ScoliCare Affiliate Clinic &#8211; Hobart<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300883884\">1300883884<\/a><\/div>' data-category='scolicare-affiliate'><\/div><div data-id='389' data-lat='-31.9419048' data-lng='115.8405079' data-html='<a href=\"https:\/\/www.scolicare.com\/\" target=\"_blank\">ScoliCare Affiliate Clinic &#8211; Perth<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300883884\">1300883884<\/a><\/div>' data-category='scolicare-affiliate'><\/div><div data-id='393' data-lat='-27.8801803' data-lng='153.3836576' data-html='<a href=\"https:\/\/www.scolicare.com\" target=\"_blank\">ScoliCare Affiliate Clinic \u2013 Gold Coast<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300883884\">1300883884<\/a><\/div>' data-category='scolicare-affiliate'><\/div><div data-id='387' data-lat='-34.9284989' data-lng='138.6007456' data-html='<a href=\"https:\/\/scolicare.com\" target=\"_blank\">The ScoliCare Clinic Adelaide<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300883884\">1300883884<\/a><\/div>' data-category='scolibrace-provider'><\/div><div data-id='385' data-lat='-27.3903934' data-lng='153.0232891' data-html='<a href=\"https:\/\/www.scolicare.com\" target=\"_blank\">The ScoliCare Clinic Brisbane<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300883884\">1300883884<\/a><\/div>' data-category='scolicare-clinic'><\/div><div data-id='349' data-lat='-37.8440693' data-lng='144.9777112' data-html='<a href=\"https:\/\/www.melbournescoliosisclinic.com.au\/\" target=\"_blank\">The ScoliCare Clinic Melbourne<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300856118\">1300856118<\/a><\/div>' data-category='scolicare-clinic'><\/div><div data-id='381' data-lat='-33.965661' data-lng='151.1330531' data-html='<a href=\"https:\/\/www.sydneyscoliosisclinic.com.au\/\" target=\"_blank\">The ScoliCare Clinic Sydney (South)<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:1300650205\">1300650205<\/a><\/div>' data-category='scolicare-clinic'><\/div><div data-id='1146' data-lat='40.4673309' data-lng='-79.9185208' data-html='<a href=\"https:\/\/www.google.com\" target=\"_blank\">no text, just a sample<\/a><br><div class=\"details\"><span class=\"fas fa-fw fa-phone\"><\/span> <a href=\"tel:123452\">123452<\/a><\/div>' data-category='scolibrace-provider'><\/div>                <\/div>\n\n                <div class=\"mb-3\">\n                    <div class=\"row info-boxes\">\n                                                    <div class=\"col-sm-6 col-lg-4 d-flex align-items-center\">\n                                <div class=\"px-4 py-2 mr-2 rounded\" style=\"background-image: linear-gradient(to right, #005894, #005894);\"><\/div>\n                                <p class=\"mb-0\">ScoliCare Clinic<\/p>\n                            <\/div>\n                                                    <div class=\"col-sm-6 col-lg-4 d-flex align-items-center\">\n                                <div class=\"px-4 py-2 mr-2 rounded\" style=\"background-image: linear-gradient(to right, #e06535, #e06535);\"><\/div>\n                                <p class=\"mb-0\">ScoliBalance Provider<\/p>\n                            <\/div>\n                                                    <div class=\"col-sm-6 col-lg-4 d-flex align-items-center\">\n                                <div class=\"px-4 py-2 mr-2 rounded\" style=\"background-image: linear-gradient(to right, #e06535 50%,#13b0d9 50%);\"><\/div>\n                                <p class=\"mb-0\">ScoliBalance\/ScoliBrace Provider<\/p>\n                            <\/div>\n                                                    <div class=\"col-sm-6 col-lg-4 d-flex align-items-center\">\n                                <div class=\"px-4 py-2 mr-2 rounded\" style=\"background-image: linear-gradient(to right, #13b0d9, #13b0d9);\"><\/div>\n                                <p class=\"mb-0\">ScoliBrace Provider<\/p>\n                            <\/div>\n                                                    <div class=\"col-sm-6 col-lg-4 d-flex align-items-center\">\n                                <div class=\"px-4 py-2 mr-2 rounded\" style=\"background-image: linear-gradient(to right, #faa334, #faa334);\"><\/div>\n                                <p class=\"mb-0\">Your location<\/p>\n                            <\/div>\n                                            <\/div>\n                <\/div>\n\n                <div class=\"table-responsive\">\n                    <table class=\"table\">\n                        <thead>\n                        <tr>\n                            <th scope=\"col\">Clinic<\/th>\n                            <th scope=\"col\" class=\"d-none d-lg-table-cell\">Distance<\/th>\n                            <th scope=\"col\" class=\"d-none d-md-table-cell\">Contact details<\/th>\n                            <th scope=\"col\" class=\"d-none d-lg-table-cell\">Website<\/th>\n                        <\/tr>\n                        <\/thead>\n\n                        <tbody>\n                        \n                                                    <tr>\n                                <td colspan=\"4\" class=\"text-center\">\n                                                                            Please use the search above to find clinics near you\n                                                                    <\/td>\n                            <\/tr>\n                                                <\/tbody>\n                    <\/table>\n                <\/div>\n            <\/div>\n        <\/div><!-- .content-location.container -->\n    <\/section><!-- #locator.content-block -->\n\n<!-- Updated JavaScript with ScoliCare Clinic priority -->\n<script type=\"text\/javascript\">\n(function($){\n    \/\/ Map variables\n    let map;\n    let isUserSearch = false;\n    let markers = [];\n    let infoWindow;\n    let userLocationMarker = null;\n    let watchId = null;\n    let autocomplete;\n    let mapInitialized = false;\n    let googleMapsLoaded = false;\n    let clinicMarkers = {};\n\n    \/\/ Pre-create icon origin\n    const baseIconOrigin = (location && location.origin) ? location.origin : window.location.origin;\n    let categoryIcons = {};\n\n    function initMap() {\n        console.log('Initializing Google Maps...');\n        \n        \/\/ Check if map container exists\n        const mapContainer = document.getElementById('scolicare_map');\n        if (!mapContainer) {\n            console.error('Map container not found');\n            return;\n        }\n        \n        \/\/ Default center\n        const defaultCenter = { lat: -25.2744, lng: 133.7751 };\n        \n        try {\n            \/\/ Create map\n            map = new google.maps.Map(mapContainer, {\n                zoom: 4,\n                center: defaultCenter,\n                mapTypeControl: true,\n                streetViewControl: false,\n                styles: [\n                    {\n                        \"featureType\": \"administrative\",\n                        \"elementType\": \"labels.text.fill\",\n                        \"stylers\": [{\"color\": \"#444444\"}]\n                    },\n                    {\n                        \"featureType\": \"landscape\",\n                        \"elementType\": \"all\",\n                        \"stylers\": [{\"color\": \"#f2f2f2\"}]\n                    },\n                    {\n                        \"featureType\": \"poi\",\n                        \"elementType\": \"all\",\n                        \"stylers\": [{\"visibility\": \"off\"}]\n                    },\n                    {\n                        \"featureType\": \"road\",\n                        \"elementType\": \"all\",\n                        \"stylers\": [{\"saturation\": -100}, {\"lightness\": 45}]\n                    },\n                    {\n                        \"featureType\": \"road.highway\",\n                        \"elementType\": \"all\",\n                        \"stylers\": [{\"visibility\": \"simplified\"}, {\"color\": \"#cccccc\"}]\n                    },\n                    {\n                        \"featureType\": \"road.highway\",\n                        elementType: \"labels.text.fill\",\n                        stylers: [{lightness: \"-36\"}]\n                    },\n                    {\n                        \"featureType\": \"road.highway\",\n                        elementType: \"labels.icon\",\n                        stylers: [{lightness: \"100\"}, {visibility: \"off\"}]\n                    },\n                    {\n                        \"featureType\": \"road.arterial\",\n                        elementType: \"labels.icon\",\n                        stylers: [{visibility: \"off\"}]\n                    },\n                    {\n                        \"featureType\": \"transit\",\n                        elementType: \"all\",\n                        stylers: [{color: \"#606b8b\"}, {visibility: \"off\"}]\n                    },\n                    {\n                        \"featureType\": \"water\",\n                        elementType: \"all\",\n                        stylers: [{color: \"#a7adbe\"}, {visibility: \"on\"}]\n                    },\n                    {\n                        \"featureType\": \"water\",\n                        elementType: \"labels\",\n                        stylers: [{weight: \"0.01\"}, {lightness: \"70\"}]\n                    }\n                ]\n            });\n\n            infoWindow = new google.maps.InfoWindow();\n            console.log('Google Maps initialized successfully');\n\n            \/\/ populate categoryIcons now that google.maps is available\n            categoryIcons = {\n                'scolicare-clinic': {\n                    path: google.maps.SymbolPath.CIRCLE,\n                    fillColor: '#005894',\n                    fillOpacity: 1,\n                    strokeColor: '#FFFFFF',\n                    strokeWeight: 2,\n                    scale: 10\n                },\n                'scolibalance-provider': {\n                    path: google.maps.SymbolPath.CIRCLE,\n                    fillColor: '#e06535',\n                    fillOpacity: 1,\n                    strokeColor: '#FFFFFF',\n                    strokeWeight: 2,\n                    scale: 10\n                },\n                'scolibalance-scolibrace-provider': {\n                    path: google.maps.SymbolPath.CIRCLE,\n                    fillColor: '#e06535',\n                    fillOpacity: 1,\n                    strokeColor: '#13b0d9',\n                    strokeWeight: 3,\n                    scale: 10\n                },\n                'scolibrace-provider': {\n                    path: google.maps.SymbolPath.CIRCLE,\n                    fillColor: '#13b0d9',\n                    fillOpacity: 1,\n                    strokeColor: '#FFFFFF',\n                    strokeWeight: 2,\n                    scale: 10\n                },\n                'Current-location': {\n                    url: baseIconOrigin + '\/wp-content\/uploads\/2025\/10\/current-location-2.png',\n                    scaledSize: new google.maps.Size(32, 32),\n                    anchor: new google.maps.Point(16, 32)\n                }\n            };\n\n            \/\/ Initialize autocomplete\n            const addressInput = document.getElementById('alternate-address');\n            if (addressInput) {\n                autocomplete = new google.maps.places.Autocomplete(addressInput, { \n                    types: ['(regions)'],\n                    fields: ['geometry', 'name', 'formatted_address']\n                });\n                \n                \/\/ FIXED: Simplified autocomplete handler\n                autocomplete.addListener('place_changed', function() {\n                    console.log('Place selected from autocomplete');\n                    handlePlaceSelection();\n                });\n            }\n\n            \/\/ Wait for map to be fully ready using idle event\n            google.maps.event.addListenerOnce(map, 'idle', function() {\n                console.log('Map is fully loaded and idle');\n                mapInitialized = true;\n                \n                \/\/ Handle URL parameters after map is initialized\n                const urlLat = parseFloat(getUrlParameter('latitude'));\n                const urlLng = parseFloat(getUrlParameter('longitude'));\n                if (!isNaN(urlLat) && !isNaN(urlLng) && \n                    urlLat >= -90 && urlLat <= 90 && \n                    urlLng >= -180 && urlLng <= 180) {\n                    \n                    updateLocationAndTable(\n                        { lat: urlLat, lng: urlLng },\n                        getUrlParameter('location') || 'Current Location'\n                    );\n                }\n                \n                loadMarkers();\n                setupClinicClickHandlers();\n            });\n            \n            \/\/ Add resize listener to handle container size changes\n            google.maps.event.addDomListener(window, 'resize', function() {\n                if (map) {\n                    google.maps.event.trigger(map, 'resize');\n                }\n            });\n            \n        } catch (error) {\n            console.error('Error initializing Google Maps:', error);\n            showMapError();\n        }\n    }\n\n        \/\/ NEW: Simplified place selection handler\n            function handlePlaceSelection() {\n                const place = autocomplete.getPlace();\n                if (!place.geometry) {\n                    console.log('No geometry found for place');\n                    return;\n                }\n\n                const coords = {\n                    lat: place.geometry.location.lat(),\n                    lng: place.geometry.location.lng()\n                };\n\n                isUserSearch = true;\n\n                if (!mapInitialized) {\n                    setTimeout(() => handlePlaceSelection(), 100);\n                    return;\n                }\n\n                if (map) {\n                    google.maps.event.trigger(map, 'resize');\n                }\n\n                setTimeout(() => {\n                    \/\/ \u2705 FIX: Remove any existing user marker\n                    if (userLocationMarker) {\n                        userLocationMarker.setMap(null);\n                        userLocationMarker = null;\n                    }\n                    \n                    \/\/ Center map first\n                    map.setCenter(coords);\n                    map.setZoom(4);\n                    \n                    \/\/ \u2705 FIX: Create marker for searched location\n                    userLocationMarker = new google.maps.Marker({\n                        position: coords,\n                        map: map,\n                        title: place.name || place.formatted_address || 'Selected Location',\n                        icon: categoryIcons['Current-location'],\n                        animation: google.maps.Animation.DROP,\n                        optimized: false\n                    });\n\n                    \/\/ \u2705 FIX: Add to markers array\n                    if (!markers.includes(userLocationMarker)) {\n                        markers.push(userLocationMarker);\n                    }\n\n                    \/\/ \u2705 FIX: Add info window for the searched location marker\n                    userLocationMarker.addListener('click', function() {\n                        infoWindow.setContent(\n                            '<div class=\"map-info-window\">' +\n                            '<h4>' + (place.name || place.formatted_address || 'Selected Location') + '<\/h4>' +\n                            '<p>This is your searched location<\/p>' +\n                            '<\/div>'\n                        );\n                        infoWindow.open(map, userLocationMarker);\n                    });\n\n                    \/\/ \u2705 FIX: Update URL directly instead of calling updateLocationAndTable\n                    const url = new URL(window.location.href);\n                    url.searchParams.set('latitude', coords.lat);\n                    url.searchParams.set('longitude', coords.lng);\n                    if (place.name || place.formatted_address) {\n                        url.searchParams.set('location', place.name || place.formatted_address);\n                    } else {\n                        url.searchParams.delete('location');\n                    }\n                    window.history.replaceState(null, null, url);\n\n                    \/\/ \u2705 FIX: Update table data without triggering updateMapLocation\n                    updateTableData(coords);\n                    \n                    \/\/ Reset isUserSearch after a delay\n                    setTimeout(() => {\n                        isUserSearch = false;\n                    }, 2000);\n                    \n                }, 300);\n            }\n\n\n    \/\/ Expose initMap to the global scope\n    window.initScolicareMap = initMap;\n\n    function showMapError() {\n        const mapContainer = document.getElementById('scolicare_map');\n        if (mapContainer) {\n            mapContainer.innerHTML = '<div class=\"alert alert-warning text-center p-4\">Unable to load map. Please refresh the page and try again.<\/div>';\n        }\n    }\n\n    function updateLocationAndTable(coords, name) {\n        try {\n            console.log('updateLocationAndTable called with:', coords, name);\n            \n            \/\/ Update URL without page refresh\n            const url = new URL(window.location.href);\n            url.searchParams.set('latitude', coords.lat);\n            url.searchParams.set('longitude', coords.lng);\n            if (name) {\n                url.searchParams.set('location', name);\n            } else {\n                url.searchParams.delete('location');\n            }\n            window.history.replaceState(null, null, url);\n\n            \/\/ \u2705 FIX: Check if marker already exists at this location\n            let markerExists = false;\n            if (userLocationMarker) {\n                const existingPos = userLocationMarker.getPosition();\n                if (existingPos && \n                    existingPos.lat() === coords.lat && \n                    existingPos.lng() === coords.lng) {\n                    markerExists = true;\n                }\n            }\n            \n            \/\/ Only update map location if marker doesn't exist\n            if (!markerExists) {\n                updateMapLocation(coords, name || 'Current Location');\n            }\n            \n            \/\/ Update table data dynamically\n            updateTableData(coords);\n            \n        } catch (error) {\n            console.error('Error updating location and table:', error);\n        }\n    }\n    function updateMapLocation(coords, name) {\n        console.log('updateMapLocation called with:', coords, name);\n        \n        \/\/ Remove existing user location marker\n        if (userLocationMarker) {\n            userLocationMarker.setMap(null);\n            userLocationMarker = null;\n        }\n\n        \/\/ Add new user location marker\n        userLocationMarker = new google.maps.Marker({\n            position: coords,\n            map: map,\n            title: name,\n            icon: categoryIcons['Current-location'],\n            animation: google.maps.Animation.BOUNCE,\n            optimized: false\n        });\n\n        userLocationMarker.addListener('click', function() {\n            infoWindow.setContent(\n                '<div class=\"map-info-window\">' +\n                '<h4>' + name + '<\/h4>' +\n                '<p>This is your selected location<\/p>' +\n                '<\/div>'\n            );\n            infoWindow.open(map, userLocationMarker);\n        });\n\n        \/\/ Ensure map is properly centered and zoomed\n        if (map) {\n            \/\/ Trigger resize to ensure map knows its dimensions\n            google.maps.event.trigger(map, 'resize');\n            \n            \/\/ Center and zoom\n            map.setCenter(coords);\n            map.setZoom(12);\n            console.log('Map centered and zoomed to 15 in updateMapLocation');\n        }\n\n        \/\/ Reload markers to recalculate distances\n        loadMarkers();\n    }\n\n    function updateTableData(coords) {\n        console.log('updateTableData called with:', coords);\n        \n        \/\/ Show loading state\n        $('.ajax-loading').removeClass('d-none').show();\n        \n        \/\/ Get clinic data from PHP-generated locations array\n        const clinicsData = [];\n        \n        \/\/ Use the PHP locations data that's already available\n        const phpClinics = [{\"id\":391,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-16.919255,145.769377\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"391\\\" data-lat=\\\"-16.919255\\\" data-lng=\\\"145.769377\\\">ScoliCare Affiliate Clinic &#8211; Cairns<\\\/a><img src=\\\"\\\/icons\\\/scolicare-affiliate.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-16.919255,145.769377\\\" target=\\\"_blank\\\" class=\\\"marker\\\">127 Sheridan Street<br \\\/>Cairns City<br \\\/>Queensland 4870<br \\\/>Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300883884\\\">1300883884<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"http:\\\/\\\/scoilicare.com\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">scoilicare.com<\\\/div><\\\/a><\\\/div>\",\"latitude\":-16.919255,\"longitude\":145.769377,\"category\":\"scolicare-affiliate\"},{\"id\":396,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-42.8661536,147.3040991\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"396\\\" data-lat=\\\"-42.8661536\\\" data-lng=\\\"147.3040991\\\">ScoliCare Affiliate Clinic &#8211; Hobart<\\\/a><img src=\\\"\\\/icons\\\/scolicare-affiliate.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-42.8661536,147.3040991\\\" target=\\\"_blank\\\" class=\\\"marker\\\">49 Augusta Road<br \\\/>Lenah Valley<br \\\/>Tasmania 7008<br \\\/>Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300883884\\\">1300883884<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"http:\\\/\\\/scoilicare.com\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">scoilicare.com<\\\/div><\\\/a><\\\/div>\",\"latitude\":-42.8661536,\"longitude\":147.3040991,\"category\":\"scolicare-affiliate\"},{\"id\":389,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-31.9419048,115.8405079\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"389\\\" data-lat=\\\"-31.9419048\\\" data-lng=\\\"115.8405079\\\">ScoliCare Affiliate Clinic &#8211; Perth<\\\/a><img src=\\\"\\\/icons\\\/scolicare-affiliate.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-31.9419048,115.8405079\\\" target=\\\"_blank\\\" class=\\\"marker\\\">14 Southport Street<br \\\/>West Leederville<br \\\/>Western Australia 6007<br \\\/>Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300883884\\\">1300883884<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"https:\\\/\\\/www.scolicare.com\\\/\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">www.scolicare.com<\\\/div><\\\/a><\\\/div>\",\"latitude\":-31.9419048,\"longitude\":115.8405079,\"category\":\"scolicare-affiliate\"},{\"id\":393,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-27.8801803,153.3836576\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"393\\\" data-lat=\\\"-27.8801803\\\" data-lng=\\\"153.3836576\\\">ScoliCare Affiliate Clinic \\u2013 Gold Coast<\\\/a><img src=\\\"\\\/icons\\\/scolicare-affiliate.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-27.8801803,153.3836576\\\" target=\\\"_blank\\\" class=\\\"marker\\\">2 Oxley Drive<br \\\/>Paradise Point<br \\\/>Queensland 4216<br \\\/>Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300883884\\\">1300883884<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"https:\\\/\\\/www.scolicare.com\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">www.scolicare.com<\\\/div><\\\/a><\\\/div>\",\"latitude\":-27.8801803,\"longitude\":153.3836576,\"category\":\"scolicare-affiliate\"},{\"id\":387,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-34.9284989,138.6007456\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"387\\\" data-lat=\\\"-34.9284989\\\" data-lng=\\\"138.6007456\\\">The ScoliCare Clinic Adelaide<\\\/a><img src=\\\"\\\/icons\\\/scolibrace-provider.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-34.9284989,138.6007456\\\" target=\\\"_blank\\\" class=\\\"marker\\\">South Australia Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300883884\\\">1300883884<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"https:\\\/\\\/scolicare.com\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">scolicare.com<\\\/div><\\\/a><\\\/div>\",\"latitude\":-34.9284989,\"longitude\":138.6007456,\"category\":\"scolibrace-provider\"},{\"id\":385,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-27.3903934,153.0232891\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"385\\\" data-lat=\\\"-27.3903934\\\" data-lng=\\\"153.0232891\\\">The ScoliCare Clinic Brisbane<\\\/a><img src=\\\"\\\/icons\\\/scolicare-clinic.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-27.3903934,153.0232891\\\" target=\\\"_blank\\\" class=\\\"marker\\\">627 Rode Road<br \\\/>Chermside<br \\\/>Queensland 4032<br \\\/>Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300883884\\\">1300883884<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"https:\\\/\\\/www.scolicare.com\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">www.scolicare.com<\\\/div><\\\/a><\\\/div>\",\"latitude\":-27.3903934,\"longitude\":153.0232891,\"category\":\"scolicare-clinic\"},{\"id\":349,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-37.8440693,144.9777112\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"349\\\" data-lat=\\\"-37.8440693\\\" data-lng=\\\"144.9777112\\\">The ScoliCare Clinic Melbourne<\\\/a><img src=\\\"\\\/icons\\\/scolicare-clinic.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-37.8440693,144.9777112\\\" target=\\\"_blank\\\" class=\\\"marker\\\">492 Saint Kilda Road<br \\\/>Melbourne<br \\\/>Victoria 3004<br \\\/>Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300856118\\\">1300856118<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"https:\\\/\\\/www.melbournescoliosisclinic.com.au\\\/\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">www.melbournescoliosisclinic.com.au<\\\/div><\\\/a><\\\/div>\",\"latitude\":-37.8440693,\"longitude\":144.9777112,\"category\":\"scolicare-clinic\"},{\"id\":381,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-33.965661,151.1330531\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"381\\\" data-lat=\\\"-33.965661\\\" data-lng=\\\"151.1330531\\\">The ScoliCare Clinic Sydney (South)<\\\/a><img src=\\\"\\\/icons\\\/scolicare-clinic.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=-33.965661,151.1330531\\\" target=\\\"_blank\\\" class=\\\"marker\\\">15 Kensington Street<br \\\/>Kogarah<br \\\/>New South Wales 2217<br \\\/>Australia<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:1300650205\\\">1300650205<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"https:\\\/\\\/www.sydneyscoliosisclinic.com.au\\\/\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">www.sydneyscoliosisclinic.com.au<\\\/div><\\\/a><\\\/div>\",\"latitude\":-33.965661,\"longitude\":151.1330531,\"category\":\"scolicare-clinic\"},{\"id\":1146,\"title\":\"<a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=40.4673309,-79.9185208\\\" target=\\\"_blank\\\" class=\\\"marker clinic-link\\\" data-clinic-id=\\\"1146\\\" data-lat=\\\"40.4673309\\\" data-lng=\\\"-79.9185208\\\">USA test 1<\\\/a><img src=\\\"\\\/icons\\\/scolibrace-provider.png\\\" class=\\\"ml-2\\\" width=\\\"14\\\" \\\/>\",\"distance\":null,\"details\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-map-marker-alt\\\"><\\\/span> <a href=\\\"https:\\\/\\\/www.google.com\\\/maps?q=40.4673309,-79.9185208\\\" target=\\\"_blank\\\" class=\\\"marker\\\">684 Collins Street<br \\\/>Pittsburgh<br \\\/>Pennsylvania 15206<br \\\/>United States<\\\/a><\\\/div><div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-phone\\\"><\\\/span> <a href=\\\"tel:123452\\\">123452<\\\/a><\\\/div>\",\"website\":\"<div class=\\\"details\\\"><span class=\\\"fas fa-fw fa-globe-americas\\\"><\\\/span><a href=\\\"https:\\\/\\\/www.google.com\\\" target=\\\"_blank\\\"><div class=\\\"d-none d-lg-block\\\">www.google.com<\\\/div><\\\/a><\\\/div>\",\"latitude\":40.4673309,\"longitude\":-79.9185208,\"category\":\"scolibrace-provider\"}];\n        \n        \/\/ Calculate distances and prepare data\n        phpClinics.forEach(function(clinic) {\n            if (clinic.latitude && clinic.longitude) {\n                const distance = calculateDistance(\n                    coords.lat, \n                    coords.lng, \n                    clinic.latitude, \n                    clinic.longitude\n                );\n                \n                clinicsData.push({\n                    id: clinic.id,\n                    title: clinic.title,\n                    distance: distance,\n                    formattedDistance: distance ? numberFormat(distance, 2) + ' km' : '&mdash;',\n                    details: clinic.details,\n                    website: clinic.website,\n                    latitude: clinic.latitude,\n                    longitude: clinic.longitude,\n                    category: clinic.category\n                });\n            }\n        });\n        \n        \/\/ Render the table with the clinic data\n        renderTable(clinicsData, coords);\n    }\n\n    \/\/ Add number_format helper function (similar to PHP)\n    function numberFormat(number, decimals) {\n        return Number(number).toFixed(decimals);\n    }\n\n    function calculateDistance(lat1, lng1, lat2, lng2) {\n        \/\/ Haversine formula to calculate distance between two coordinates\n        const R = 6371; \/\/ Earth's radius in km\n        const dLat = (lat2 - lat1) * Math.PI \/ 180;\n        const dLng = (lng2 - lng1) * Math.PI \/ 180;\n        const a = \n            Math.sin(dLat\/2) * Math.sin(dLat\/2) +\n            Math.cos(lat1 * Math.PI \/ 180) * Math.cos(lat2 * Math.PI \/ 180) * \n            Math.sin(dLng\/2) * Math.sin(dLng\/2);\n        const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));\n        const distance = R * c;\n        return distance;\n    }\n\n    function renderTable(clinicsData, coords) {\n        \/\/ Sort clinics by distance\n        clinicsData.sort(function(a, b) {\n            return a.distance - b.distance;\n        });\n        \n        \/\/ Find the nearest ScoliCare Clinic\n        const scolicareClinics = clinicsData.filter(function(clinic) {\n            return clinic.category === 'scolicare-clinic';\n        });\n        \n        const nearestScolicareClinic = scolicareClinics.length > 0 ? scolicareClinics[0] : null;\n        \n        \/\/ Remove the nearest ScoliCare Clinic from the main array if found\n        let remainingClinics = [];\n        if (nearestScolicareClinic) {\n            remainingClinics = clinicsData.filter(function(clinic) {\n                return clinic.id !== nearestScolicareClinic.id;\n            });\n        } else {\n            remainingClinics = clinicsData;\n        }\n        \n        \/\/ Sort remaining clinics by distance\n        remainingClinics.sort(function(a, b) {\n            return a.distance - b.distance;\n        });\n        \n        \/\/ Take top 4 remaining clinics (so we have 5 total including the ScoliCare Clinic)\n        const topRemainingClinics = remainingClinics.slice(0, 4);\n        \n        let tableHTML = '';\n        \n        if (clinicsData.length > 0) {\n            \/\/ Show featured section with nearest ScoliCare Clinic if available, otherwise show closest clinic\n            let featuredClinic;\n            if (nearestScolicareClinic) {\n                featuredClinic = nearestScolicareClinic;\n            } else if (clinicsData.length > 0) {\n                featuredClinic = clinicsData[0];\n            }\n            \n            if (featuredClinic) {\n                tableHTML += \n                    '<tr id=\"clinic-' + featuredClinic.id + '\" class=\"text-break clinic-row\" data-clinic-id=\"' + featuredClinic.id + '\" data-lat=\"' + featuredClinic.latitude + '\" data-lng=\"' + featuredClinic.longitude + '\">' +\n                        '<td colspan=\"4\">' +\n                            '<div id=\"clinic-featured\" class=\"font-weight-bold\">' +\n                                '<p class=\"h4 mb-4\">' + featuredClinic.title + '<\/p>' +\n                                '<div class=\"row justify-content-between mx-0\">' +\n                                    '<div class=\"details\"><span class=\"fas fa-fw fa-arrows-alt-h mr-1\"><\/span>&nbsp;' + featuredClinic.formattedDistance + '<\/div>' +\n                                    featuredClinic.details +\n                                    featuredClinic.website +\n                                '<\/div>' +\n                            '<\/div>' +\n                        '<\/td>' +\n                    '<\/tr>';\n            }\n            \n            \/\/ Show remaining clinics (excluding the featured one)\n            let remainingClinicsToShow;\n            if (nearestScolicareClinic) {\n                \/\/ If we featured a ScoliCare Clinic, show top 4 remaining\n                remainingClinicsToShow = topRemainingClinics;\n            } else if (clinicsData.length > 1) {\n                \/\/ If we featured the closest clinic (non-ScoliCare), show next 4\n                remainingClinicsToShow = clinicsData.slice(1, 5);\n            } else {\n                remainingClinicsToShow = [];\n            }\n            \n            \/\/ Add remaining clinics to table\n            remainingClinicsToShow.forEach(function(clinic, index) {\n                tableHTML += \n                    '<tr id=\"clinic-' + clinic.id + '\" class=\"text-break clinic-row\" data-clinic-id=\"' + clinic.id + '\" data-lat=\"' + clinic.latitude + '\" data-lng=\"' + clinic.longitude + '\">' +\n                        '<td scope=\"row\">' +\n                            clinic.title +\n                            '<div class=\"mt-2 d-lg-none\">' +\n                                '<span class=\"fas fa-fw fa-arrows-alt-h mr-1\"><\/span>&nbsp;' + clinic.formattedDistance +\n                            '<\/div>' +\n                        '<\/td>' +\n                        '<td class=\"d-none d-lg-table-cell\">' + clinic.formattedDistance + '<\/td>' +\n                        '<td class=\"d-none d-md-table-cell\">' + clinic.details + '<\/td>' +\n                        '<td class=\"d-none d-lg-table-cell\">' + clinic.website + '<\/td>' +\n                    '<\/tr>';\n            });\n        } else {\n            tableHTML = \n                '<tr>' +\n                    '<td colspan=\"4\" class=\"text-center\">' +\n                        'No clinics found' +\n                    '<\/td>' +\n                '<\/tr>';\n        }\n        \n        \/\/ Update the table body\n        $('table tbody').html(tableHTML);\n        \n        \/\/ Re-setup click handlers for the new table rows\n        setupClinicClickHandlers();\n        \n        \/\/ Hide loading state\n        $('.ajax-loading').addClass('d-none').hide();\n        \n        console.log('Table updated with', clinicsData.length, 'clinics');\n    }\n\n    function startWatchingLocation() {\n        if (navigator.geolocation) {\n            \/\/ Show loading state\n            $('.ajax-loading').removeClass('d-none').show();\n            \n            navigator.geolocation.getCurrentPosition(\n                function(position) {\n                    const userLatLng = {\n                        lat: position.coords.latitude,\n                        lng: position.coords.longitude\n                    };\n                    updateLocationAndTable(userLatLng, 'Current Location');\n                },\n                function(error) {\n                    alert('Error getting location: ' + error.message);\n                    $('.ajax-loading').addClass('d-none').hide();\n                },\n                {\n                    enableHighAccuracy: true,\n                    timeout: 10000,\n                    maximumAge: 60000\n                }\n            );\n        } else {\n            alert('Geolocation is not supported by this browser.');\n        }\n    }\n\n    function stopWatchingLocation() {\n        if (watchId) {\n            navigator.geolocation.clearWatch(watchId);\n            watchId = null;\n        }\n    }\n\n    function loadMarkers() {\n        if (!mapInitialized) {\n            console.log('Map not fully initialized yet, waiting...');\n            setTimeout(loadMarkers, 100);\n            return;\n        }\n\n        console.log('Loading markers...');\n\n        try {\n            \/\/ Clear existing clinic markers\n            markers.forEach(function(marker) {\n                if (marker !== userLocationMarker) {\n                    marker.setMap(null);\n                }\n            });\n            markers = userLocationMarker ? [userLocationMarker] : [];\n            clinicMarkers = {};\n\n            let markersLoaded = 0;\n            const totalMarkers = $('#scolicare_markers > div').length;\n\n            \/\/ Get all marker elements\n            $('#scolicare_markers > div').each(function() {\n                const $marker = $(this);\n                const lat = parseFloat($marker.data('lat'));\n                const lng = parseFloat($marker.data('lng'));\n                const html = $marker.data('html');\n                const rawCategory = $marker.data('category');\n                const id = String($marker.data('id'));\n                const title = $marker.data('title') || 'Clinic';\n\n                \/\/ Validate coordinates\n                if (isNaN(lat) || isNaN(lng) || lat < -90 || lat > 90 || lng < -180 || lng > 180) {\n                    console.warn('Invalid coordinates for marker:', id);\n                    markersLoaded++;\n                    return;\n                }\n\n                if (!isNaN(lat) && !isNaN(lng)) {\n                    \/\/ Skip if this is the user location marker element (we create that separately)\n                    if (id === '0') {\n                        markersLoaded++;\n                        return;\n                    }\n\n                    \/\/ Normalize category to a slug-like string\n                    let category = rawCategory ? String(rawCategory).toLowerCase().replace(\/\\s+\/g, '-') : '';\n\n                    \/\/ If the marker is explicitly the current-location marker, use configured icon\n                    if (rawCategory === 'Current-location' || category === 'current-location') {\n                        const icon = categoryIcons['Current-location'] || { url: '\/icons\/default.png', scaledSize: new google.maps.Size(32, 32)};\n                        createMarker({ lat: lat, lng: lng }, title, icon, html, id);\n                        markersLoaded++;\n                        return;\n                    }\n\n                    \/\/ Build expected custom icon URL and fallback\n                    const customIconUrl = (category ? (baseIconOrigin + '\/icons\/' + category + '.png') : (baseIconOrigin + '\/icons\/default.png'));\n                    const fallbackUrl = baseIconOrigin + '\/icons\/default.png';\n\n                    \/\/ Preload icon to avoid 404 -> default Google pin\n                    const img = new Image();\n                    img.onload = function() {\n                        const icon = {\n                            url: customIconUrl,\n                            scaledSize: new google.maps.Size(23, 32),\n                            origin: new google.maps.Point(0, 0),\n                            anchor: new google.maps.Point(11, 32)\n                        };\n                        createMarker({ lat: lat, lng: lng }, title, icon, html, id);\n                        markersLoaded++;\n                        checkAllLoaded();\n                    };\n                    img.onerror = function() {\n                        console.warn('Marker icon not found, using fallback:', customIconUrl);\n                        \/\/ Use fallback custom icon when category icon missing\n                        const icon = {\n                            url: fallbackUrl,\n                            scaledSize: new google.maps.Size(23, 32),\n                            origin: new google.maps.Point(0, 0),\n                            anchor: new google.maps.Point(11, 32)\n                        };\n                        createMarker({ lat: lat, lng: lng }, title, icon, html, id);\n                        markersLoaded++;\n                        checkAllLoaded();\n                    };\n                    \/\/ trigger load\n                    img.src = customIconUrl;\n                }\n            });\n\n            \/\/ Helper to create marker and attach info window\n            function createMarker(positionObj, title, icon, html, clinicId) {\n                const marker = new google.maps.Marker({\n                    position: { lat: positionObj.lat, lng: positionObj.lng },\n                    map: map,\n                    title: title,\n                    icon: icon,\n                    optimized: false\n                });\n\n                \/\/ Store marker by clinic ID for easy access\n                clinicMarkers[clinicId] = marker;\n\n                if (html) {\n                    marker.addListener('click', function() {\n                        infoWindow.setContent(html);\n                        infoWindow.open(map, marker);\n                        \n                        \/\/ Scroll to map when marker is clicked\n                        scrollToMap();\n                    });\n                }\n\n                markers.push(marker);\n                return marker;\n            }\n\n            function checkAllLoaded() {\n                console.log('Loaded ' + markersLoaded + ' out of ' + totalMarkers + ' markers');\n                \/\/ Once we've attempted to load all markers, fit bounds\n                if (markersLoaded >= totalMarkers) {\n                    fitBoundsToMarkers();\n                }\n            }\n\n            \/\/ In case there are no images to preload, still attempt to fit bounds after a short delay\n            setTimeout(function() {\n                console.log('Timeout check: ' + markersLoaded + ' \/ ' + totalMarkers);\n                if (markersLoaded >= totalMarkers || totalMarkers === 0) {\n                    fitBoundsToMarkers();\n                }\n            }, 800);\n\n            \/\/ Fit map to show all markers\nfunction fitBoundsToMarkers() {\n\n    \/\/ \u2705 ADD THIS BLOCK\n    if (isUserSearch) {\n         return;\n    }\n\n    if (markers.length > 0) {\n        const bounds = new google.maps.LatLngBounds();\n        markers.forEach(function(marker) {\n            if (marker.getPosition()) {\n                bounds.extend(marker.getPosition());\n            }\n        });\n\n        if (!bounds.isEmpty()) {\n            setTimeout(function() {\n                map.fitBounds(bounds);\n\n                if (markers.length === 1) {\n                    google.maps.event.addListenerOnce(map, 'bounds_changed', function() {\n                        if (this.getZoom() > 12) {\n                            this.setZoom(12);\n                        }\n                    });\n                }\n            }, 500);\n        }\n    }\n}\n\n        } catch (error) {\n            console.error('Error loading markers:', error);\n        }\n    }\n\n    \/\/ Scroll to map function\n    function scrollToMap() {\n        try {\n            const $map = $('#scolicare_map');\n            if ($map.length) {\n                $('html, body').animate({\n                    scrollTop: $map.offset().top - 50\n                }, 500);\n            }\n        } catch (error) {\n            console.error('Error scrolling to map:', error);\n        }\n    }\n\n    \/\/ Setup click handlers for clinic rows and links\n    function setupClinicClickHandlers() {\n        try {\n            \/\/ Remove existing handlers to prevent duplicates\n            $('.clinic-row').off('click');\n            $('.clinic-link').off('click');\n            $('.details a').off('click');\n\n            \/\/ Handle clicks on clinic rows\n            $('.clinic-row').on('click', function(e) {\n                \/\/ Don't prevent default if clicking on website link\n                if ($(e.target).closest('a[href*=\"\/\/\"]').length && !$(e.target).closest('a').hasClass('clinic-link') && !$(e.target).closest('a').attr('href').includes('maps.google.com')) {\n                    return; \/\/ Allow website links to work normally\n                }\n                e.preventDefault();\n                const clinicId = $(this).data('clinic-id');\n                const lat = $(this).data('lat');\n                const lng = $(this).data('lng');\n                \n                focusOnClinic(clinicId, lat, lng);\n            });\n\n            \/\/ Handle clicks on clinic links (prevent double triggering)\n            $('.clinic-link').on('click', function(e) {\n                e.preventDefault();\n                e.stopPropagation();\n                const clinicId = $(this).data('clinic-id');\n                const lat = $(this).data('lat');\n                const lng = $(this).data('lng');\n                \n                focusOnClinic(clinicId, lat, lng);\n            });\n\n            \/\/ Handle clicks on contact details links (only map-related links)\n            $('.details a').on('click', function(e) {\n                const href = $(this).attr('href');\n                \/\/ Only prevent default for map links and clinic links, allow website links to work normally\n                if (href.includes('maps.google.com') || $(this).hasClass('marker') || $(this).hasClass('clinic-link')) {\n                    e.preventDefault();\n                    e.stopPropagation();\n                    \n                    \/\/ Find the parent clinic row\n                    const $clinicRow = $(this).closest('.clinic-row');\n                    if ($clinicRow.length) {\n                        const clinicId = $clinicRow.data('clinic-id');\n                        const lat = $clinicRow.data('lat');\n                        const lng = $clinicRow.data('lng');\n                        \n                        focusOnClinic(clinicId, lat, lng);\n                    }\n                }\n                \/\/ Allow tel: and http:\/\/ website links to work normally\n            });\n        } catch (error) {\n            console.error('Error setting up click handlers:', error);\n        }\n    }\n\n    \/\/ Focus map on specific clinic\n    function focusOnClinic(clinicId, lat, lng) {\n        if (!mapInitialized) {\n            console.log('Map not initialized yet');\n            return;\n        }\n\n        try {\n            const clinicMarker = clinicMarkers[clinicId];\n            \n            if (clinicMarker) {\n                \/\/ Trigger resize to ensure map knows its dimensions\n                google.maps.event.trigger(map, 'resize');\n                \n                \/\/ Center map on clinic\n                map.setCenter(clinicMarker.getPosition());\n                map.setZoom(12);\n                \n                \/\/ Open info window\n                infoWindow.close();\n                google.maps.event.trigger(clinicMarker, 'click');\n                \n                \/\/ Scroll to map instead of highlighting table row\n                scrollToMap();\n            } else {\n                \/\/ If marker not found, still center on coordinates\n                google.maps.event.trigger(map, 'resize');\n                \n                const clinicLatLng = new google.maps.LatLng(lat, lng);\n                map.setCenter(clinicLatLng);\n                map.setZoom(12);\n                \n                \/\/ Scroll to map instead of highlighting table row\n                scrollToMap();\n            }\n        } catch (error) {\n            console.error('Error focusing on clinic:', error);\n        }\n    }\n\n    \/\/ Helper to get URL parameters\n    function getUrlParameter(name) {\n        try {\n            const params = new URLSearchParams(window.location.search);\n            return params.get(name);\n        } catch (error) {\n            console.error('Error getting URL parameter:', error);\n            return null;\n        }\n    }\n\n    function loadGoogleMapsAPI() {\n        if (typeof google === 'undefined' || typeof google.maps === 'undefined') {\n            console.log('Loading Google Maps API...');\n            const script = document.createElement('script');\n            script.src = 'https:\/\/maps.googleapis.com\/maps\/api\/js?key=AIzaSyB7IPL_Ai4k5aK5EfojQgenCbE9zW6dEkA&libraries=places&callback=initScolicareMap';\n            script.async = true;\n            script.defer = true;\n            \n            script.onload = function() {\n                console.log('Google Maps API loaded successfully');\n                googleMapsLoaded = true;\n            };\n            \n            script.onerror = function() {\n                console.error('Failed to load Google Maps API');\n                showMapError();\n            };\n            \n            document.head.appendChild(script);\n        } else {\n            console.log('Google Maps API already loaded');\n            googleMapsLoaded = true;\n            initScolicareMap();\n        }\n    }\n\n$(document).ready(function(){\n    console.log('Document ready - initializing clinic locator');\n\n    \/\/ SOLUTION: Clean URL on page load and provide proper reset functionality\n    function cleanURL() {\n        if (window.history && window.history.replaceState) {\n            const urlParams = new URLSearchParams(window.location.search);\n            const hasLocationParams = urlParams.has('latitude') || urlParams.has('longitude') || urlParams.has('location');\n            \n            if (hasLocationParams) {\n                const cleanURL = window.location.pathname;\n                window.history.replaceState(null, null, cleanURL);\n                console.log('Cleaned URL parameters on page load');\n            }\n        }\n    }\n    \n    \/\/ Clean URL immediately\n    cleanURL();\n\n    \/\/ Load Google Maps API\n    loadGoogleMapsAPI();\n\n    \/\/ Current location button\n    $('#current-location').on('click', function() {\n        startWatchingLocation();\n    });\n\n    \/\/ Reset filters with proper functionality\n    $('#reset-filters').on('click', function() {\n        \/\/ Stop any active location watching\n        stopWatchingLocation();\n        \n        \/\/ Remove user marker if exists\n        if (userLocationMarker) {\n            userLocationMarker.setMap(null);\n            userLocationMarker = null;\n        }\n        \n        \/\/ Clear URL\n        if (window.history && window.history.replaceState) {\n            const cleanURL = window.location.pathname;\n            window.history.replaceState(null, null, cleanURL);\n        }\n        \n        \/\/ Reset form fields\n        $('#alternate-address').val('');\n        \n        \/\/ Reload the page to completely reset everything\n        location.reload();\n    });\n\n    \/\/ Clean up\n    $(window).on('beforeunload', function() {\n        stopWatchingLocation();\n    });\n});\n\n})(jQuery);\n<\/script>\n    <style type=\"text\/css\">\n        .post-type-archive-clinics {\n        background-color: #ebebeb;\n    }\n\n    .content-location input[type='text'], .content-location .facetwp-search, .content-location .facetwp-dropdown, .content-location .fs-label-wrap {\n        width: 100%;\n        padding: 1rem;\n        background-color: #fff !important;\n        color: #003a76 !important;\n    }\n\n    #clinic-featured {\n        background-color: #9ddae6;\n        border-radius: 1rem;\n        padding: 1rem 2rem;\n    }\n\n    #clinic-featured .marker {\n        color: #005894;\n        font-weight: 700;\n    }\n\n    #clinic-featured .details a {\n        color: #212529;\n    }\n\n    .scolicare-map {\n        height: 500px;\n        width: 100%;\n        border: 1px solid #ccc;\n        border-radius: 8px;\n        background-color: #f8f9fa; \/* Fallback background *\/\n    }\n\n    \/* Ensure map container is visible *\/\n    .scolicare-map {\n        min-height: 400px;\n    }\n\n    \/* Hide markers container *\/\n    #scolicare_markers {\n        display: none !important;\n    }\n\n    \/* Style for active clinic row *\/\n    .clinic-row.table-active {\n        background-color: #e3f2fd !important;\n        border-left: 4px solid #005894;\n    }\n\n    \/* Make clinic rows clickable *\/\n    .clinic-row {\n        cursor: pointer;\n        transition: background-color 0.2s ease;\n    }\n\n    .clinic-row:hover {\n        background-color: #f8f9fa !important;\n    }\n\n    \/* Style for clinic links *\/\n    .clinic-link {\n        color: #005894;\n        text-decoration: none;\n        font-weight: 600;\n    }\n\n    .clinic-link:hover {\n        color: #003a76;\n        text-decoration: underline;\n    }\n    <\/style>\n\n    \n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Find a Clinic Near You Select your \u2018Current Location\u2019 or enter a country, city or suburb to find your closest &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Find a Clinic Near You\" class=\"read-more button\" href=\"https:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/#more-3024\" aria-label=\"Read more about Find a Clinic Near You\">Read more<\/a><\/p>\n","protected":false},"author":1284,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-3024","page","type-page","status-publish"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Find the closest Scoliosis clinic or provider near you &#8211; Denver<\/title>\n<meta name=\"description\" content=\"The world&#039;s leading Scoliosis Clinic, Clinicians and Doctors, ScoliCare is all about providing the right treatment at the right time.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Find the closest Scoliosis clinic or provider near you &#8211; Denver\" \/>\n<meta property=\"og:description\" content=\"The world&#039;s leading Scoliosis Clinic, Clinicians and Doctors, ScoliCare is all about providing the right treatment at the right time.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/\" \/>\n<meta property=\"og:site_name\" content=\"Denver\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/scolicaredenvercolorado\" \/>\n<meta property=\"og:image\" content=\"https:\/\/scolicare.com\/denver-colorado\/wp-content\/uploads\/sites\/50\/2024\/07\/Denver-Google-Search-Listing.png\" \/>\n\t<meta property=\"og:image:width\" content=\"451\" \/>\n\t<meta property=\"og:image:height\" content=\"343\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/\",\"url\":\"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/\",\"name\":\"Find the closest Scoliosis clinic or provider near you &#8211; Denver\",\"isPartOf\":{\"@id\":\"https:\/\/scolicare.com\/denver-colorado\/#website\"},\"datePublished\":\"2021-05-02T23:02:47+00:00\",\"description\":\"The world's leading Scoliosis Clinic, Clinicians and Doctors, ScoliCare is all about providing the right treatment at the right time.\",\"breadcrumb\":{\"@id\":\"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/#breadcrumb\"},\"inLanguage\":\"en-AU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/scolicare.com\/denver-colorado\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Find a Clinic Near You\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/scolicare.com\/denver-colorado\/#website\",\"url\":\"https:\/\/scolicare.com\/denver-colorado\/\",\"name\":\"ScoliCare Denver Colorado \u2013 Non-surgical based treatments for Scoliosis\",\"description\":\"Leaders in non-surgical scoliosis treatments\",\"publisher\":{\"@id\":\"https:\/\/scolicare.com\/denver-colorado\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/scolicare.com\/denver-colorado\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-AU\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/scolicare.com\/denver-colorado\/#organization\",\"name\":\"ScoliCare Denver Colorado\",\"url\":\"https:\/\/scolicare.com\/denver-colorado\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-AU\",\"@id\":\"https:\/\/scolicare.com\/denver-colorado\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/scolicare.com\/us-clinic\/wp-content\/uploads\/sites\/50\/2021\/04\/menu-logo-180x47-1.png\",\"contentUrl\":\"https:\/\/scolicare.com\/us-clinic\/wp-content\/uploads\/sites\/50\/2021\/04\/menu-logo-180x47-1.png\",\"width\":180,\"height\":47,\"caption\":\"ScoliCare Denver Colorado\"},\"image\":{\"@id\":\"https:\/\/scolicare.com\/denver-colorado\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/scolicaredenvercolorado\",\"https:\/\/www.instagram.com\/scolicaredenvercolorado\/\",\"https:\/\/www.linkedin.com\/company\/scolicare\/\",\"https:\/\/www.youtube.com\/user\/scolicare\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Find the closest Scoliosis clinic or provider near you &#8211; Denver","description":"The world's leading Scoliosis Clinic, Clinicians and Doctors, ScoliCare is all about providing the right treatment at the right time.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/","og_locale":"en_US","og_type":"article","og_title":"Find the closest Scoliosis clinic or provider near you &#8211; Denver","og_description":"The world's leading Scoliosis Clinic, Clinicians and Doctors, ScoliCare is all about providing the right treatment at the right time.","og_url":"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/","og_site_name":"Denver","article_publisher":"https:\/\/www.facebook.com\/scolicaredenvercolorado","og_image":[{"width":451,"height":343,"url":"https:\/\/scolicare.com\/denver-colorado\/wp-content\/uploads\/sites\/50\/2024\/07\/Denver-Google-Search-Listing.png","type":"image\/png"}],"twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/","url":"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/","name":"Find the closest Scoliosis clinic or provider near you &#8211; Denver","isPartOf":{"@id":"https:\/\/scolicare.com\/denver-colorado\/#website"},"datePublished":"2021-05-02T23:02:47+00:00","description":"The world's leading Scoliosis Clinic, Clinicians and Doctors, ScoliCare is all about providing the right treatment at the right time.","breadcrumb":{"@id":"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/#breadcrumb"},"inLanguage":"en-AU","potentialAction":[{"@type":"ReadAction","target":["http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/scolicare.com\/denver-colorado\/patients-find-a-clinic\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/scolicare.com\/denver-colorado\/"},{"@type":"ListItem","position":2,"name":"Find a Clinic Near You"}]},{"@type":"WebSite","@id":"https:\/\/scolicare.com\/denver-colorado\/#website","url":"https:\/\/scolicare.com\/denver-colorado\/","name":"ScoliCare Denver Colorado \u2013 Non-surgical based treatments for Scoliosis","description":"Leaders in non-surgical scoliosis treatments","publisher":{"@id":"https:\/\/scolicare.com\/denver-colorado\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/scolicare.com\/denver-colorado\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-AU"},{"@type":"Organization","@id":"https:\/\/scolicare.com\/denver-colorado\/#organization","name":"ScoliCare Denver Colorado","url":"https:\/\/scolicare.com\/denver-colorado\/","logo":{"@type":"ImageObject","inLanguage":"en-AU","@id":"https:\/\/scolicare.com\/denver-colorado\/#\/schema\/logo\/image\/","url":"https:\/\/scolicare.com\/us-clinic\/wp-content\/uploads\/sites\/50\/2021\/04\/menu-logo-180x47-1.png","contentUrl":"https:\/\/scolicare.com\/us-clinic\/wp-content\/uploads\/sites\/50\/2021\/04\/menu-logo-180x47-1.png","width":180,"height":47,"caption":"ScoliCare Denver Colorado"},"image":{"@id":"https:\/\/scolicare.com\/denver-colorado\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/scolicaredenvercolorado","https:\/\/www.instagram.com\/scolicaredenvercolorado\/","https:\/\/www.linkedin.com\/company\/scolicare\/","https:\/\/www.youtube.com\/user\/scolicare"]}]}},"_links":{"self":[{"href":"https:\/\/scolicare.com\/denver-colorado\/wp-json\/wp\/v2\/pages\/3024","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scolicare.com\/denver-colorado\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/scolicare.com\/denver-colorado\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/scolicare.com\/denver-colorado\/wp-json\/wp\/v2\/users\/1284"}],"replies":[{"embeddable":true,"href":"https:\/\/scolicare.com\/denver-colorado\/wp-json\/wp\/v2\/comments?post=3024"}],"version-history":[{"count":0,"href":"https:\/\/scolicare.com\/denver-colorado\/wp-json\/wp\/v2\/pages\/3024\/revisions"}],"wp:attachment":[{"href":"https:\/\/scolicare.com\/denver-colorado\/wp-json\/wp\/v2\/media?parent=3024"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}