﻿function SelectCurrency(Code) {
    window.location.href = '?Currency=' + Code;
}
function GetSubCookie(CookieName, CrumbName) {
    var aCookie = document.cookie.split("; ");
    for (var i = 0; i < aCookie.length; i++) {
        var j = aCookie[i].indexOf('=');
        var aCookieName = aCookie[i].substring(0, j);
        if (aCookieName == CookieName) {
            var CookieValue = aCookie[i].substring(j + 1)
            var Crumbs = CookieValue.split("&");
            for (j = 0; j < Crumbs.length; j++) {
                var Crumb = Crumbs[j].split('=');
                if (Crumb[0] == CrumbName) return Crumb[1];
            }
        }
    }
    return null;
}

function CustomRegistration(Command) {
    if (Command == 1) {
        var AffID = GetSubCookie('TurfMasterAffiliate', 'AffID');
        if (AffID == "undefined") AffID = "";
        if ((AffID == null) || (AffID == "")) AffID = '2180';
        window.open('https://www.ladbrokes.com/lbr_portal?AFF_ID=' + AffID + '&action=go_reg_splash&popupReg=1&id=home&return_url=http^//www.ladbrokes.com/lbr_portal?action=go_portal_home~CTXT=PORTAL&w_id=20030425123951');
    } else {
        window.location.href = SecureSiteURL + '/Membership/Register.asp';
    }
}

function CustomLogin() {
}

function CustomAccount() {
    var IsOnAccountPage = (window.location.href.toLowerCase().indexOf("ladbrokesaccount.asp") > 0);
    var DontAsk = GetCookie("DontShowLadbrokesAccount") == "1"
    if (IsOnAccountPage || DontAsk) {
        window.open('http://www.ladbrokes.com');
        return;
    }
    window.location.href = SiteURL + '/Framework/LadbrokesAccount.asp';
}

function OpenAboutRaceViewerPopup() {
    var x = window.open(SiteURL + "/Framework/AboutRaceclubs.asp", 'DownloadRaceViewer', 'resizable=no,scrollbars=no,menubar=no,location=no,toolbar=no,status=yes,top=40,left=40,width=800,height=600');
}

if (window.Menu) {
    with (new Menu('MenuTransactions', 'SubMenuTable', 'SubMenuInactive', 'SubMenuActive')) {
        addJSItem('LB Racing Account', 'CustomAccount()');
        addBreak();
        addItem('RC Account Summary', '/AccountHistory/AccountHistory.asp');
        addItem('RC Credit History', '/AccountHistory/CreditHistory.asp');
        addBreak();
        addItem('Wallet History', '/AccountHistory/WalletHistory.asp');
    }
}