Type.createNamespace('LoginComponent');

////////////////////////////////////////////////////////////////////////////////
// LoginComponent.LoginComponent

LoginComponent.LoginComponent = function LoginComponent_LoginComponent() {
    LoginComponent.LoginComponent.constructBase(this);
}


LoginComponent.LoginComponent.createClass('LoginComponent.LoginComponent', AbstractMMCoreComponents.AbstractLoginComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('AccountsDetailsComponent');

////////////////////////////////////////////////////////////////////////////////
// AccountsDetailsComponent.AccountsDetailsComponent

AccountsDetailsComponent.AccountsDetailsComponent = function AccountsDetailsComponent_AccountsDetailsComponent() {
    AccountsDetailsComponent.AccountsDetailsComponent.constructBase(this);
}
AccountsDetailsComponent.AccountsDetailsComponent.prototype = {
    _changeActionOnLogout$2: null,
    
    refreshBalanceOnClickEventHandler: function AccountsDetailsComponent_AccountsDetailsComponent$refreshBalanceOnClickEventHandler(sender, eventArgs) {
        this.refreshBalance();
        window.event.returnValue = false;
    },
    
    goToEventHandler: function AccountsDetailsComponent_AccountsDetailsComponent$goToEventHandler(sender, eventArgs) {
        new NavigationService.GoToBehavior(eventArgs.domElement, null, this._navigationService$2);
    },
    
    logoutOnClickEventHandler: function AccountsDetailsComponent_AccountsDetailsComponent$logoutOnClickEventHandler(sender, eventArgs) {
        this.logout();
    },
    
    logOutAndGotoPageEventHandler: function AccountsDetailsComponent_AccountsDetailsComponent$logOutAndGotoPageEventHandler(sender, eventArgs) {
        this.logout();
        this.removeBSselections();
        this.goToPageArea(eventArgs.parameters.getAsString('pagename'));
    },
    
    logoutAndRemoveSelectionsEventHandler: function AccountsDetailsComponent_AccountsDetailsComponent$logoutAndRemoveSelectionsEventHandler(sender, eventArgs) {
        this.logout();
        this.removeBSselections();
    },
    
    _accountService$2: null,
    
    setAccountService: function AccountsDetailsComponent_AccountsDetailsComponent$setAccountService(accountService) {
        this._log.debug('SetAccountService');
        this._accountService$2 = accountService;
    },
    
    onBalanceChanged: function AccountsDetailsComponent_AccountsDetailsComponent$onBalanceChanged(eventSource) {
        this._log.debug('OnBalanceChanged');
        this.update();
    },
    
    onAccountPreferencesChanged: function AccountsDetailsComponent_AccountsDetailsComponent$onAccountPreferencesChanged(eventSource) {
        this._log.debug('OnAccountPreferencesChanged');
        this.update();
    },
    
    _navigationService$2: null,
    
    setNavigationService: function AccountsDetailsComponent_AccountsDetailsComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$2 = navigationService;
        this._navigationService$2.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.action);
    },
    
    onPageFilterChanged: function AccountsDetailsComponent_AccountsDetailsComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this.update();
    },
    
    _userService$2: null,
    
    setUserService: function AccountsDetailsComponent_AccountsDetailsComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$2 = userService;
    },
    
    _betSlipService$2: null,
    
    setBetSlipService: function AccountsDetailsComponent_AccountsDetailsComponent$setBetSlipService(betSlipService) {
        this._log.debug('SetBetSlipService');
        this._betSlipService$2 = betSlipService;
    },
    
    init: function AccountsDetailsComponent_AccountsDetailsComponent$init(environment, componentInstanceName, domElementId, parameters) {
        this._changeActionOnLogout$2 = parameters['change-action-on-logout'];
    },
    
    preTransformation: function AccountsDetailsComponent_AccountsDetailsComponent$preTransformation(eventArgs) {
        if (!this._accountService$2.get_accountsDetails() && this._userService$2.isLoggedIn()) {
            this._accountService$2.onUserChanged(null);
        }
    },
    
    renderComplete: function AccountsDetailsComponent_AccountsDetailsComponent$renderComplete(eventArgs) {
        this.refreshBalance();
    },
    
    get_isComponentVisible: function AccountsDetailsComponent_AccountsDetailsComponent$get_isComponentVisible() {
        return (this.isVisible(this._parameters.get_visibleOn(), this._parameters.get_notVisibleOn(), this._navigationService$2.getAction()) && this._userService$2.isLoggedIn());
    },
    
    getXsltParameters: function AccountsDetailsComponent_AccountsDetailsComponent$getXsltParameters(contextObject) {
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        if (this._userService$2.get_personalDetails()) {
            xsltParameters['name'] = this._userService$2.get_personalDetails().FullName;
        }
        if (this._accountService$2.get_accountsDetails()) {
            xsltParameters['account-number'] = this._accountService$2.get_creditAccountDetails().AccountNumber;
            xsltParameters['currency-symbol'] = this._accountService$2.getCurrencySimbol();
            xsltParameters['cash-balance'] = this._accountService$2.get_creditAccountDetails().WithdrawalBalance.format('N2', true);
            xsltParameters['credit-limit'] = ((this._accountService$2.get_creditAccountDetails().TradingBalance - this._accountService$2.get_creditAccountDetails().WithdrawalBalance)).format('N2', true);
            xsltParameters['free-balance'] = this._accountService$2.get_freeAccountDetails().WithdrawalBalance.format('N2', true);
            xsltParameters['available-funds'] = ((this._accountService$2.get_creditAccountDetails().TradingBalance + this._accountService$2.get_freeAccountDetails().TradingBalance)).format('N2', true);
            xsltParameters['is-account-balance-constantly-displayed'] = this._accountService$2.get_preferences().IsAccountBalanceConstantlyDisplayed;
            xsltParameters['is-call-centre-account-number-constantly-displayed'] = this._accountService$2.get_preferences().IsCallCentreAccountNumberConstantlyDisplayed;
        }
        return xsltParameters;
    },
    
    refreshBalance: function AccountsDetailsComponent_AccountsDetailsComponent$refreshBalance() {
        this._log.debug('RefreshBalance');
        this._accountService$2.fetchAccountsDetails();
    },
    
    logout: function AccountsDetailsComponent_AccountsDetailsComponent$logout() {
        this._log.debug('Logout');
        this.changeActionOnLogout();
        this.disable();
        this._userService$2.logout(Delegate.create(this, function(result) {
            this.enable();
        }), Delegate.create(this, function(exception) {
            this.enable();
        }));
    },
    
    changeActionOnLogout: function AccountsDetailsComponent_AccountsDetailsComponent$changeActionOnLogout() {
        if (!String.isNullOrEmpty(this._changeActionOnLogout$2)) {
            var pageFilter = this._navigationService$2.getPageFilter();
            pageFilter['action'] = this._changeActionOnLogout$2;
            this._navigationService$2.setPageFilter(pageFilter);
        }
    },
    
    goTo: function AccountsDetailsComponent_AccountsDetailsComponent$goTo(pageArea, pageFilter) {
        this._navigationService$2.goTo(pageArea, pageFilter);
        return false;
    },
    
    goToPageArea: function AccountsDetailsComponent_AccountsDetailsComponent$goToPageArea(pageArea) {
        var pageFilter = this._navigationService$2.getPageFilter();
        return this.goTo(pageArea, pageFilter);
    },
    
    removeBSselections: function AccountsDetailsComponent_AccountsDetailsComponent$removeBSselections() {
        this._betSlipService$2.removeAllSelections();
    }
}


