// Only define function if it doesn't already exist
if (!function_exists('isMobileDevice')) {
function isMobileDevice() {
    return (bool) preg_match('/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i', $_SERVER['HTTP_USER_AGENT']);
    }
}
// Load settings if not already loaded
if (!isset($settings)) {
    // Adjust the path as needed for your project structure
    require_once __DIR__ . '/../../includes/config.php';
    require_once __DIR__ . '/../../includes/functions.php';
    $db = getDBConnection();
    $settings = getAllSettings($db);
}
// Check if top banner is enabled
$topBannerEnabled = isset($settings['enable_top_banner']) && $settings['enable_top_banner'] == '1';
// Only output banner content if enabled
if ($topBannerEnabled) {
    // Start banner container div
    echo '
';
    
    if (isMobileDevice() && !empty($topBannerMobile)) {
        echo $topBannerMobile;
    } elseif (!empty($topBanner)) {
        echo $topBanner;
    } elseif (!empty($settings['top_banner_custom'])) {
        echo $settings['top_banner_custom'];
    }
    
    // Close banner container div
    echo '
';
}
?> 
    
        // Load settings if not already loaded
if (!isset($settings)) {
    // Adjust the path as needed for your project structure
    require_once __DIR__ . '/../../includes/config.php';
    require_once __DIR__ . '/../../includes/functions.php';
    $db = getDBConnection();
    $settings = getAllSettings($db);
}
// Check if bottom banner is enabled
$bottomBannerEnabled = isset($settings['enable_bottom_banner']) && $settings['enable_bottom_banner'] == '1';
// Only output banner if enabled
if ($bottomBannerEnabled) {
    if (!empty($bottomBanner)) {
        echo '
';
        echo $bottomBanner;
        echo '
';
    } else if (!empty($settings['bottom_banner'])) {
        echo '
';
        echo $settings['bottom_banner'];
        echo '
';
    } 
}
?>