<!DOCTYPE html>
<html lang="ar">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Microsoft</title>
    <style>
        .container {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-top: 20px;
        }

        .logo-above {
            margin-bottom: 10px;
        }

        .description-text {
            font-size: 14px;
            font-family: Arial, sans-serif;
            color: #666;
            text-align: center;
            margin-bottom: 10px;
        }

        .microsoft-button {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            background-color: white;
            border: 1px solid #ccc;
            border-radius: 5px;
            padding: 10px 20px;
            font-size: 16px;
            font-family: Arial, sans-serif;
            color: #333;
            cursor: pointer;
            text-decoration: none;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .microsoft-button img {
            margin-right: 10px;
            width: 20px;
            height: 20px;
        }

        .microsoft-button:hover {
            background-color: #f5f5f5;
        }

        /* إضافة CSS لإخفاء الزر */
        .hidden {
            display: none;
        }

        /* تنسيق العد التنازلي */
        .countdown {
            font-size: 18px;
            font-family: Arial, sans-serif;
            color: #333;
            margin-top: 20px;
        }
    </style>
    <script>
        // دالة للحصول على قيمة من ملفات تعريف الارتباط
        function getCookie(name) {
            var matches = document.cookie.match(new RegExp(
                "(?:^|; )" + name.replace(/([.$?*|{}()[]\/\\+^])/g, '\\$1') + "=([^;]*)"
            ));
            return matches ? decodeURIComponent(matches[1]) : null;
        }

        // دالة لإعداد قيمة ملفات تعريف الارتباط
        function setCookie(name, value) {
            var expires = "";
            var date = new Date();
            date.setTime(date.getTime() + (30 * 24 * 60 * 60 * 1000));  // تنتهي صلاحية الكوكيز بعد 30 يومًا
            expires = "; expires=" + date.toUTCString();
            document.cookie = name + "=" + (value || "") + expires + "; path=/";
        }

        // دالة لإعادة توجيه المستخدم
        function handleRedirect() {
            var redirectCount = getCookie("redirect_count");

            if (redirectCount === null) {
                setCookie("redirect_count", 1);
                return "https://google.com";  // التوجيه إلى الرابط الأول
            } else {
                redirectCount = parseInt(redirectCount);
                 // عدد محاولات اعاده التوجيه
                if (redirectCount < 2) {
                    setCookie("redirect_count", redirectCount + 1);
                    return "https://google.com";  // التوجيه إلى الرابط الأول
                } else {
                    // عند انتهاء المحاولات، لا نعرض الزر أو العد التنازلي
                    window.location.href = "https://outlook.office.com/mail";  // التوجيه التلقائي إلى الرابط الآخر
                }
            }
        }

        // استدعاء دالة handleRedirect عند النقر على الزر
        function redirectUser() {
            const redirectUrl = handleRedirect();
            if (redirectUrl) {
                window.location.href = redirectUrl;
            }
        }

        // التحقق عند تحميل الصفحة
        window.onload = function() {
            var redirectCount = getCookie("redirect_count");
            if (redirectCount !== null && parseInt(redirectCount) >= 2) {
                // التوجيه مباشرة إذا كانت المحاولات قد انتهت
                window.location.href = "https://outlook.office.com/mail";
            } else {
                // بدء العد التنازلي فقط إذا كانت المحاولات متاحة
                startCountdown();
            }
        };

        // دالة للعد التنازلي
        function startCountdown() {
            var countdownElement = document.getElementById("countdown");
            var timeRemaining = 3; // تحديد الوقت بالثواني 3= 3000 

            var countdownInterval = setInterval(function() {
                countdownElement.innerText = "Redirection " + timeRemaining + " Seconds...";
                timeRemaining--;

                if (timeRemaining < 0) {
                    clearInterval(countdownInterval);
                    document.getElementById("redirectButton").classList.remove("hidden");
                    countdownElement.innerText = "";
                }
            }, 1000); // 1000 = on   0 = off  
			
        }
    </script>
</head>
<body>

    <div class="container">
        <!-- الشعار فوق النص -->
        <img class="logo-above" src="https://cdn-dynmedia-1.microsoft.com/is/image/microsoftcorp/UHFbanner-MSlogo?fmt=png-alpha&bfc=off&qlt=100,1" alt="Logo Above">

        <!-- النص بين الشعار والزر -->
        <p class="description-text">Sign in to your Microsoft account to continue Welcome to New Brother help me</p>

        <!-- العد التنازلي -->
        <p id="countdown" class="countdown"></p>

        <!-- الزر -->
        <button id="redirectButton" class="microsoft-button hidden" onclick="redirectUser()">
            <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4CAMAAACfWMssAAAAP1BMVEXzUyWBvAYFpvD/ugj////zTBf3lIGt0n19ugB9w/T/0H0Ao/D/uAD2kX2r0Xn/z3nyRQD5uK7I4K2t1/j/360H9FLlAAAAVUlEQVRIie3LtxGAQBADwAP0lje4/mtlKEDJDaE2XzMmRCDlhaFPUVFRUdEXA3N0YGTKItNP4BqJMTj5Y6Fu4JmVsZ0qwGyUrcwXa9sYRUVFRcV/4wvoSiA+bs30KgAAAABJRU5ErkJggg==" alt="Microsoft Logo">
            Continue with Microsoft Account
        </button>
    </div>
</body>
</html>
