const openLiveChat = () => {
    const subDomain = "account";
    var mainDomain = getMainDomain();
    mainDomain = mainDomain === ".sbobetex.com" ? ".sbotop.com" : mainDomain; // handle current pavo hostname

    let livechatLang = currentLang;
    livechatLang = livechatLang ? livechatLang : 'en';

    const path = "/web-root/public/live-chat/live-chat.aspx?isBsi=1&lang=" + livechatLang;
    const link = window.location.protocol + "//" + subDomain + mainDomain + path;
    popupWindow(link, "liveChat", 450, 700);
};

const openAsiLiveChat = (link) => {
    popupWindow(link, "liveChat", 450, 700);
}

const popupWindow = (link, pageName, width, height) => {
    let style = `scrollbars=yes,resizable=yes,width=${width},height=${height},left=660,top=200,status=yes,toolbar=no,menubar=no,location=no`;
    window.open(link, pageName, style);
};

function getCurrentUrlPath()
{
    var rg = new RegExp("(\/[^\/]+)(?<p>\/.*)");
    var m = window.location.pathname.match(rg);
    if( !m ) {
        return "/";
    }
    return m.groups["p"];
}