AccountsDetailsComponent.AccountsDetailsComponent.createClass('AccountsDetailsComponent.AccountsDetailsComponent', Framework.Component.AbstractXsltBasedComponent, NavigationService.IPageFilterChangedListener, AccountService.IBalanceChangedListener, AccountService.IAccountPreferencesChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('OddsTypeSelectorComponent');

////////////////////////////////////////////////////////////////////////////////
// OddsTypeSelectorComponent.OddsTypeSelectorComponent

OddsTypeSelectorComponent.OddsTypeSelectorComponent = function OddsTypeSelectorComponent_OddsTypeSelectorComponent() {
    OddsTypeSelectorComponent.OddsTypeSelectorComponent.constructBase(this);
}
OddsTypeSelectorComponent.OddsTypeSelectorComponent.prototype = {
    _parameters$1: null,
    _userOddsFormat$1: null,
    _defaultOddsFormat$1: 'FRACTIONS',
    _fixedOddsBettingService$1: null,
    
    setFixedOddsBettingService: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$setFixedOddsBettingService(fixedOddsBettingService) {
        this._log.debug('SetFixedOddsBettingService');
        this._fixedOddsBettingService$1 = fixedOddsBettingService;
    },
    
    onOddsTypeChanged: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$onOddsTypeChanged(fixedOddsBettingService) {
        this._log.debug('OnOddsTypeChanged');
        this.repaint();
    },
    
    _userService$1: null,
    
    setUserService: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$1 = userService;
    },
    
    onUserChanged: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$onUserChanged(eventSource) {
        this._log.debug('OnUserChanged');
        this.repaint();
    },
    
    init: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$init(environment, componentInstanceName, domElementId, parameters) {
        OddsTypeSelectorComponent.OddsTypeSelectorComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = parameters;
        this._userOddsFormat$1 = parameters['default-odds-format'];
    },
    
    start: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$start() {
        this.repaint();
    },
    
    repaint: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$repaint() {
        this._log.debug('Repaint');
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        if (this._fixedOddsBettingService$1.getPreferences()) {
            xsltParameters['odds-type'] = this._fixedOddsBettingService$1.getPreferences().OddsType.toUpperCase();
        }
        else {
            if (this._fixedOddsBettingService$1.isOddsTypeValid(this._userOddsFormat$1)) {
                xsltParameters['odds-type'] = this._userOddsFormat$1.toUpperCase();
                this._fixedOddsBettingService$1.setOddsType(this._userOddsFormat$1.toUpperCase());
            }
            else {
                xsltParameters['odds-type'] = this._defaultOddsFormat$1;
            }
        }
        this._environment.transformAndUpdate(this._domElementId, null, this._parameters$1['xslt-url'], xsltParameters, Delegate.create(this, function() {
            Framework.Behavior.Binding.BehaviorBinder.autoBind(this._environment.getDomElement(this._domElementId), (this));
        }));
    },
    
    setOddsTypeEventHandler: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$setOddsTypeEventHandler(sender, eventArgs) {
        var oddsType = (eventArgs.domElement).value;
        this._log.debug('SetOddsType oddsType = [' + oddsType + ']');
        this._userOddsFormat$1 = oddsType;
        this._fixedOddsBettingService$1.setOddsType(oddsType);
    }
}


