function initCheckboxes(){Array.prototype.forEach.call(document.getElementsByClassName("checker"),function(n){return new FakeCheckbox(n)})}function init(){languageSelect=document.getElementById("lang-select");MessageBox.init("messageBox","confirmMsg","msgClose");sportsTab=document.querySelector(".productSwitcher > .sports");casinoTab=document.querySelector(".productSwitcher > .casino");esportTab=document.querySelector(".productSwitcher > .esports");gameTab=document.querySelector(".productSwitcher > .games");raceTab=document.querySelector(".productSwitcher > .racing");vsTab=document.querySelector(".productSwitcher > .virtualsports");hiddenSiteType=document.getElementById("hiddenSiteType");bannerBox=document.getElementById("bannerBox");kindBg=document.getElementById("kindBg");loginBox=document.getElementById("account");passwordBox=document.getElementById("password");hidCK=document.getElementById("HidCK");vCodeBox=document.getElementById("validcode");loginForm=document.getElementById("loginForm");form=document.getElementById("form");captchaImage=document.getElementById("valid");refreshCaptchaButton=document.getElementById("valid-refresh");oldSiteButtons=Array.prototype.slice.call(document.querySelectorAll("#footer button"));sportsBannerBoxWorldCup=document.getElementById("sportsBannerBoxWorldCup");sportsBannerBox=document.getElementById("sportsBannerBox");androidBannerBox=document.getElementById("androidBannerBox");africaCupBannerBox=document.getElementById("africaCupBannerBox");eSportsBannerBox=document.getElementById("eSportsBannerBox");paymentBannerBox=document.getElementById("paymentBannerBox");casinoDepositBannerBox=document.getElementById("casinoDepositBannerBox");casinoBannerBox=document.getElementById("casinoBannerBox");funkyGameBannerBox=document.getElementById("funkyGameBannerBox");sportsTab.addEventListener("click",function(){onClickProductTab("sports");SetTabHover("sports");SetTabUnhover("sports")});casinoTab.addEventListener("click",function(){onClickProductTab("casino");SetTabHover("casino");SetTabUnhover("casino")});esportTab&&esportTab.addEventListener("click",function(){onClickProductTab("esports");SetTabHover("esports");SetTabUnhover("esports")});gameTab&&gameTab.addEventListener("click",function(){onClickProductTab("games");SetTabHover("games");SetTabUnhover("games")});raceTab&&(racingHorseRacing=document.getElementById("racingHorseRacing2"),raceBannerBox=document.getElementById("raceBannerBox"),raceTab.addEventListener("click",function(){onClickProductTab("racing");SetTabHover("racing");SetTabUnhover("racing")}));vsTab&&(virtualSportsCompetitionBannerBox=document.getElementById("virtualSportsCompetitionBannerBox"),virtualSportsBannerBox=document.getElementById("virtualSportsBannerBox"),vsTab.addEventListener("click",function(){onClickProductTab("virtualsports");SetTabHover("virtualsports");SetTabUnhover("virtualsports")}));loginForm.addEventListener("submit",onSubmitLoginForm);languageSelect.addEventListener("change",onChangeLanguage);refreshCaptchaButton&&refreshCaptchaButton.addEventListener("click",onClickRefreshCaptcha);loginBox.focus();loginBox.parentElement.addEventListener("click",function(){return loginBox.focus()});passwordBox.parentElement.addEventListener("click",function(){return passwordBox.focus()});languageSelect.value=languageCode;rememberMeChecker=new FakeCheckbox(document.getElementById("checkbox"));checkCookiesEnabled()?!errorCode||errorCode==="0"||MessageBox.show(errorCode):MessageBox.show("cookies_disabled");loadDataFromLocalStorage();setTab();isSingaporeIP&&(loginBox.blur(),window.scrollTo(0,0))}function SetTabHover(n){let t=document.getElementById(n+"-icon");t!=null&&(t.className=n+"-icon2")}function SetTabUnhover(n){for(var i=["sports","casino","games","racing","virtualsports","esports"],r,t=0;t<i.length;t++)i[t]!=n&&(r=document.getElementById(i[t]+"-icon"),r&&(r.className=i[t]+"-icon"))}function GetURLParameter(n){for(var u=window.location.search.substring(1),r=u.split("&"),i,t=0;t<r.length;t++)if(i=r[t].split("="),i[0]==n)return i[1];return""}function setTab(){var n=GetURLParameter("tab").toLowerCase();n&&onClickProductTab(n)}function hideAddFavoritePopup(n){n&&n.preventDefault();addFavoritePopup.classList.add("fading");setTimeout(function(){addFavoritePopup.style.display="none"},550)}function loadDataFromLocalStorage(){if(localStorage){localStorage["login.username"]&&(loginBox.value=localStorage["login.username"],rememberMeChecker.toggle());var n=localStorage["login.product.tab"];n?(onClickProductTab(n),SetTabHover(n),SetTabUnhover(n)):(onClickProductTab(hiddenSiteType.value),SetTabHover(hiddenSiteType.value),SetTabUnhover(hiddenSiteType.value));localStorage["login.casino.type"]==="3"&&(casinoSiteTypeSelect.selectedIndex=1)}}function onClickProductTab(n){var t=document.querySelector(".productSwitcher > ."+n),r,u,i,f;t==null||t.classList.contains("hover")||(r=document.getElementById("account"),r.focus(),u=Array.prototype.slice.call(document.querySelectorAll(".productSwitcher > div")),u.forEach(function(n){n!==t&&n.classList.remove("hover")}),t.classList.add("hover"),SetTabHover(n),SetTabUnhover(n),i=!1,funkyGameBannerBox&&(f=[sportsTab,gameTab],funkyGameBannerBox.style.display=f.includes(t)?"block":"none",i=!0),gameTab&&(bannerBox.style.display=t==gameTab&&!i?"block":"none"),raceTab&&(raceBannerBox.style.display=t==raceTab?"block":"none"),vsTab&&virtualSportsBannerBox&&virtualSportsCompetitionBannerBox&&(virtualSportsBannerBox.style.display="none",virtualSportsCompetitionBannerBox.style.display="none",Math.random()>=.5?virtualSportsBannerBox.style.display=t==vsTab?"block":"none":virtualSportsCompetitionBannerBox.style.display=t==vsTab?"block":"none"),sportsTab&&(sportsBannerBox&&(sportsBannerBox.style.display=t==sportsTab?"block":"none"),sportsBannerBoxWorldCup&&(sportsBannerBoxWorldCup.style.display=t==sportsTab?"block":"none"),androidBannerBox&&(androidBannerBox.style.display=t==sportsTab?"block":"none"),africaCupBannerBox&&(africaCupBannerBox.style.display=t==sportsTab?"block":"none")),sportsTab&&paymentBannerBox&&(paymentBannerBox.style.display=t==sportsTab?"block":"none"),esportTab&&eSportsBannerBox&&(eSportsBannerBox.style.display=t==esportTab?"block":"none"),casinoTab&&casinoDepositBannerBox&&(casinoDepositBannerBox.style.display=t==casinoTab?"block":"none"),casinoTab&&casinoBannerBox&&(casinoBannerBox.style.display=t==casinoTab?"block":"none"),hiddenSiteType.value=n,oldSiteButtons.forEach(function(i){if(i.getAttribute("id")!=="line_sports"){let r=i.getAttribute("data-target");i.style.display=(r==null||r=="web")&&t==sportsTab?"inline-block":r==n?"inline-block":"none"}}))}function onClickRefreshCaptcha(n){n.preventDefault();captchaImage.src="/handlers/validation-code.ashx?"+(new Date).getTime()}function onChangeLanguage(){location.replace("login.aspx?lang="+languageSelect.value)}function validateCredentials(){var t=loginBox.value,n=passwordBox.value;return t.length===0||n.length===0?(MessageBox.show("invalid_credentials"),!1):n.length<8?(MessageBox.show("password_short"),!1):vCodeBox&&vCodeBox.value.length<4?(MessageBox.show("wrong_vcode"),!1):!0}function onSubmitLoginForm(n){return validateCredentials()?(saveLocalStorageData(),sendSigninEvent(),!0):(n.preventDefault(),!1)}function sendSigninEvent(){function t(){n||(n=!0,loginForm.submit())}var n,i;event.preventDefault();n=!1;setTimeout(t,1e3);i=loginForm.elements.loginFrom.value;ga("send","event","sign in",i,{hitCallback:t})}function saveLocalStorageData(){if(localStorage){localStorage["loginPattern.username"]=loginBox.value;rememberMeChecker.checked?localStorage["login.username"]=loginBox.value:localStorage["login.username"]&&localStorage.removeItem("login.username");var n="";sportsTab.classList.contains("hover")?n="sports":casinoTab.classList.contains("hover")?n="casino":esportTab!=null&&esportTab.classList.contains("hover")?n="esports":gameTab.classList.contains("hover")?n="games":raceTab.classList.contains("hover")?n="racing":vsTab.classList.contains("hover")&&(n="virtualsports");localStorage["login.product.tab"]=n}}function checkCookiesEnabled(){var n=navigator.cookieEnabled?!0:!1;return typeof navigator.cookieEnabled!="undefined"||n||(document.cookie="testcookie",n=document.cookie.indexOf("testcookie")!=-1?!0:!1),n}function MM_openBrWindow(n,t,i){var r=window.open(n,t,i);return r.focus(),r}function openPlayForFun(){window.location="http://h2ypw0skjn93.gamez.sbobet.com/web-root/public/?token=88879.c0QAfieDXbbR60E7G7TUO5O&gameId=602201&pff=1&from=Mobile&lang=en"}function deviceSpecificTweaks(){var n=navigator.userAgent.toLowerCase(),e=document.querySelector("meta[name='viewport']"),o=!1,s=!1,t,i,r,u,h,l,c,a;if(n.indexOf("firefox")!==-1)Array.prototype.forEach.call(document.querySelectorAll("select.kind"),function(n){n.style.paddingTop="15px"});else if(n.indexOf("iphone")!==-1||n.indexOf("ipod")!==-1){if(s=!0,t=document.createElement("div"),t.innerHTML='<div style="display:block;width=640px;min-width:640px;height=1px;"> &nbsp;<\/div>',i=t.firstChild,document.body.appendChild(i),window.scrollTo(500,0),r=document.documentElement,u=(window.pageXOffset||r.scrollLeft)-(r.clientLeft||0),u>0&&n.indexOf("version/8.0 mobile")<0&&n.indexOf("version/9.0 mobile")<0&&n.indexOf("safari")<0&&window.navigator.standalone===!0){o=!0;var v=document.styleSheets[0].href,y=/\?[^?&]+/.exec(v)[0],f=document.createElement("link");f.type="text/css";f.rel="stylesheet";f.href="/css/zoom.css"+y;document.getElementsByTagName("head")[0].appendChild(f);e.content="width=320,initial-scale=1,maximum-scale=1"}document.body.removeChild(i)}else n.indexOf("ipad")!==-1&&(s=!0,e.content="width=1536,initial-scale=0.5,maximum-scale=0.5",t=document.createElement("div"),t.innerHTML='<div style ="display:block;width=640px;min-width:640px;height=1px;"> &nbsp;<\/div>',i=t.firstChild,document.body.appendChild(i),window.scrollTo(500,0),r=document.documentElement,u=(window.pageXOffset||r.scrollLeft)-(r.clientLeft||0),u>0&&n.indexOf("version/8.0 mobile")<0&&n.indexOf("version/9.0 mobile")<0&&n.indexOf("safari")<0&&window.navigator.standalone===!0&&(o=!0),document.body.removeChild(i),e.content="width=device-width,initial-scale=1,maximum-scale=1");s&&(o?(h=document.querySelector('button.old[data-target="web"]'),h.parentElement.removeChild(h),l=languageSelect.options[languageSelect.selectedIndex],l.value==="id-id"&&(c=document.querySelector("div.productSwitcher > div.sports"),c.style.lineHeight="24px",c.style.paddingTop="2px"),a=document.querySelector(".productSwitcher > .casino"),a.style.display="none"):navigator.standalone||(addFavoritePopup=document.getElementById("addFavoriteBox"),document.getElementById("homeClose").addEventListener("click",hideAddFavoritePopup),addFavoritePopup.style.display="none",setTimeout(hideAddFavoritePopup,8e3)));initiallyPortrait=screen.height>screen.width;portraitOrientation=initiallyPortrait?window.orientation%180:(window.orientation+90)%180;onResize();window.addEventListener("resize",function(){return onResize()});window.addEventListener("orientationchange",function(){return onResize()})}function checkAuthorized(n){n&&n.IsAuthorized||redirect(n.RedirectTo)}function redirect(n){alert("You are on an unauthorized domain! You will be redirected to authorized domain soon. Please contact our support team for any inquiries.");window.location.href=n?"http://"+n:"http://m.sbobet.com"}function insertLocalLog(n){if(window.localStorage!=null){var i=window.localStorage.getItem("log"),t=[];i&&(t=JSON.parse(i));t.push(n);window.localStorage.setItem("log",JSON.stringify(t))}}function sendLogToServer(){var n,t;if(window.localStorage!=null&&(n=window.localStorage.getItem("log"),n!=null)){var i=location.protocol,r=location.hostname,u=i+"//"+r+"/web-root/public/SendLogToServer.aspx";n&&(t={log:n},$.post(u,t).done(function(){window.localStorage.removeItem("log")}))}}var sportsTab,casinoTab,esportTab,gameTab,raceTab,vsTab,productSwitcher,hiddenSiteType,form,casinoSiteTypeSelect,bannerBox,kindBg,loginBox,passwordBox,hidCK,vCodeBox,loginForm,languageSelect,rememberMeChecker,refreshCaptchaButton,captchaImage,addFavoritePopup,oldSiteButtons,languageCode,racingHorseRacing,raceBannerBox,virtualSportsBannerBox,virtualSportsCompetitionBannerBox,sportsBannerBoxWorldCup,sportsBannerBox,androidBannerBox,africaCupBannerBox,eSportsBannerBox,paymentBannerBox,casinoDepositBannerBox,casinoBannerBox,funkyGameBannerBox,MessageBox=function(){function n(){}return n.init=function(t,i,r){n.div=document.getElementById(t);n.messageDiv=document.getElementById(i);n.closeButton=document.getElementById(r);n.messageDict={};n.overlayDiv=document.getElementById("dialogOverlay");var u=document.querySelectorAll("#messageBoxMessages > span");Array.prototype.forEach.call(u,function(t){var u=t.dataset,i,r;u===undefined?(i=t.getAttribute("data-id"),r=t.getAttribute("data-value")):(i=u.id,r=u.value);i&&r&&(n.messageDict[i]=r)});n.closeButton.addEventListener("click",function(){return n.hide()})},n.show=function(t){n.messageDiv.innerHTML=n.messageDict[t];n.div.style.display="block";n.overlayDiv.style.display="block";n.closeButton.focus()},n.hide=function(){n.div.style.display="none";n.overlayDiv.style.display="none"},n}(),FakeCheckbox=function(){function n(n){var t=this;this.checkbox=n;this.checked=n.classList.contains("checked");this.hiddenInput=n.parentElement.querySelector(".checker ~ input");this.updateHiddenInput();this.checkbox&&this.checkbox.addEventListener("click",function(){return t.toggle()});Array.prototype.forEach.call(this.checkbox.parentElement.getElementsByTagName("span"),function(n){return n.addEventListener("click",function(){return t.toggle()})})}return n.prototype.updateHiddenInput=function(){this.hiddenInput&&(this.hiddenInput.checked=this.checked)},n.prototype.toggle=function(){this.checked=!this.checked;this.checked?this.checkbox&&this.checkbox.classList.add("checked"):this.checkbox&&this.checkbox.classList.remove("checked");this.updateHiddenInput()},n}(),oldOrientation,initiallyPortrait,portraitOrientation;init(),function(){try{var t=location.protocol,n=location.hostname,i=t+"//"+n+"/web-root/public/authorize-domain.aspx?domain="+n;$.ajax({url:i,type:"GET",tryCount:1,retryLimit:3,success:function(n){checkAuthorized(n)},error:function(t){if(this.tryCount++,this.tryCount<=this.retryLimit){setTimeout($.ajax(this),5e3);return}insertLocalLog("check authorize-domain status : "+t.status+";domain : "+n);redirect()}})}catch(r){console.log(r);redirect()}}();sendLogToServer()