/******* Do not edit this file *******
Simple Custom CSS and JS - by Silkypress.com
Saved: May 23 2026 | 10:31:55 */
jQuery(document).ready(function($) {
    setTimeout(function() {
        var url = window.location.href;
        var startMatch = url.match(/start_date=([0-9]{4}-[0-9]{2}-[0-9]{2})/);
        var endMatch = url.match(/end_date=([0-9]{4}-[0-9]{2}-[0-9]{2})/);
        
        if (!startMatch) return;
        
        var checkIn = startMatch[1];
        var checkOut = endMatch ? endMatch[1] : checkIn;
        
        // Encontrar el ID del calendario en esta página
        $('[id^="DOPBSPCalendar-submit"]').each(function() {
            var calID = $(this).attr('id').replace('DOPBSPCalendar-submit', '');
            var startDay = $('#' + calID + '_' + checkIn);
            var endDay = $('#' + calID + '_' + checkOut);
            
            if (startDay.length) {
                // Simular clicks para que el plugin registre las fechas
                startDay.trigger('click');
                setTimeout(function() {
                    endDay.trigger('click');
                    
                    // Reactivar botón
                    setTimeout(function() {
                        var btn = document.getElementById('DOPBSPCalendar-submit' + calID);
                        if (btn) {
                            btn.classList.remove('DOPBSPCalendar-hidden');
                            btn.style.display = 'block';
                            var el = btn;
                            while (el) {
                                el.style.pointerEvents = 'auto';
                                el = el.parentElement;
                            }
                        }
                        
                        // Bloquear clicks en el calendario DESPUÉS de que el plugin haya registrado las fechas
                        $('.DOPBSPCalendar-calendar').css('pointer-events', 'none');
                        
                    }, 500);
                }, 300);
            }
        });
    }, 3000);
});

