// timing ====================
function sleep(time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}
// timing ====================


let register = document.querySelector('.register');
let register_btn = document.querySelectorAll('.register_btn');
let log_in = document.querySelectorAll('.log_in');
let btn_1 = document.querySelector('#btn-1');
let btn_2 = document.querySelector('#btn-2');

let register_content = document.querySelector('.register_content');
let register_content_2 = document.querySelector('.register_content_2');

let phone_box = document.querySelectorAll('.phone_box');
let iti__country = document.querySelectorAll('.iti__country');
let iti__country_list = document.querySelectorAll('.iti__country-list');


if (register_btn != undefined) {
    register_btn.forEach(x => {
        x.addEventListener('click', function () {
            sleep(2).then(() => {
                register.classList.toggle('active');
                btn_2.classList.add('active');
                btn_1.classList.remove('active');
                selectElement('body').classList.add('active');


                register_content.classList.add('active');
                register_content_2.classList.remove('active');
            });
        });
    })
}

if (log_in != undefined) {
    log_in.forEach(x => {
        x.addEventListener('click', function () {
            sleep(2).then(() => {
                register.classList.toggle('active');
                btn_1.classList.add('active');
                btn_2.classList.remove('active');
                selectElement('body').classList.add('active');


                register_content.classList.remove('active');
                register_content_2.classList.add('active');
            });
        });
    })
}

if (btn_1 != undefined) {
    btn_1.addEventListener('click', function () {
        sleep(2).then(() => {
            btn_1.classList.add('active');
            btn_2.classList.remove('active');

            register_content.classList.remove('active');
            register_content_2.classList.add('active');
        });
    });
}

if (btn_2 != undefined) {
    btn_2.addEventListener('click', function () {
        sleep(2).then(() => {
            btn_2.classList.add('active');
            btn_1.classList.remove('active');

            register_content.classList.add('active');
            register_content_2.classList.remove('active');
        });
    });
}

if (phone_box != undefined) {
    phone_box.forEach(x => {
        x.addEventListener('click', function () {
            sleep(2).then(() => {
                iti__country_list.forEach(e => {
                    e.classList.toggle('active');
                })
            });
        });
    })
}

if (iti__country != undefined) {
    iti__country.forEach(x => {
        x.addEventListener('click', function () {
            sleep(2).then(() => {
                iti__country_list.forEach(e => {
                    e.classList.remove('active');
                })
            });
        });
    })
}