	
<script>
function getUserPrayerTimes(resultDivId) {
    var display = document.getElementById(resultDivId);
    
    // Safety check: if element doesn't exist
    if (!display) return;

    // Optimization: If we already found the times (the table is visible), 
    // don't ask for location again.
    if(display.innerHTML.indexOf('<table') !== -1) {
        return; 
    }
    
    // 1. Check if Geolocation is supported
    if (!navigator.geolocation) {
        display.innerHTML = "<p class='text-danger'>Geolocation is not supported.</p>";
        return;
    }

    display.innerHTML = "<p class='text-info'><i class='fas fa-spinner fa-spin'></i> Locating...</p>";

    // 2. Request Location
    navigator.geolocation.getCurrentPosition(success, error);

    function success(position) {
        var lat = position.coords.latitude;
        var long = position.coords.longitude;
        
        display.innerHTML = "<p class='text-info'>Found! Fetching times...</p>";

        // 3. Fetch Data (Method 4 = Umm Al-Qura)
        var date = new Date();
        var api_url = "https://api.aladhan.com/v1/timings/" + date.getDate() + "-" + (date.getMonth() + 1) + "-" + date.getFullYear() + "?latitude=" + lat + "&longitude=" + long + "&method=4";

        fetch(api_url)
    .then(response => response.json())
    .then(data => {
        var timings = data.data.timings;
        
        // Helper function to convert 24h to 12h AM/PM
        function format12h(timeStr) {
            if (!timeStr) return "";
            var [hours, minutes] = timeStr.split(':');
            hours = parseInt(hours);
            var suffix = hours >= 12 ? " PM" : " AM";
            hours = ((hours + 11) % 12 + 1); // Converts 0 to 12 and 13 to 1
            return hours + ":" + minutes + suffix;
        }
        
        // Build the Table with formatted times
        var html = '<table class="table table-sm mt-2" style="font-size:13px; margin-bottom:0;">';
        html += '<thead style="background-color: #C68C22; color: white;"><tr><th>Prayer</th><th>Time</th></tr></thead>';
        html += '<tbody>';
        html += '<tr><td><strong>Fajr</strong></td><td>' + format12h(timings.Fajr) + '</td></tr>';
        html += '<tr><td><strong>Dhuhr</strong></td><td>' + format12h(timings.Dhuhr) + '</td></tr>';
        html += '<tr><td><strong>Asr</strong></td><td>' + format12h(timings.Asr) + '</td></tr>';
        html += '<tr><td><strong>Maghrib</strong></td><td>' + format12h(timings.Maghrib) + '</td></tr>';
        html += '<tr><td><strong>Isha</strong></td><td>' + format12h(timings.Isha) + '</td></tr>';
        html += '</tbody></table>';
        
        display.innerHTML = html;
            })
            .catch(err => {
                display.innerHTML = "<p class='text-danger'>Error fetching times.</p>";
                console.error(err);
            });
    }

    function error() {
        display.innerHTML = "<p class='text-danger' style='line-height:1.2; margin-top:5px;'><strong>Permission Denied.</strong><br>Please allow location access to see times.</p>";
    }
}
</script>
	<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="https://mercytv.tv/wp-sitemap-index.xsl" ?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-post-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-page-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-services-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-team-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-teachings-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-testimonial-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-location-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-elementor-hf-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-posts-envira-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-taxonomies-category-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-taxonomies-post_tag-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-taxonomies-services-cat-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-taxonomies-team-category-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-taxonomies-teachings-category-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-taxonomies-testimonial-category-1.xml</loc></sitemap><sitemap><loc>https://mercytv.tv/wp-sitemap-users-1.xml</loc></sitemap></sitemapindex>