OddsTypeSelectorComponent.OddsTypeSelectorComponent.createClass('OddsTypeSelectorComponent.OddsTypeSelectorComponent', Framework.Component.AbstractComponent, FixedOddsBettingService.IOddsTypeChangedListener, UserService.IUserChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('ClockComponent');

////////////////////////////////////////////////////////////////////////////////
// ClockComponent.ClockComponent

ClockComponent.ClockComponent = function ClockComponent_ClockComponent() {
    ClockComponent.ClockComponent.constructBase(this);
}
ClockComponent.ClockComponent.prototype = {
    _parameters$1: null,
    _clockDomElement$1: null,
    _useCustomDigits$1: false,
    _timeDateFormat$1: null,
    _clockSpan$1: null,
    _businessUnitService$1: null,
    
    setBusinessUnitService: function ClockComponent_ClockComponent$setBusinessUnitService(businessUnitService) {
        this._log.debug('SetBusinessUnitService');
        this._businessUnitService$1 = businessUnitService;
    },
    
    init: function ClockComponent_ClockComponent$init(environment, componentInstanceName, domElementId, parameters) {
        ClockComponent.ClockComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._timeDateFormat$1 = parameters['time-date-format'];
        this._useCustomDigits$1 = parameters['use-custom-digits'];
        this._clockDomElement$1 = document.createElement('p');
        this._clockDomElement$1.className = 'lb_clock';
        this._clockDomElement$1.id = this._domElementId + '-lb_clock';
        this._environment.getDomElement(this._domElementId).appendChild(this._clockDomElement$1);
        this._clockSpan$1 = '';
        if (parameters['clock-label'] !== '') {
            this._clockSpan$1 = parameters['clock-label'];
            if (this._useCustomDigits$1) {
                var tempClockSpan = '';
                var curChar = '';
                for (var i = 0; i < this._clockSpan$1.length; i++) {
                    curChar = this._clockSpan$1.charAt(i).toString();
                    tempClockSpan += String.format('<span class=\"digit digit{0}\">{1}</span>', curChar, this._clockSpan$1.charAt(i));
                }
                this._clockSpan$1 = tempClockSpan;
            }
            this._clockSpan$1 = ' <span class=\"clocklabel\" >' + this._clockSpan$1 + '</span> ';
        }
    },
    
    start: function ClockComponent_ClockComponent$start() {
        this.repaint();
    },
    
    repaint: function ClockComponent_ClockComponent$repaint() {
        this._log.debug('Repaint');
        window.setInterval(Delegate.create(this, function() {
            var currentTime = new Date(Date.get_now().getTime() + this._businessUnitService$1.getDateTimeOffset()).format(this._timeDateFormat$1);
            if (this._useCustomDigits$1) {
                var customCurrentTime = '';
                var curChar = '';
                for (var i = 0; i < currentTime.length; i++) {
                    curChar = currentTime.charAt(i).toString();
                    switch (curChar) {
                        case ':':
                            curChar = 'Colon';
                            break;
                        case '.':
                            curChar = 'Dot';
                            break;
                        case '-':
                            curChar = 'Dash';
                            break;
                    }
                    customCurrentTime += String.format('<span class=\"digit digit{0}\">{1}</span>', curChar, currentTime.charAt(i));
                }
                currentTime = customCurrentTime;
            }
            this._environment.updateDomElementDirect(this._clockDomElement$1, currentTime + this._clockSpan$1);
        }), 1000);
    }
}


ClockComponent.ClockComponent.createClass('ClockComponent.ClockComponent', Framework.Component.AbstractComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('NavigationComponent');

////////////////////////////////////////////////////////////////////////////////
// NavigationComponent.NavigationComponent

NavigationComponent.NavigationComponent = function NavigationComponent_NavigationComponent() {
    NavigationComponent.NavigationComponent.constructBase(this);
}


NavigationComponent.NavigationComponent.createClass('NavigationComponent.NavigationComponent', AbstractWarpComponents.AbstractNavigationComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
// TBOpenMarketGroupsComponent.js
//


Type.createNamespace('TBOpenMarketGroupsComponent');

////////////////////////////////////////////////////////////////////////////////
// TBOpenMarketGroupsComponent.TBOpenMarketGroupsComponent

TBOpenMarketGroupsComponent.TBOpenMarketGroupsComponent = function TBOpenMarketGroupsComponent_TBOpenMarketGroupsComponent() {
    TBOpenMarketGroupsComponent.TBOpenMarketGroupsComponent.constructBase(this);
}
TBOpenMarketGroupsComponent.TBOpenMarketGroupsComponent.prototype = {
    _parameters$1: null,
    _bettingNavigationService$1: null,
    
    setBettingNavigationService: function TBOpenMarketGroupsComponent_TBOpenMarketGroupsComponent$setBettingNavigationService(bettingNavigationService) {
        this._log.debug('SetBettingNavigationService');
        this._bettingNavigationService$1 = bettingNavigationService;
    },
    
    init: function TBOpenMarketGroupsComponent_TBOpenMarketGroupsComponent$init(environment, componentInstanceName, domElementId, parameters) {
        TBOpenMarketGroupsComponent.TBOpenMarketGroupsComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
    },
    
    repaint: function TBOpenMarketGroupsComponent_TBOpenMarketGroupsComponent$repaint() {
        this._environment.clearPeriodicalTransformAndUpdate(this._domElementId);
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        this._environment.periodicalTransformAndUpdate(this._domElementId, this._parameters$1.get_contentUrl(), this._parameters$1.get_xsltUrl(), xsltParameters, null, this._domElementId, 20000);
    },
    
    onClick: function TBOpenMarketGroupsComponent_TBOpenMarketGroupsComponent$onClick(idfwbonavigation, idfwmarketgroup) {
        this._bettingNavigationService$1.setNavigation([ idfwbonavigation ], idfwmarketgroup, null, null, null, null);
    }
}


TBOpenMarketGroupsComponent.TBOpenMarketGroupsComponent.createClass('TBOpenMarketGroupsComponent.TBOpenMarketGroupsComponent', Framework.AbstractComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('InRunningDiaryComponent');

////////////////////////////////////////////////////////////////////////////////
// InRunningDiaryComponent.InRunningDiaryComponent

InRunningDiaryComponent.InRunningDiaryComponent = function InRunningDiaryComponent_InRunningDiaryComponent() {
    InRunningDiaryComponent.InRunningDiaryComponent.constructBase(this);
}
InRunningDiaryComponent.InRunningDiaryComponent.prototype = {
    _parameters$1: null,
    _imagesDirectoryUrl$1: null,
    _navigationService$1: null,
    
    setNavigationService: function InRunningDiaryComponent_InRunningDiaryComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.action);
    },
    
    onPageFilterChanged: function InRunningDiaryComponent_InRunningDiaryComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this.repaint();
    },
    
    init: function InRunningDiaryComponent_InRunningDiaryComponent$init(environment, componentInstanceName, domElementId, parameters) {
        InRunningDiaryComponent.InRunningDiaryComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._imagesDirectoryUrl$1 = parameters['images-directory-url'];
        this._log.debug('imagesDirectoryUrl = [' + this._imagesDirectoryUrl$1 + ']');
    },
    
    repaint: function InRunningDiaryComponent_InRunningDiaryComponent$repaint() {
        this._log.debug('Repaint');
        if (this.isVisible(this._parameters$1.get_visibleOn(), this._parameters$1.get_notVisibleOn(), this._navigationService$1.getAction())) {
            this.show();
            var xsltParameters = {};
            xsltParameters['component-instance-name'] = this._componentInstanceName;
            xsltParameters['images-directory-url'] = this._imagesDirectoryUrl$1;
            this._environment.transformAndUpdate(this._domElementId, this._parameters$1.get_contentUrl(), this._parameters$1.get_xsltUrl(), xsltParameters, null);
        }
        else {
            this.hide();
        }
    }
}


InRunningDiaryComponent.InRunningDiaryComponent.createClass('InRunningDiaryComponent.InRunningDiaryComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('IncludeComponent');

////////////////////////////////////////////////////////////////////////////////
// IncludeComponent.IncludeComponent

IncludeComponent.IncludeComponent = function IncludeComponent_IncludeComponent() {
    IncludeComponent.IncludeComponent.constructBase(this);
}
IncludeComponent.IncludeComponent.prototype = {
    _parameters$1: null,
    _repaintOnFilterChanged$1: true,
    _navigationService$1: null,
    
    setNavigationService: function IncludeComponent_IncludeComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.action);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.page);
    },
    
    onPageFilterChanged: function IncludeComponent_IncludeComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        if (this._repaintOnFilterChanged$1) {
            this.repaint();
        }
    },
    
    init: function IncludeComponent_IncludeComponent$init(environment, componentInstanceName, domElementId, parameters) {
        IncludeComponent.IncludeComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        if (Object.keyExists(parameters, 'repaint-on-filter-changed')) {
            this._repaintOnFilterChanged$1 = Boolean.parse(parameters['repaint-on-filter-changed']);
        }
    },
    
    repaint: function IncludeComponent_IncludeComponent$repaint() {
        this._log.debug('Repaint');
        if (this.isVisible(this._parameters$1.get_visibleOn(), this._parameters$1.get_notVisibleOn(), this._navigationService$1.getAction())) {
            this.show();
            var contentUrl = this._parameters$1.get_contentUrl().replace('${region}', this._environment.getRegion()).replace('${language}', this._environment.getLanguage());
            var page = this._navigationService$1.getPageFilter()[NavigationService.NavigationService.page];
            if (!String.isNullOrEmpty(page)) {
                contentUrl = contentUrl.replace('${page}', page);
            }
            var ajaxUpdater = new Framework.AjaxUpdater(this._domElementId, contentUrl, null, null);
            ajaxUpdater.update();
        }
        else {
            this.hide();
        }
    }
}


IncludeComponent.IncludeComponent.createClass('IncludeComponent.IncludeComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
