Type.createNamespace('ChannelNavigationComponent');

////////////////////////////////////////////////////////////////////////////////
// ChannelNavigationComponent.ChannelNavigationComponent

ChannelNavigationComponent.ChannelNavigationComponent = function ChannelNavigationComponent_ChannelNavigationComponent() {
    this._navigationSection$1 = String.Empty;
    this._currentChannel$1 = String.Empty;
    ChannelNavigationComponent.ChannelNavigationComponent.constructBase(this);
}
ChannelNavigationComponent.ChannelNavigationComponent.prototype = {
    _parameters$1: null,
    _repaintOnUserChanged$1: false,
    _repaintOnPageFilterChanged$1: false,
    _protocol$1: null,
    _activeElement$1: null,
    _navigationService$1: null,
    
    setNavigationService: function ChannelNavigationComponent_ChannelNavigationComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
    },
    
    onPageFilterChanged: function ChannelNavigationComponent_ChannelNavigationComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        if (this._repaintOnPageFilterChanged$1) {
            this.repaint();
        }
        else {
            this._setActiveElement$1();
        }
    },
    
    _userService$1: null,
    
    setUserService: function ChannelNavigationComponent_ChannelNavigationComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$1 = userService;
    },
    
    onUserChanged: function ChannelNavigationComponent_ChannelNavigationComponent$onUserChanged(eventSource) {
        this._log.debug('OnUserChanged');
        if (this._repaintOnUserChanged$1) {
            this.repaint();
        }
    },
    
    init: function ChannelNavigationComponent_ChannelNavigationComponent$init(environment, componentInstanceName, domElementId, parameters) {
        ChannelNavigationComponent.ChannelNavigationComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._repaintOnUserChanged$1 = Boolean.parse(parameters['repaint-onuserchanged']);
        this._repaintOnPageFilterChanged$1 = Boolean.parse(parameters['repaint-onpagefilterchanged']);
        this._protocol$1 = parameters['protocol'];
        this._navigationSection$1 = parameters['navigation-section'];
        this._currentChannel$1 = parameters['current-channel'];
    },
    
    repaint: function ChannelNavigationComponent_ChannelNavigationComponent$repaint() {
        this._log.debug('Repaint');
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        xsltParameters['current-channel'] = this._currentChannel$1;
        this.show();
        this._environment.transformAndUpdate(this._domElementId, this._parameters$1.get_contentUrl(), this._parameters$1.get_xsltUrl(), xsltParameters, Delegate.create(this, function() {
            this._setActiveElement$1();
        }));
    },
    
    _setActiveElement$1: function ChannelNavigationComponent_ChannelNavigationComponent$_setActiveElement$1() {
        var action = this._navigationService$1.getAction();
        if (String.isNullOrEmpty(action)) {
            action = null;
        }
        var liElements = this._environment.getDomElement(this._domElementId).getElementsByTagName('LI');
        this._deactivateElement$1();
        for (var i = 0; i < liElements.length; i++) {
            var liElement = liElements[i];
            if (liElement.attributes.getNamedItem('action') && liElement.attributes.getNamedItem('action').value === this._currentChannel$1) {
                this._activateElement$1(liElement);
                break;
            }
        }
    },
    
    setPageFilter: function ChannelNavigationComponent_ChannelNavigationComponent$setPageFilter(liElement, area) {
        if (liElement.tagName !== 'LI') {
            throw new Error('Expected an LI element');
        }
        this._deactivateElement$1();
        this._activateElement$1(liElement);
        var pageFilter = {};
        pageFilter['action'] = liElement.attributes.getNamedItem('action').value;
        this._log.debug('SetPageFilter');
        this._navigationService$1.goTo(area, pageFilter);
        return false;
    },
    
    setPageFilterWithRegion: function ChannelNavigationComponent_ChannelNavigationComponent$setPageFilterWithRegion(liElement, area, region) {
        if (liElement.tagName !== 'LI') {
            throw new Error('Expected an LI element');
        }
        this._deactivateElement$1();
        this._activateElement$1(liElement);
        var pageFilter = {};
        pageFilter['action'] = liElement.attributes.getNamedItem('action').value;
        this._log.debug('SetPageFilter, region=' + region);
        this._environment.changeRegion(region, area, pageFilter);
        return false;
    },
    
    _activateElement$1: function ChannelNavigationComponent_ChannelNavigationComponent$_activateElement$1(liElement) {
        this._activeElement$1 = liElement;
        this._activeElement$1.className = 'cur';
    },
    
    _deactivateElement$1: function ChannelNavigationComponent_ChannelNavigationComponent$_deactivateElement$1() {
        if (this._activeElement$1) {
            this._activeElement$1.className = String.Empty;
            this._activeElement$1 = null;
        }
    },
    
    togglePart: function ChannelNavigationComponent_ChannelNavigationComponent$togglePart(parId, componentId) {
        var el = document.getElementById(componentId);
        if (el.style.display === 'block') {
            el.style.display = 'none';
            (parId).innerText = (parId).innerText.replace('Close', 'Open');
        }
        else {
            el.style.display = 'block';
            (parId).innerText = (parId).innerText.replace('Open', 'Close');
        }
    }
}


ChannelNavigationComponent.ChannelNavigationComponent.createClass('ChannelNavigationComponent.ChannelNavigationComponent', Framework.AbstractComponent, UserService.IUserChangedListener, NavigationService.IPageFilterChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BFNavigationComponent');

////////////////////////////////////////////////////////////////////////////////
// BFNavigationComponent.BFNavigationComponent

BFNavigationComponent.BFNavigationComponent = function BFNavigationComponent_BFNavigationComponent() {
    BFNavigationComponent.BFNavigationComponent.constructBase(this);
}
BFNavigationComponent.BFNavigationComponent.prototype = {
    _promotionsSection$3: '',
    
    getXsltParameters: function BFNavigationComponent_BFNavigationComponent$getXsltParameters(contextObject) {
        var useService = (!contextObject) ? true : contextObject;
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        xsltParameters['username'] = (useService && this._userService.isLoggedIn()) ? this._userService.get_username() : null;
        xsltParameters['navigation-section'] = this._navigationSection;
        xsltParameters['top-level-css-class'] = this._topLevelCssClass;
        xsltParameters['current-item'] = this._currentItem;
        xsltParameters['promotions-section'] = this._promotionsSection$3;
        return xsltParameters;
    },
    
    init: function BFNavigationComponent_BFNavigationComponent$init(environment, componentInstanceName, domElementId, parameters) {
        BFNavigationComponent.BFNavigationComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        if ((parameters['promotions-section']) !== '') {
            this._promotionsSection$3 = parameters['promotions-section'];
        }
    },
    
    logoutEventHandler: function BFNavigationComponent_BFNavigationComponent$logoutEventHandler(sender, eventArgs) {
        this.logout();
        window.event.returnValue = false;
    },
    
    popupEventHandler: function BFNavigationComponent_BFNavigationComponent$popupEventHandler(sender, eventArgs) {
        this.popup(eventArgs.domElement, eventArgs.parameters.getAsString('area'), eventArgs.parameters.getAsString('popupparams'));
        window.event.returnValue = false;
    },
    
    setPageFilter: function BFNavigationComponent_BFNavigationComponent$setPageFilter(liElement, area) {
        if (liElement.tagName !== 'LI') {
            throw new Error('Expected an LI element');
        }
        this.deactivateElement();
        this.activateElement(liElement);
        var pageFilter = {};
        pageFilter['action'] = liElement.attributes.getNamedItem('action').value;
        if (this._promotionsSection$3 !== '' && pageFilter['action'] === 'promotions') {
            pageFilter['action'] += '&progress=' + this._promotionsSection$3;
        }
        this._log.debug('SetPageFilter');
        this._navigationService.goTo(area, pageFilter);
        return false;
    },
    
    logout: function BFNavigationComponent_BFNavigationComponent$logout() {
        this._log.debug('BFNavigationComponent:Logout');
        this.disable();
        this._userService.logout(Delegate.create(this, function(result) {
            this.enable();
            var pageFilter = {};
            pageFilter['action'] = 'homepage';
            this._navigationService.goTo('homepage', pageFilter);
        }), Delegate.create(this, function(exception) {
            this.enable();
        }));
    },
    
    popup: function BFNavigationComponent_BFNavigationComponent$popup(aElement, area, popupParams) {
        this._log.debug('BFNavigationComponent:Popup');
        var action = aElement.parentNode.attributes.getNamedItem('action').value;
        if ((area === 'HelpCentre2' || area === 'HelpCentre') && action === 'default') {
            action += '&selected-menu-id=_MenuItem_Default';
        }
        var pageFilter = {};
        pageFilter['action'] = action;
        window.open(this._environment.buildUrl(area, pageFilter, this._protocol), 'BFWRPhelp', popupParams);
    }
}


BFNavigationComponent.BFNavigationComponent.createClass('BFNavigationComponent.BFNavigationComponent', AbstractWarpComponents.AbstractNavigationComponent);

// ---- 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> ';
        }
    },
    
    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.AbstractComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BFBetSlipComponent');

////////////////////////////////////////////////////////////////////////////////
// BFBetSlipComponent.BFBetSlipComponent

BFBetSlipComponent.BFBetSlipComponent = function BFBetSlipComponent_BFBetSlipComponent() {
    BFBetSlipComponent.BFBetSlipComponent.constructBase(this);
}
BFBetSlipComponent.BFBetSlipComponent.prototype = {
    _lastInputValue$2: null,
    _minimumStake_single$2: null,
    _minimumStake_multibet$2: null,
    _minimumStake_betslip$2: null,
    _totalStake$2: null,
    
    init: function BFBetSlipComponent_BFBetSlipComponent$init(environment, componentInstanceName, domElementId, parameters) {
        this._lastInputValue$2 = {};
        BFBetSlipComponent.BFBetSlipComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._minimumStake_single$2 = parameters['min-stake-single'];
        this._minimumStake_multibet$2 = parameters['min-stake-multibet'];
        this._minimumStake_betslip$2 = parameters['min-stake-betslip'];
    },
    
    populate: function BFBetSlipComponent_BFBetSlipComponent$populate() {
        this.updateSelectionCountDisplay();
        this.toggleFreeBet();
        var content = String.format('\r\n\t\t\t\t\t<table>\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr class=\'nopad\'>\r\n\t\t\t\t\t\t\t\t<th class=\'x\'>\r\n\t\t\t\t\t\t\t\t\t<a href=\'#\' onclick=\"{0}.removeAllSelections(); return false;\">remove all</a>\r\n\t\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t\t\t<th class=\'sel_header\' colspan=\'3\'>\r\n\t\t\t\t\t\t\t\t\tSelections\r\n\t\t\t\t\t\t\t\t</th>\t\t\r\n\t\t\t\t\t\t\t\t<th class=\'odds_header\'>Odds</th>\r\n\t\t\t\t\t\t\t\t<th>E/W</th>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t', this._componentInstanceName);
        var row = 0;
        var currentBet = 0;
        var betSlipCalculation = this._betSlipService.getBetSlipCalculation();
        var $dict1 = this._betSlipService.getSelections();
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var selection = entry.value;
            var selectionDescription = String.format('({0}', decodeURI(selection.MarketName));
            if (selection.Handicap) {
                if (selection.HADValue === 'A') {
                    if (selection.Handicap < 0) {
                        selectionDescription += String.format(' +{0}', selection.Handicap * -1);
                    }
                    else {
                        selectionDescription += String.format(' {0}', selection.Handicap * -1);
                    }
                }
                else {
                    selectionDescription += String.format(' {0}', selection.Handicap);
                }
            }
            if (selection.EachWayPlaceTerms.length === 1) {
                var ew = String.format(', EW 1/{0} 1', selection.EachWayReduction[0]);
                for (var i = 2; i <= selection.EachWayPlaceTerms[0]; i++) {
                    ew += String.format(',{0}', i);
                }
                selectionDescription += ew;
            }
            selectionDescription += ')';
            var parameters = null;
            if (selection.IDFOEventScorecast) {
                parameters = String.format('{0}, {1}, {2}', selection.IDFOEventScorecast, selection.IDFOSelection, selection.IDFOSelectionCS);
            }
            else {
                parameters = String.format('{0}', selection.IDFOSelection);
            }
            var isTrap = (selection.IsTrapBettingOptionOn) ? String.format('\r\n\t\t\t\t\t\t\t<label>Bet on trap   \r\n\t\t\t\t\t\t\t\t<input\r\n\t\t\t\t\t\t\t\t\ttype=\'checkbox\'\r\n\t\t\t\t\t\t\t\t\tonclick=\"{0}.setSimpleSelectionIsTrap({1}, this.checked);\" {2} />\r\n\t\t\t\t\t\t\t\t</label>', this._componentInstanceName, selection.IDFOSelection, (selection.IsTrap) ? 'checked' : '') : '';
            var validPriceTypesForSingle = 0;
            for (var i = 0; i < selection.IDFOPriceType.length; i++) {
                if (FixedOddsBettingService.PriceType.isValidForSingle(selection.IDFOPriceType[i])) {
                    validPriceTypesForSingle++;
                }
            }
            var priceType = '';
            switch (validPriceTypesForSingle) {
                case 1:
                    for (var i = 0; i < selection.IDFOPriceType.length; i++) {
                        if (FixedOddsBettingService.PriceType.isValidForSingle(selection.IDFOPriceType[i])) {
                            priceType = this._fixedOddsBettingService.formatOdds(selection.IDFOPriceType[i], selection.PriceUp, selection.PriceDown);
                            break;
                        }
                    }
                    break;
                default:
                    priceType = String.format('\r\n\t\t\t\t\t\t\t\t<select class=\'bsPriceType\' \r\n\t\t\t\t\t\t\t\t\tonchange=\"{0}.setSimpleSelectionPriceType({1}, this.value);\"\r\n\t\t\t\t\t\t\t\t>', this._componentInstanceName, selection.IDFOSelection);
                    var selecteditem = '';
                    for (var i = 0; i < selection.IDFOPriceType.length; i++) {
                        if (FixedOddsBettingService.PriceType.isValidForSingle(selection.IDFOPriceType[i])) {
                            if (i.toString() === selection.ActivePriceType.toString()) {
                                selecteditem = 'selected';
                            }
                            else {
                                selecteditem = '';
                            }
                            priceType += String.format('\r\n\t\t\t\t\t\t\t\t\t<option value=\'{0}\' {1}>{2}</option>', i, selecteditem, this._fixedOddsBettingService.formatOdds(selection.IDFOPriceType[i], selection.PriceUp, selection.PriceDown));
                        }
                    }
                    priceType += '</select>';
                    break;
            }
            var eachWay = '';
            switch (selection.EachWayReduction.length) {
                case 0:
                    break;
                case 1:
                    eachWay = String.format('\r\n\t\t\t\t\t\t\t\t<label>\r\n\t\t\t\t\t\t\t\t\t<input\r\n\t\t\t\t\t\t\t\t\t\ttype=\'checkbox\'\r\n\t\t\t\t\t\t\t\t\t\t{0}\r\n\t\t\t\t\t\t\t\t\t\tonclick=\"{1}.setSimpleSelectionEachWay({2}, this.checked ? 0 : -1);\"\r\n\t\t\t\t\t\t\t\t\t\tid=\'{3}-{2}-each-way\'\r\n\t\t\t\t\t\t\t\t\t/> \r\n\t\t\t\t\t\t\t\t</label>', (selection.ActiveEachWay < 0) ? '' : 'checked', this._componentInstanceName, selection.IDFOSelection, this._domElementId);
                    break;
                default:
                    eachWay = String.format('\r\n\t\t\t\t\t\t\t\t<select onchange=\"{0}.setSimpleSelectionEachWay({1}, this.value);\">\r\n\t\t\t\t\t\t\t\t\t<option value=\'-1\'>win only</option>', this._componentInstanceName, selection.IDFOSelection);
                    for (var i = 0; i < selection.EachWayReduction.length; i++) {
                        eachWay += String.format('<option value=\'{0}\'>EW 1/{1} {2}</option>', i, selection.EachWayReduction[i], selection.EachWayPlaceTerms[i]);
                    }
                    eachWay += '</select>';
                    break;
            }
            var bIsSingleAllowed = ((',' + selection.ActiveBetTypes + ',').indexOf(',S,') !== -1);
            var stakePerSelection = this._betSlipService.getStakePerSelection()[entry.key];
            content += String.format('\r\n\t\t\t\t\t\t<tr class=\'row{0}\'>\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<td class=\'x\' >\r\n\t\t\t\t\t\t\t\t<a href=\'#\' onclick=\"{8}.remove{9}Selection({10});return false;\">remove</a>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td colspan=\'3\' onmouseout=\"{8}.showSelectionInfoOut()\" onmouseover=\"{8}.show{9}SelectionInfoOver({10},this)\">\r\n                               <div class=\'bsSelectionName\'>\r\n\t\t\t\t\t\t\t\t<strong class=\'selname\'>{2}</strong>\r\n\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td  class=\'odd\'>\r\n                                <div id=\'{4}-{5}-price-type\'>\r\n\t\t\t\t\t\t\t\t{6}\r\n                                </div>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td>{7}</td>\r\n\t\t\t\t\t\t</tr>', (row++) % 2, this._betSlipService.getSelectionsInterRelationColors()[selection.IDFOSelection.toString()], decodeURI(selection.SelectionName), selectionDescription, this._domElementId, entry.key, priceType, eachWay, this._componentInstanceName, (!selection.IDFOEventScorecast) ? '' : 'Scorecast', parameters, stakePerSelection, (!stakePerSelection) ? '' : betSlipCalculation[currentBet].TotalStake.toString(), (!stakePerSelection) ? '' : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(betSlipCalculation[currentBet].PotentialReturn));
            if (bIsSingleAllowed) {
                var SPPrice = 'N/A';
                if (selection.IDFOPriceType[selection.ActivePriceType] === 'SP') {
                    SPPrice = 'SP';
                }
                content += String.format('\r\n\t\t\t\t\t\t<tr class=\'row{0}\'>\r\n\t\t\t\t\t\t\t<td colspan=\'3\' width=\'50%\'>Stake:\r\n\t\t\t\t\t\t\t\t<input class=\' bsstake\' \r\n\t\t\t\t\t\t\t\t\tid=\'{1}-{2}-unit-stake\'\r\n\t\t\t\t\t\t\t\t\tsize=\'8\'\r\n\t\t\t\t\t\t\t\t\ttype=\'text\'\r\n\t\t\t\t\t\t\t\t\tonkeyup=\"{3}.adjustDecimals(this, 2);{3}.setStakePer{4}Selection(this.value, {5});\"\r\n\t\t\t\t\t\t\t\t\tvalue=\'{6}\'\r\n\t\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<!-- td><input type=\'text\' size=\'5\' id=\'{1}-{2}-total-stake\' class=\'num bscostS\' value=\'{7}\' /></td -->\r\n\t\t\t\t\t\t\t<td colspan=\'3\' width=\'50%\'>To Win: <input type=\'text\' size=\'8\' id=\'{1}-{2}-potential-return\' class=\'num bsreturnS\' value=\'{8}\' onfocus=\"{3}.saveContent(this);\" onkeyup=\"{3}.keepContent(this);\" /></td>\r\n\t\t\t\t\t\t</tr>', (row++) % 2, this._domElementId, entry.key, this._componentInstanceName, (!selection.IDFOEventScorecast) ? '' : 'Scorecast', parameters, stakePerSelection, (!stakePerSelection) ? '' : betSlipCalculation[currentBet].TotalStake.toString(), (!stakePerSelection) ? '' : (betSlipCalculation[currentBet].PotentialReturn < 0) ? SPPrice : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(betSlipCalculation[currentBet].PotentialReturn));
            }
            else {
                content += String.format('\r\n\t\t\t\t\t\t<tr class=\'row{0}\'>\r\n\t\t\t\t\t\t\t<td colspan=\'6\'>{1}</td>\r\n\t\t\t\t\t\t</tr>', (row++) % 2, '<span class=\'bs_atleast3\'>Minimum selection rules apply </span>');
            }
            if (isTrap.length > 0) {
                content += '<tr><td colspan=\'6\' align=\'right\'>' + isTrap + '</td></tr>';
            }
            if (stakePerSelection) {
                currentBet++;
            }
        }
        content += '</table><table>';
        if (this._betSlipService.getSelectionsCount() > 1) {
            var allowedBetTypes = this._betSlipService.getAllowedBetTypes();
            if (allowedBetTypes.length > 0) {
                content += '\r\n\t\t\t\t\t\t<tr class=\'nopad multiples\'>\r\n\t\t\t\t\t\t\t<th colspan=\'6\' class=\'multibets_header\'>\r\n\t\t\t\t\t\t\t\t<h3>Multiple Bets</h3>\r\n\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<th>Bet type</th>\r\n\t\t\t\t\t\t\t<th>EW</th>\r\n\t\t\t\t\t\t\t<th colspan=\'2\'>Stake</th>\r\n\t\t\t\t\t\t\t<th colspan=\'2\'>Pot. return</th>\r\n\t\t\t\t\t\t</tr>';
            }
            for (var i = 0; i < allowedBetTypes.length; i++) {
                var naPriceM = 'N/A';
                var $dict3 = this._betSlipService.getSelections();
                for (var $key4 in $dict3) {
                    var entry = { key: $key4, value: $dict3[$key4] };
                    var selectionToCheck = entry.value;
                    if (selectionToCheck.IDFOPriceType[selectionToCheck.ActivePriceType] === 'SP') {
                        naPriceM = 'SP';
                    }
                }
                var stakePerBetType = this._betSlipService.getStakePerBetType()[allowedBetTypes[i].IDFOBetType];
                var eachWay = (allowedBetTypes[i].IsEachWayAllowed) ? String.format('\r\n\t\t\t\t\t\t<label>\r\n\t\t\t\t\t\t\t<input\r\n\t\t\t\t\t\t\t\ttype=\'checkbox\'\r\n\t\t\t\t\t\t\t\t{0}\r\n\t\t\t\t\t\t\t\tonclick=\"{1}.setIsEachWayPerBetType(\'{2}\', this.checked);\"\r\n\t\t\t\t\t\t\t\tid=\'{3}-{2}-each-way\'\r\n\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t</label>', (this._betSlipService.getIsEachWayPerBetType()[allowedBetTypes[i].IDFOBetType]) ? 'checked' : '', this._componentInstanceName, allowedBetTypes[i].IDFOBetType, this._domElementId) : '';
                content += String.format('\r\n\t\t\t\t\t\t<tr class=\'row{0}\'>\r\n\t\t\t\t\t\t\t<td ><div class=\'bettype\'> {1}<div></td>\r\n\t\t\t\t\t\t\t<td class=\'bsew\'>{2}</td>\r\n\t\t\t\t\t\t\t<td colspan=\'2\'>\r\n\t\t\t\t\t\t\t\t<input class=\'bsstake\' \r\n\t\t\t\t\t\t\t\t\tid=\'{8}-{9}-unit-stake\'\r\n\t\t\t\t\t\t\t\t\tsize=\'8\'\r\n\t\t\t\t\t\t\t\t\tvalue=\'{3}\'\r\n\t\t\t\t\t\t\t\t\ttype=\'text\'\r\n\t\t\t\t\t\t\t\t\tonkeyup=\"{4}.adjustDecimals(this, 2);{4}.setStakePerBetType(this.value, \'{5}\');\"\r\n\t\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<!-- td><input type=\'text\' size=\'6\' id=\'{8}-{9}-total-stake\' class=\'num bscostM\' value=\'{6}\' /></td -->\r\n\t\t\t\t\t\t\t<td colspan=\'2\' ><input type=\'text\' size=\'8\' id=\'{8}-{9}-potential-return\' class=\'num bsreturnM\' value=\'{7}\' onfocus=\"{4}.saveContent(this);\" onkeyup=\"{4}.keepContent(this);\"/></td>\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t</tr>', i % 2, allowedBetTypes[i].Name, eachWay, (!stakePerBetType) ? '' : stakePerBetType.toString(), this._componentInstanceName, allowedBetTypes[i].IDFOBetType, (!stakePerBetType) ? '' : betSlipCalculation[currentBet].TotalStake.toString(), (!stakePerBetType) ? '' : (betSlipCalculation[currentBet].PotentialReturn < 0) ? naPriceM : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(betSlipCalculation[currentBet].PotentialReturn), this._domElementId, allowedBetTypes[i].IDFOBetType);
            }
        }
        var totalStake = 0;
        var potentialReturn = 0;
        if (betSlipCalculation) {
            for (var i = 0; i < betSlipCalculation.length; i++) {
                totalStake += betSlipCalculation[i].TotalStake;
                potentialReturn += betSlipCalculation[i].PotentialReturn;
            }
        }
        content += String.format('\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t\t<tfoot>\r\n\t\t\t\t\t\t\t<tr class=\'totalcost\'>\r\n\t\t\t\t\t\t\t\t<th colspan=\'2\'>Total cost:</th>\r\n\t\t\t\t\t\t\t\t<th colspan=\'3\'>\r\n\t\t\t\t\t\t\t\t\t<input type=\'text\' size=\'14\' id=\'{0}-total-stake\' class=\'bstotalcost\' value=\'{1}\' onfocus=\"{3}.saveContent(this);\" onkeyup=\"{3}.keepContent(this);\" />\r\n\t\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t<tr class=\'totalcost\'>\r\n\t\t\t\t\t\t\t\t<th colspan=\'2\'>Total Est. Returns:</th>\r\n\t\t\t\t\t\t\t\t<th colspan=\'3\'>\r\n\t\t\t\t\t\t\t\t\t<input type=\'text\' size=\'14\' id=\'{0}-potential-return\' class=\'bspotentialreturn\' value=\'{2}\' onfocus=\"{3}.saveContent(this);\" onkeyup=\"{3}.keepContent(this);\"/>\r\n\t\t\t\t\t\t\t\t</th>\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</tfoot>\r\n\t\t\t\t\t</table>', this._domElementId, totalStake, AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(potentialReturn), this._componentInstanceName);
        this.updatePrivateDomElementWithCallback('table', content, Delegate.create(this, function() {
            this._log.debug('AfterUpdateElementCallbackSuccess');
            this.adjustHeight();
        }), null);
        var potentialReturnDE = this.getPrivateDomElement('potential-return');
        if (potentialReturnDE) {
            potentialReturnDE.value = this._totalReturnSPCorrection$2(potentialReturn);
        }
        var retainSelectionsAfterPlacementDomElement = this.getPrivateDomElement('retain-selections-after-placement');
        if (retainSelectionsAfterPlacementDomElement) {
            retainSelectionsAfterPlacementDomElement.checked = this._betSlipService.getRetainSelectionsAfterPlacement();
        }
        var isFreeDomElement = this.getPrivateDomElement('is-free');
        if (isFreeDomElement) {
            isFreeDomElement.checked = this._betSlipService.getIsFree();
        }
    },
    
    _totalReturnSPCorrection$2: function BFBetSlipComponent_BFBetSlipComponent$_totalReturnSPCorrection$2(potentialReturn) {
        var totalPotentialReturn = '';
        var SPexists = false;
        var NAexists = false;
        var $dict1 = this._betSlipService.getSelections();
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var oSinglePotentialReturn = this.getPrivateDomElement(String.format('{0}-potential-return', entry.key));
            if (oSinglePotentialReturn) {
                if (oSinglePotentialReturn.value === 'SP') {
                    SPexists = true;
                }
                if (oSinglePotentialReturn.value === 'N/A') {
                    NAexists = true;
                }
            }
        }
        var allowedBetTypesCheck = this._betSlipService.getAllowedBetTypes();
        for (var i = 0; i < allowedBetTypesCheck.length; i++) {
            var oMultiplePotentialReturn = this.getPrivateDomElement(String.format('{0}-potential-return', allowedBetTypesCheck[i].IDFOBetType));
            if (oMultiplePotentialReturn) {
                if (oMultiplePotentialReturn.value === 'SP') {
                    SPexists = true;
                }
                if (oMultiplePotentialReturn.value === 'N/A') {
                    NAexists = true;
                }
            }
        }
        totalPotentialReturn = AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(potentialReturn);
        if (NAexists) {
            totalPotentialReturn = 'N/A';
        }
        if (SPexists) {
            totalPotentialReturn = 'SP';
        }
        return totalPotentialReturn;
    },
    
    populateBetSlipCalculation: function BFBetSlipComponent_BFBetSlipComponent$populateBetSlipCalculation() {
        this.updateSelectionCountDisplay();
        this.toggleFreeBet();
        var currentBet = 0;
        var betSlipCalculation = this._betSlipService.getBetSlipCalculation();
        var $dict1 = this._betSlipService.getSelections();
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var selection = entry.value;
            var unitStakePerSelection = 0;
            if (Object.keyExists(this._betSlipService.getStakePerSelection(), entry.key)) {
                unitStakePerSelection = this._betSlipService.getStakePerSelection()[entry.key];
            }
            var unitStakeInputElement = this.getPrivateDomElement(String.format('{0}-unit-stake', entry.key));
            if (unitStakeInputElement) {
                if (Number.parse(unitStakeInputElement.value) !== unitStakePerSelection) {
                    unitStakeInputElement.value = (!unitStakePerSelection) ? '' : unitStakePerSelection.toString();
                }
            }
            var totalStakeDomElement = this.getPrivateDomElement(String.format('{0}-total-stake', entry.key));
            if (totalStakeDomElement) {
                totalStakeDomElement.value = (!unitStakePerSelection) ? '' : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(betSlipCalculation[currentBet].TotalStake);
            }
            var potentialReturnDomElement = this.getPrivateDomElement(String.format('{0}-potential-return', entry.key));
            if (potentialReturnDomElement) {
                var naPrice = 'N/A';
                if (selection.IDFOPriceType[selection.ActivePriceType] === 'SP') {
                    naPrice = 'SP';
                }
                potentialReturnDomElement.value = (!unitStakePerSelection) ? '' : (betSlipCalculation[currentBet].PotentialReturn < 0) ? naPrice : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(betSlipCalculation[currentBet].PotentialReturn);
            }
            var eachWayDomElement = this.getPrivateDomElement(String.format('{0}-each-way', selection.IDFOSelection));
            if (eachWayDomElement) {
                switch (selection.EachWayPlaceTerms.length) {
                    case 0:
                        break;
                    case 1:
                        (eachWayDomElement).checked = !selection.ActiveEachWay;
                        break;
                    default:
                        (eachWayDomElement).value = selection.ActiveEachWay.toString();
                        break;
                }
            }
            if (unitStakePerSelection) {
                currentBet++;
            }
        }
        var allowedBetTypes = this._betSlipService.getAllowedBetTypes();
        for (var i = 0; i < allowedBetTypes.length; i++) {
            var TotalStake = 0;
            var PotentialReturn = 0;
            for (var y = 0; y < betSlipCalculation.length; y++) {
                if (betSlipCalculation[y].IDFOBetType === allowedBetTypes[i].IDFOBetType) {
                    TotalStake = betSlipCalculation[y].TotalStake;
                    PotentialReturn = betSlipCalculation[y].PotentialReturn;
                }
            }
            var naPriceM = 'N/A';
            if (PotentialReturn < 0) {
                var $dict3 = this._betSlipService.getSelections();
                for (var $key4 in $dict3) {
                    var entry = { key: $key4, value: $dict3[$key4] };
                    var selectionToCheck = entry.value;
                    if (selectionToCheck.IDFOPriceType[selectionToCheck.ActivePriceType] === 'SP') {
                        naPriceM = 'SP';
                    }
                }
            }
            var unitStakePerBetType = 0;
            if (Object.keyExists(this._betSlipService.getStakePerBetType(), allowedBetTypes[i].IDFOBetType)) {
                unitStakePerBetType = this._betSlipService.getStakePerBetType()[allowedBetTypes[i].IDFOBetType];
            }
            var unitStakeInputElement = this.getPrivateDomElement(String.format('{0}-unit-stake', allowedBetTypes[i].IDFOBetType));
            if (unitStakeInputElement) {
                if (Number.parse(unitStakeInputElement.value) !== unitStakePerBetType) {
                    unitStakeInputElement.value = (!unitStakePerBetType) ? '' : unitStakePerBetType.toString();
                }
            }
            var totalStakeDomElement = this.getPrivateDomElement(String.format('{0}-total-stake', allowedBetTypes[i].IDFOBetType));
            if (totalStakeDomElement) {
                totalStakeDomElement.value = (!unitStakePerBetType) ? '' : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(TotalStake);
            }
            var potentialReturnDomElement = this.getPrivateDomElement(String.format('{0}-potential-return', allowedBetTypes[i].IDFOBetType));
            if (potentialReturnDomElement) {
                potentialReturnDomElement.value = (!unitStakePerBetType) ? '' : (PotentialReturn < 0) ? naPriceM : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(PotentialReturn);
            }
            var eachWayDomElement = this.getPrivateDomElement(String.format('{0}-each-way', allowedBetTypes[i].IDFOBetType));
            if (eachWayDomElement) {
                eachWayDomElement.checked = this._betSlipService.getIsEachWayPerBetType()[allowedBetTypes[i].IDFOBetType];
            }
            if (unitStakePerBetType) {
                currentBet++;
            }
        }
        var totalStake = 0;
        var potentialReturn = 0;
        var SPexists = false;
        var NAexists = false;
        if (betSlipCalculation) {
            for (var i = 0; i < betSlipCalculation.length; i++) {
                totalStake += betSlipCalculation[i].TotalStake;
                potentialReturn += betSlipCalculation[i].PotentialReturn;
            }
        }
        this._totalStake$2 = totalStake;
        var totalStakeDE = this.getPrivateDomElement('total-stake');
        if (totalStakeDE) {
            totalStakeDE.value = AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(totalStake);
        }
        var potentialReturnDE = this.getPrivateDomElement('potential-return');
        if (potentialReturnDE) {
            potentialReturnDE.value = (potentialReturn < 0) ? 'N/A' : AbstractMMCoreComponents.AbstractBetSlipComponent.formatNumber(potentialReturn);
            var $dict5 = this._betSlipService.getSelections();
            for (var $key6 in $dict5) {
                var entry = { key: $key6, value: $dict5[$key6] };
                var oSinglePotentialReturn = this.getPrivateDomElement(String.format('{0}-potential-return', entry.key));
                if (oSinglePotentialReturn) {
                    if (oSinglePotentialReturn.value === 'SP') {
                        SPexists = true;
                    }
                    if (oSinglePotentialReturn.value === 'N/A') {
                        NAexists = true;
                    }
                }
            }
            for (var i = 0; i < allowedBetTypes.length; i++) {
                var oMultiplePotentialReturn = this.getPrivateDomElement(String.format('{0}-potential-return', allowedBetTypes[i].IDFOBetType));
                if (oMultiplePotentialReturn) {
                    if (oMultiplePotentialReturn.value === 'SP') {
                        SPexists = true;
                    }
                    if (oMultiplePotentialReturn.value === 'N/A') {
                        NAexists = true;
                    }
                }
            }
            if (NAexists) {
                potentialReturnDE.value = 'N/A';
            }
            if (SPexists) {
                potentialReturnDE.value = 'SP';
            }
        }
        var retainSelectionsAfterPlacementDomElement = this.getPrivateDomElement('retain-selections-after-placement');
        if (retainSelectionsAfterPlacementDomElement) {
            retainSelectionsAfterPlacementDomElement.checked = this._betSlipService.getRetainSelectionsAfterPlacement();
        }
        var isFreeDomElement = this.getPrivateDomElement('is-free');
        if (isFreeDomElement) {
            isFreeDomElement.checked = this._betSlipService.getIsFree();
        }
    },
    
    adjustDecimals: function BFBetSlipComponent_BFBetSlipComponent$adjustDecimals(inTextField, numOfDecimals) {
        if ((!Object.keyExists(this._lastInputValue$2, inTextField.id)) || inTextField.value !== this._lastInputValue$2[inTextField.id].toString()) {
            var inStr = inTextField.value;
            var dec = inStr.indexOf('.');
            if (dec > 0 && inStr.length > dec + numOfDecimals) {
                inTextField.disabled = true;
                inStr = inStr.substr(0, dec + numOfDecimals + 1);
                inTextField.value = inStr;
                inTextField.disabled = false;
                inTextField.focus();
            }
            this._lastInputValue$2[inTextField.id] = inStr;
        }
    },
    
    savedContent: null,
    
    saveContent: function BFBetSlipComponent_BFBetSlipComponent$saveContent(txEl) {
        this.savedContent = txEl.value;
    },
    
    keepContent: function BFBetSlipComponent_BFBetSlipComponent$keepContent(txEl) {
        if (txEl.value !== this.savedContent) {
            txEl.value = this.savedContent;
        }
    },
    
    _minStakeViolated$2: function BFBetSlipComponent_BFBetSlipComponent$_minStakeViolated$2(type, stake) {
        var ret = false;
        switch (type) {
            case 'S':
                var $dict1 = this._betSlipService.getStakePerSelection();
                for (var $key2 in $dict1) {
                    var entry = { key: $key2, value: $dict1[$key2] };
                    if (entry.value < stake) {
                        ret = true;
                    }
                }
                break;
            case 'M':
                var $dict3 = this._betSlipService.getStakePerBetType();
                for (var $key4 in $dict3) {
                    var entry = { key: $key4, value: $dict3[$key4] };
                    if (entry.value < stake) {
                        ret = true;
                    }
                }
                break;
            case 'B':
                if (this._totalStake$2 < stake) {
                    ret = true;
                }
                break;
        }
        return ret;
    },
    
    startBetPlacement: function BFBetSlipComponent_BFBetSlipComponent$startBetPlacement(checkBets) {
        var alertMessage = null;
        this._environment.storeState('betslipInProblem', null);
        this._log.debug('StartBetPlacement');
        if (!this._userService.isLoggedIn()) {
            alert('Please log in');
        }
        else if (!this.hasStake()) {
            alert('Stake must be greater than zero');
        }
        else if (!this._betSlipService.getBetSlipCalculation().length) {
            alert('Please choose a selection');
        }
        else if (this._minStakeViolated$2('S', this._minimumStake_single$2)) {
            alertMessage = 'The minimum stake for single is [' + this._minimumStake_single$2 + ']!';
            this._environment.storeState('betslipInProblem', { message: alertMessage });
            alert(alertMessage);
        }
        else if (this._minStakeViolated$2('M', this._minimumStake_multibet$2)) {
            alertMessage = 'The minimum stake for multiple bets is [' + this._minimumStake_multibet$2 + ']!';
            this._environment.storeState('betslipInProblem', { message: alertMessage });
            alert('The minimum stake for multiple bets is [' + this._minimumStake_multibet$2 + ']!');
        }
        else if (this._minStakeViolated$2('B', this._minimumStake_betslip$2)) {
            alertMessage = 'The minimum total stake for bet slip is [' + this._minimumStake_betslip$2 + ']!';
            this._environment.storeState('betslipInProblem', { message: alertMessage });
            alert('The minimum total stake for bet slip is [' + this._minimumStake_betslip$2 + ']!');
        }
        else {
            if (this._accountService.get_accountsDetails()[1].TradingBalance <= 0) {
                this.setIsFree(false);
            }
            this._betSlipService.placeBetSlip((checkBets) ? FixedOddsBettingService.OverrideToShowConfirmation.overrideToShowConfirmation : FixedOddsBettingService.OverrideToShowConfirmation.notOverride);
        }
    }
}


BFBetSlipComponent.BFBetSlipComponent.createClass('BFBetSlipComponent.BFBetSlipComponent', AbstractMMCoreComponents.AbstractBetSlipComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('DashboardComponent');

////////////////////////////////////////////////////////////////////////////////
// DashboardComponent.DashboardComponent

DashboardComponent.DashboardComponent = function DashboardComponent_DashboardComponent() {
    DashboardComponent.DashboardComponent.constructBase(this);
}
DashboardComponent.DashboardComponent.prototype = {
    _parameters$1: null,
    _accountService$1: null,
    
    setAccountService: function DashboardComponent_DashboardComponent$setAccountService(accountService) {
        this._log.debug('SetAccountService');
        this._accountService$1 = accountService;
    },
    
    onBalanceChanged: function DashboardComponent_DashboardComponent$onBalanceChanged(eventSource) {
        this._log.debug('OnBalanceChanged');
        this.repaint();
    },
    
    onAccountPreferencesChanged: function DashboardComponent_DashboardComponent$onAccountPreferencesChanged(eventSource) {
        this._log.debug('OnAccountPreferencesChanged');
        var dbStyle = (this._accountService$1.get_preferences().IsCallCentreAccountNumberConstantlyDisplayed) ? 'block' : 'none';
        Framework.CookieUtil.setCookie('plchdash', dbStyle);
        this.repaint();
    },
    
    _navigationService$1: null,
    
    setNavigationService: function DashboardComponent_DashboardComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
    },
    
    _playtechService$1: null,
    
    setPlaytechService: function DashboardComponent_DashboardComponent$setPlaytechService(playtechService) {
        this._log.debug('SetPlaytechService');
        this._playtechService$1 = playtechService;
    },
    
    onPlayerInfoChanged: function DashboardComponent_DashboardComponent$onPlayerInfoChanged(eventSource) {
        this._log.debug('OnPlayerInfoChanged');
        this.repaint();
    },
    
    _userService$1: null,
    
    setUserService: function DashboardComponent_DashboardComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$1 = userService;
    },
    
    onUserChanged: function DashboardComponent_DashboardComponent$onUserChanged(userService) {
        this._log.debug('OnUserChanged');
        this.repaint();
    },
    
    init: function DashboardComponent_DashboardComponent$init(environment, componentInstanceName, domElementId, parameters) {
        DashboardComponent.DashboardComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
    },
    
    start: function DashboardComponent_DashboardComponent$start() {
        this._log.debug('Start');
        this.repaint();
    },
    
    repaint: function DashboardComponent_DashboardComponent$repaint() {
        this._log.debug('Repaint');
        var dbStyle = Framework.CookieUtil.getCookie('plchdash');
        if (this.isVisible(this._parameters$1.get_visibleOn(), this._parameters$1.get_notVisibleOn(), this._navigationService$1.getAction()) && this._userService$1.isLoggedIn()) {
            if (this._accountService$1.get_accountsDetails()) {
                var xsltParameters = {};
                xsltParameters['component-instance-name'] = this._componentInstanceName;
                xsltParameters['component-dom-element-id'] = this._domElementId;
                if (this._userService$1.get_personalDetails()) {
                    xsltParameters['name'] = this._userService$1.get_personalDetails().FullName;
                }
                xsltParameters['playtech-balance'] = (!this._playtechService$1.get_playerInfo()) ? 'N/A' : this._playtechService$1.get_playerInfo().Balance.toFixed(2);
                xsltParameters['currency-symbol'] = this._accountService$1.getCurrencySimbol();
                xsltParameters['cash-balance'] = this._accountService$1.get_accountsDetails()[0].WithdrawalBalance.toFixed(2);
                xsltParameters['free-balance'] = this._accountService$1.get_accountsDetails()[1].WithdrawalBalance.toFixed(2);
                xsltParameters['acct-number'] = this._accountService$1.get_accountsDetails()[0].AccountNumber;
                this._environment.transformAndUpdate(this._domElementId, null, this._parameters$1.get_xsltUrl(), xsltParameters, Delegate.create(this, function() {
                    if (dbStyle) {
                        document.getElementById('plchdash').style.display = dbStyle;
                        var parId = document.getElementById('dashboardlink');
                        if (parId) {
                            if (dbStyle === 'none') {
                                (parId).innerText = 'Open Dashboard';
                            }
                            else {
                                (parId).innerText = 'Close Dashboard';
                            }
                        }
                    }
                }));
            }
            else {
                this._environment.updateDomElement(this._domElementId, '');
            }
            this.show();
        }
        else {
            this.hide();
        }
    },
    
    logout: function DashboardComponent_DashboardComponent$logout() {
        this._log.debug('Logout');
        this.disable();
        this._userService$1.logout(Delegate.create(this, function(result) {
            this.enable();
        }), Delegate.create(this, function(exception) {
            this.enable();
        }));
    },
    
    refreshBalance: function DashboardComponent_DashboardComponent$refreshBalance() {
        this._log.debug('RefreshBalance');
        this._accountService$1.fetchAccountsDetails();
        this._playtechService$1.fetchPlayerInfo();
        this.repaint();
        return false;
    },
    
    setPageFilter: function DashboardComponent_DashboardComponent$setPageFilter(action, area) {
        this._log.debug('SetPageFilter');
        this._navigationService$1.goTo(area, { action: action });
        return false;
    }
}


DashboardComponent.DashboardComponent.createClass('DashboardComponent.DashboardComponent', Framework.AbstractComponent, AccountService.IBalanceChangedListener, AccountService.IAccountPreferencesChangedListener, PlaytechService.IPlayerInfoChangedListener, UserService.IUserChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
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('GamesLoginComponent');

////////////////////////////////////////////////////////////////////////////////
// GamesLoginComponent.GamesLoginComponent

GamesLoginComponent.GamesLoginComponent = function GamesLoginComponent_GamesLoginComponent() {
    GamesLoginComponent.GamesLoginComponent.constructBase(this);
}
GamesLoginComponent.GamesLoginComponent.prototype = {
    _gamesHostService$1: null,
    _autoLogin$1: null,
    _autoLogout$1: null,
    
    setGamesHostService: function GamesLoginComponent_GamesLoginComponent$setGamesHostService(gamesHostService) {
        this._log.debug('SetGamesHostService');
        this._gamesHostService$1 = gamesHostService;
    },
    
    _userService$1: null,
    
    setUserService: function GamesLoginComponent_GamesLoginComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$1 = userService;
    },
    
    onUserChanged: function GamesLoginComponent_GamesLoginComponent$onUserChanged(eventSource) {
        this._log.debug('OnUserChanged');
        if (this._gamesHostService$1 && this._gamesHostService$1.isLoggedIn() && this._autoLogout$1 === 'true') {
            this._gamesHostService$1.logout(Delegate.create(this, this._logoutSuccess$1), Delegate.create(this, this._logoutFailure$1));
        }
        this.repaint();
        this._refreshOpener$1();
    },
    
    init: function GamesLoginComponent_GamesLoginComponent$init(environment, componentInstanceName, domElementId, parameters) {
        GamesLoginComponent.GamesLoginComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._autoLogin$1 = (parameters['auto-login']).toLowerCase();
        this._autoLogout$1 = (parameters['auto-logout']).toLowerCase();
    },
    
    repaint: function GamesLoginComponent_GamesLoginComponent$repaint() {
        this._log.debug('Repaint');
        if (this._userService$1 && this._gamesHostService$1) {
            if (this._userService$1.isLoggedIn()) {
                if (!this._gamesHostService$1.isLoggedIn() && this._autoLogin$1 === 'true') {
                    this._gamesHostService$1.login(Delegate.create(this, this._loginSuccess$1), Delegate.create(this, this._loginFailure$1));
                }
            }
            else {
                if (this._gamesHostService$1.isLoggedIn() && this._autoLogout$1 === 'true') {
                    this._gamesHostService$1.logout(Delegate.create(this, this._logoutSuccess$1), Delegate.create(this, this._logoutFailure$1));
                }
            }
        }
    },
    
    _refreshOpener$1: function GamesLoginComponent_GamesLoginComponent$_refreshOpener$1() {
        var opener = window.self;
        while (opener.opener) {
            opener = opener.opener;
            ((opener.location)).reload();
            if (opener) {
                if (opener.parent) {
                    ((opener.parent.location)).reload();
                }
            }
        }
    },
    
    _logoutSuccess$1: function GamesLoginComponent_GamesLoginComponent$_logoutSuccess$1(result) {
        this._log.debug('logoutSuccess');
    },
    
    _logoutFailure$1: function GamesLoginComponent_GamesLoginComponent$_logoutFailure$1(e) {
        this._log.debug('logoutFailure: ' + e.message);
    },
    
    _loginSuccess$1: function GamesLoginComponent_GamesLoginComponent$_loginSuccess$1(result) {
        this._log.debug('loginSuccess');
    },
    
    _loginFailure$1: function GamesLoginComponent_GamesLoginComponent$_loginFailure$1(e) {
        this._log.debug('loginFailure: ' + e.message);
    },
    
    repaintForAdmin: function GamesLoginComponent_GamesLoginComponent$repaintForAdmin() {
        GamesLoginComponent.GamesLoginComponent.callBase(this, 'disableForAdmin');
    }
}


GamesLoginComponent.GamesLoginComponent.createClass('GamesLoginComponent.GamesLoginComponent', Framework.AbstractComponent, UserService.IUserChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('QuickNavigationComponent');

////////////////////////////////////////////////////////////////////////////////
// QuickNavigationComponent.QuickNavigation

QuickNavigationComponent.QuickNavigation = function QuickNavigationComponent_QuickNavigation() {
}
QuickNavigationComponent.QuickNavigation.prototype = {
    id: null,
    contentUrl: null,
    
    compareTo: function QuickNavigationComponent_QuickNavigation$compareTo(obj) {
        var quickNavigation = obj;
        var result = this.contentUrl.compareTo(quickNavigation.contentUrl);
        if (result) {
            return result;
        }
        else if (String.isNullOrEmpty(this.id) && String.isNullOrEmpty(quickNavigation.id)) {
            return 0;
        }
        else if (String.isNullOrEmpty(this.id)) {
            return -1;
        }
        else if (String.isNullOrEmpty(quickNavigation.id)) {
            return 1;
        }
        else {
            return this.id.compareTo(quickNavigation.id);
        }
    }
}


////////////////////////////////////////////////////////////////////////////////
// QuickNavigationComponent.QuickNavigationComponent

QuickNavigationComponent.QuickNavigationComponent = function QuickNavigationComponent_QuickNavigationComponent() {
    this._previousLevels$1 = [];
    QuickNavigationComponent.QuickNavigationComponent.constructBase(this);
}
QuickNavigationComponent.QuickNavigationComponent.prototype = {
    _parameters$1: null,
    _repaintLast$1: false,
    _boNavigationContentUrl$1: null,
    _marketGroupContentUrl$1: null,
    _eventContentUrl$1: null,
    _autoRefreshPeriod: 10000,
    marketGroupType: null,
    
    get_showMarketGroupDropdown: function QuickNavigationComponent_QuickNavigationComponent$get_showMarketGroupDropdown() {
        if (String.isNullOrEmpty(this.marketGroupType)) {
            return true;
        }
        return (String.isNullOrEmpty(this._bettingNavigationService$1.getEvent()) || ((this.marketGroupType === 'SIMPLECOUPON') || (this.marketGroupType === 'USCOUPON')));
    },
    
    _bettingNavigationService$1: null,
    
    setBettingNavigationService: function QuickNavigationComponent_QuickNavigationComponent$setBettingNavigationService(bettingNavigationService) {
        this._log.debug('SetBettingNavigationService');
        this._bettingNavigationService$1 = bettingNavigationService;
    },
    
    _navigationService$1: null,
    
    setNavigationService: function QuickNavigationComponent_QuickNavigationComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.action);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.boNavigation);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketGroup);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketFromMarketGroup);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.event);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketFromEvent);
    },
    
    onPageFilterChanged: function QuickNavigationComponent_QuickNavigationComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this.repaint();
    },
    
    init: function QuickNavigationComponent_QuickNavigationComponent$init(environment, componentInstanceName, domElementId, parameters) {
        QuickNavigationComponent.QuickNavigationComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._repaintLast$1 = Boolean.parse(parameters['repaint-last']);
        this._boNavigationContentUrl$1 = parameters['bo-navigation-content-url'];
        this._marketGroupContentUrl$1 = parameters['market-group-content-url'];
        this._eventContentUrl$1 = parameters['event-content-url'];
        this._autoRefreshPeriod = Number.parse(parameters['auto-refresh-period']);
    },
    
    _repaintItem$1: function QuickNavigationComponent_QuickNavigationComponent$_repaintItem$1(contentUrl, level, selectedId) {
        this._log.debug(String.format('RepaintItem ContentUrl=[{0}] level=[{1}] selectedId=[{2}]', contentUrl, level, selectedId));
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['level'] = level;
        xsltParameters['currently-selected-identifier-value'] = selectedId;
        xsltParameters['current-day'] = Date.get_today().format('yyyy-MM-dd');
        var containingElement = this._getContainingElement$1(level);
        if (!containingElement) {
            containingElement = this._createContainingElement$1(level);
        }
        else {
            this._environment.updateDomElementDirect(containingElement, String.Empty);
        }
        if (!this._autoRefreshPeriod) {
            this._environment.transformAndUpdate(containingElement.id, contentUrl, this._parameters$1.get_xsltUrl(), xsltParameters, null);
        }
        else {
            this._environment.clearPeriodicalTransformAndUpdate(containingElement.id);
            this._environment.periodicalTransformAndUpdate(containingElement.id, contentUrl, this._parameters$1.get_xsltUrl(), xsltParameters, Delegate.create(this, function() {
                var element = this._environment.getDomElement(containingElement.id);
                if (element && element.childNodes.length > 0) {
                    var sele = element.childNodes[0];
                    if (sele) {
                        var type = sele.value.split('|')[0];
                        var marketGroup = this._bettingNavigationService$1.getMarketGroup();
                        var id;
                        if (type === 'idfwbonavigation') {
                            id = this._bettingNavigationService$1.getBONavigation()[level];
                        }
                        else {
                            id = this._bettingNavigationService$1.getMarketGroup();
                        }
                        var seleValue = String.format('{0}|{1}', type, id);
                        if (sele.value !== seleValue) {
                            sele.value = String.format('{0}|{1}', type, id);
                        }
                        if (sele.value !== seleValue) {
                            this.changeDropdown(sele, level);
                        }
                    }
                }
            }), containingElement.id, this._autoRefreshPeriod);
        }
    },
    
    changeDropdown: function QuickNavigationComponent_QuickNavigationComponent$changeDropdown(sele, level) {
        var type = sele.value.split('|')[0];
        var id = sele.value.split('|')[1];
        if (type === 'idfwbonavigation') {
            this.setBONavigation(level, id);
        }
        else {
            this.setMarketGroup(level, id);
        }
    },
    
    _updatePersistedSelection$1: function QuickNavigationComponent_QuickNavigationComponent$_updatePersistedSelection$1(level, id) {
        (this._previousLevels$1[level - 1]).id = id;
    },
    
    _getContainingElement$1: function QuickNavigationComponent_QuickNavigationComponent$_getContainingElement$1(level) {
        return this._environment.getDomElement(this._getContainingElementId$1(level));
    },
    
    _getContainingElementId$1: function QuickNavigationComponent_QuickNavigationComponent$_getContainingElementId$1(level) {
        return this._domElementId + '-' + level;
    },
    
    _createContainingElement$1: function QuickNavigationComponent_QuickNavigationComponent$_createContainingElement$1(level) {
        var result = document.createElement('SPAN');
        result.id = this._getContainingElementId$1(level);
        this._environment.getDomElement(this._domElementId).appendChild(result);
        return result;
    },
    
    _getSelect$1: function QuickNavigationComponent_QuickNavigationComponent$_getSelect$1(level) {
        var containingElement = this._getContainingElement$1(level);
        if (containingElement && containingElement.children.length > 0 && !String.compare(containingElement.children[0].tagName, 'SELECT', true)) {
            return containingElement.children[0];
        }
        return null;
    },
    
    _findDifferenceLevel$1: function QuickNavigationComponent_QuickNavigationComponent$_findDifferenceLevel$1(oldLevels, newLevels) {
        for (var i = 0; i < newLevels.length; i++) {
            if (oldLevels.length - 1 < i || (newLevels[i]).compareTo(oldLevels[i])) {
                return i - ((this._repaintLast$1 && i > 0) ? 1 : 0);
            }
        }
        if (oldLevels.length > newLevels.length) {
            return newLevels.length;
        }
        return -1;
    },
    
    _getLevels$1: function QuickNavigationComponent_QuickNavigationComponent$_getLevels$1() {
        var result = [];
        var boNavigation = this._bettingNavigationService$1.getBONavigation();
        for (var i = 0; i < boNavigation.length; i++) {
            var level = new QuickNavigationComponent.QuickNavigation();
            level.id = (i === boNavigation.length - 1) ? this._bettingNavigationService$1.getMarketGroup() : boNavigation[i + 1];
            level.contentUrl = this._boNavigationContentUrl$1.replace('${idfwbonavigation}', boNavigation[i]);
            result.add(level);
        }
        if (this.get_showMarketGroupDropdown()) {
            var IDFOMarketGroup = this._bettingNavigationService$1.getMarketGroup();
            if (!String.isNullOrEmpty(IDFOMarketGroup)) {
                var level = new QuickNavigationComponent.QuickNavigation();
                level.contentUrl = this._marketGroupContentUrl$1.replace('${idfwmarketgroup}', IDFOMarketGroup);
                level.id = this._bettingNavigationService$1.getMarketFromMarketGroup();
                result.add(level);
            }
        }
        var IDFOEvent = this._bettingNavigationService$1.getEvent();
        if (!String.isNullOrEmpty(IDFOEvent)) {
            var level = new QuickNavigationComponent.QuickNavigation();
            level.contentUrl = this._eventContentUrl$1.replace('${idfoevent}', IDFOEvent);
            level.id = this._bettingNavigationService$1.getMarketFromEvent() || this._bettingNavigationService$1.getEventScorecastFromEvent();
            result.add(level);
        }
        return result;
    },
    
    repaint: function QuickNavigationComponent_QuickNavigationComponent$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 levels = this._getLevels$1();
            var differenceLevel = this._findDifferenceLevel$1(this._previousLevels$1, levels);
            if (differenceLevel >= 0) {
                for (var i = differenceLevel; i < levels.length; i++) {
                    var level = levels[i];
                    this._repaintItem$1(level.contentUrl, i + 1, level.id);
                }
                for (var i = levels.length; i < this._previousLevels$1.length; i++) {
                    this._environment.updateDomElementDirect(this._getContainingElement$1(i + 1), String.Empty);
                }
            }
            this._previousLevels$1 = levels;
        }
        else {
            this.hide();
        }
    },
    
    setBONavigation: function QuickNavigationComponent_QuickNavigationComponent$setBONavigation(level, IDFWBONavigation) {
        this._log.debug(String.format('SetBONavigation level=[{0}] IDFWBONavigation=[{1}]', level, IDFWBONavigation));
        this._updatePersistedSelection$1(level, IDFWBONavigation);
        this._bettingNavigationService$1.setBONavigation(level, IDFWBONavigation);
    },
    
    setMarketGroup: function QuickNavigationComponent_QuickNavigationComponent$setMarketGroup(level, IDFWMarketGroup) {
        this._log.debug(String.format('SetMarketGroup level=[{0}] IDFWMarketGroup=[{1}]', level, IDFWMarketGroup));
        this._updatePersistedSelection$1(level, IDFWMarketGroup);
        this._bettingNavigationService$1.setMarketGroup(level, IDFWMarketGroup);
    },
    
    setMarketFromMarketGroup: function QuickNavigationComponent_QuickNavigationComponent$setMarketFromMarketGroup(level, IDFOMarket) {
        this._log.debug(String.format('SetMarketFromMarketGroup level=[{0}] IDFOMarket=[{1}]', level, IDFOMarket));
        this._updatePersistedSelection$1(level, IDFOMarket);
        this._bettingNavigationService$1.setMarketFromMarketGroup(IDFOMarket);
    },
    
    setMarketFromEvent: function QuickNavigationComponent_QuickNavigationComponent$setMarketFromEvent(level, IDFOMarket) {
        this._log.debug(String.format('SetMarketFromEvent level=[{0}] IDFOMarket=[{1}]', level, IDFOMarket));
        this._updatePersistedSelection$1(level, IDFOMarket);
        this._bettingNavigationService$1.setMarketFromEvent(IDFOMarket);
    },
    
    setEventScorecastFromEvent: function QuickNavigationComponent_QuickNavigationComponent$setEventScorecastFromEvent(level, IDFOEventScorecast) {
        this._log.debug(String.format('SetEventScorecastFromEvent level=[{0}] IDFOEventScorecast=[{1}]', level, IDFOEventScorecast));
        this._updatePersistedSelection$1(level, IDFOEventScorecast);
        this._bettingNavigationService$1.setEventScorecastFromEvent(IDFOEventScorecast);
    }
}


QuickNavigationComponent.QuickNavigation.createClass('QuickNavigationComponent.QuickNavigation');
QuickNavigationComponent.QuickNavigationComponent.createClass('QuickNavigationComponent.QuickNavigationComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BetPlacementComponent');

////////////////////////////////////////////////////////////////////////////////
// BetPlacementComponent.BetPlacementComponent

BetPlacementComponent.BetPlacementComponent = function BetPlacementComponent_BetPlacementComponent() {
    BetPlacementComponent.BetPlacementComponent.constructBase(this);
}


BetPlacementComponent.BetPlacementComponent.createClass('BetPlacementComponent.BetPlacementComponent', AbstractMMCoreComponents.AbstractBetPlacementComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BFMarketGroupListComponent');

////////////////////////////////////////////////////////////////////////////////
// BFMarketGroupListComponent.BFMarketGroupListComponent

BFMarketGroupListComponent.BFMarketGroupListComponent = function BFMarketGroupListComponent_BFMarketGroupListComponent() {
    BFMarketGroupListComponent.BFMarketGroupListComponent.constructBase(this);
}
BFMarketGroupListComponent.BFMarketGroupListComponent.prototype = {
    _idfwMarketGroup$2: '',
    _mediaForRegionData$2: '',
    _sectionsListBetSlipService$2: null,
    
    setSectionsListBetSlipService: function BFMarketGroupListComponent_BFMarketGroupListComponent$setSectionsListBetSlipService(sectionsListBetSlipService) {
        this._log.debug('SetSectionsListBetSlipService');
        this._sectionsListBetSlipService$2 = sectionsListBetSlipService;
    },
    
    onSectionsListSelectionAdded: function BFMarketGroupListComponent_BFMarketGroupListComponent$onSectionsListSelectionAdded(IDFWMarketGroup, selection) {
        this._log.debug(String.format('OnSectionsListSelectionAdded IDFWMarketGroup=[{0}] selection=[{1}]', IDFWMarketGroup, selection));
        var coupon = this._sectionsListBetSlipService$2.getCoupon(IDFWMarketGroup);
        this._checkNoOfSelectionsInEachSection$2(IDFWMarketGroup, this._sectionsListBetSlipService$2.getSelectionsPerSection(coupon.idfwMarketGroupType), selection[0].IDFOSelection);
        for (var i = 0; i < selection.length; i++) {
            var checkBox = this._getSectionsListSelectionCheckBox$2(coupon.idfwMarketGroupType, IDFWMarketGroup, selection[i].IDFOSelection);
            if (checkBox) {
                checkBox.checked = true;
            }
        }
    },
    
    onSectionsListSelectionRemoved: function BFMarketGroupListComponent_BFMarketGroupListComponent$onSectionsListSelectionRemoved(IDFWMarketGroup, selection) {
        this._log.debug(String.format('OnSectionsListSelectionRemoved IDFWMarketGroup=[{0}] selection=[{1}]', IDFWMarketGroup));
        var coupon = this._sectionsListBetSlipService$2.getCoupon(IDFWMarketGroup);
        for (var i = 0; i < selection.length; i++) {
            var checkBox = this._getSectionsListSelectionCheckBox$2(coupon.idfwMarketGroupType, IDFWMarketGroup, selection[i].IDFOSelection);
            if (checkBox) {
                checkBox.checked = false;
            }
        }
    },
    
    onSectionsListBetSlipCalculationChanged: function BFMarketGroupListComponent_BFMarketGroupListComponent$onSectionsListBetSlipCalculationChanged(IDFWMarketGroup) {
        this._log.debug(String.format('OnSectionsListBetSlipCalculationChanged IDFWMarketGroup=[{0}]', IDFWMarketGroup));
        this._updateSectionsListBetSlipData$2(IDFWMarketGroup, false);
    },
    
    onPageFilterChanged: function BFMarketGroupListComponent_BFMarketGroupListComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        var IDFWMarketGroup = this._bettingNavigationService.getMarketGroup();
        if (this._bettingNavigationService.getBONavigation() && this._bettingNavigationService.getBONavigation().length === 3 && !String.isNullOrEmpty(IDFWMarketGroup) && IDFWMarketGroup !== this._idfwMarketGroup$2) {
            this._updateMarketGroup$2(IDFWMarketGroup);
            this._idfwMarketGroup$2 = IDFWMarketGroup;
        }
        else {
            this.repaint();
        }
    },
    
    getXsltParameters: function BFMarketGroupListComponent_BFMarketGroupListComponent$getXsltParameters(displayShowAll) {
        var result = {};
        result['component-instance-name'] = this._componentInstanceName;
        result['component-dom-element-id'] = this._domElementId;
        result['odds-type'] = this._fixedOddsBettingService.getPreferences().OddsType.toUpperCase();
        result['media-images-base-url'] = this._mediaImagesBaseUrl;
        result['mediacoverage-content-url'] = this._mediaCoverageContentUrl;
        result['media-for-region'] = this._mediaCoverageContentData$2();
        result['date-grouping'] = this._dateGrouping;
        result['current-date'] = Date.get_today().format('dd/MM/yyyy');
        result['race-tabs-per-market'] = '';
        if (displayShowAll) {
            result['display-show-all'] = true;
        }
        return result;
    },
    
    _mediaCoverageContentData$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_mediaCoverageContentData$2() {
        if (!this._mediaForRegionData$2.length) {
            var mediaRequest = new XMLHttpRequest();
            mediaRequest.open('GET', this._mediaCoverageContentUrl, false);
            mediaRequest.send('');
            var mediaDocument = mediaRequest.responseXML;
            this._mediaForRegionData$2 = mediaDocument.xml.toString();
        }
        return this._mediaForRegionData$2;
    },
    
    start: function BFMarketGroupListComponent_BFMarketGroupListComponent$start() {
        BFMarketGroupListComponent.BFMarketGroupListComponent.callBase(this, 'start');
        this._navigationService.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.boNavigation);
        this._navigationService.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketGroup);
        this._navigationService.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketFromMarketGroup);
        this._navigationService.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.event);
        this._navigationService.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketFromEvent);
        this._navigationService.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.eventScorecastFromEvent);
    },
    
    repaint: function BFMarketGroupListComponent_BFMarketGroupListComponent$repaint() {
        this._log.debug('Repaint');
        this.clearPeriodicalTransformAndUpdateTasks();
        if (this.isVisible(this._parameters.get_visibleOn(), this._parameters.get_notVisibleOn(), this._navigationService.getAction())) {
            this.show();
            var xsltUrl = this._marketGroupXsltUrl;
            var contentUrl = null;
            var displayShowAll = true;
            var isTabbed = false;
            var autoRefresh = true;
            var IDFOMarketFromEvent = this._bettingNavigationService.getMarketFromEvent();
            if (!String.isNullOrEmpty(IDFOMarketFromEvent)) {
                contentUrl = this._marketContentUrl.replace('${idfomarket}', IDFOMarketFromEvent);
            }
            else {
                var IDFOEventScorecast = this._bettingNavigationService.getEventScorecastFromEvent();
                if (!String.isNullOrEmpty(IDFOEventScorecast)) {
                    contentUrl = this._eventScorecastContentUrl.replace('${idfoeventscorecast}', IDFOEventScorecast).replace('${idfoselectedgoalscorer}', '0');
                }
                else {
                    var IDFOEvent = this._bettingNavigationService.getEvent();
                    if (!String.isNullOrEmpty(IDFOEvent)) {
                        displayShowAll = false;
                        autoRefresh = false;
                        contentUrl = this._eventContentUrl.replace('${idfoevent}', IDFOEvent);
                    }
                    else {
                        var IDFOMarketFromMarketGroup = this._bettingNavigationService.getMarketFromMarketGroup();
                        if (!String.isNullOrEmpty(IDFOMarketFromMarketGroup)) {
                            contentUrl = this._marketContentUrl.replace('${idfomarket}', IDFOMarketFromMarketGroup);
                        }
                        else {
                            var IDFWMarketGroup = this._bettingNavigationService.getMarketGroup();
                            var IDFWBONavigation = this._bettingNavigationService.getBONavigation();
                            if (!String.isNullOrEmpty(IDFWMarketGroup) && IDFWBONavigation.length !== 3) {
                                contentUrl = this._marketGroupContentUrl.replace('${idfwmarketgroup}', IDFWMarketGroup);
                            }
                            else if (IDFWBONavigation && IDFWBONavigation.length > 0) {
                                isTabbed = IDFWBONavigation.length === 3;
                                xsltUrl = this._parameters.get_xsltUrl();
                                autoRefresh = false;
                                contentUrl = this._parameters.get_contentUrl().replace('${idfwbonavigation}', IDFWBONavigation[IDFWBONavigation.length - 1]);
                            }
                        }
                    }
                }
            }
            var xsltParameters = this.getXsltParameters(displayShowAll);
            xsltParameters['active-idfwmarketgroup'] = (String.isNullOrEmpty(this._bettingNavigationService.getMarketGroup())) ? '0' : this._bettingNavigationService.getMarketGroup();
            var displayMoreBets = false;
            var oMarketMG = this._bettingNavigationService.getMarketFromMarketGroup();
            if (oMarketMG) {
                displayMoreBets = true;
            }
            xsltParameters['show-more-bets'] = displayMoreBets.toString();
            if (isTabbed) {
                xsltParameters['is-tabbed'] = true;
            }
            if (!String.isNullOrEmpty(contentUrl)) {
                if (autoRefresh) {
                    this._environment.periodicalTransformAndUpdate(this._domElementId, contentUrl, xsltUrl, xsltParameters, Delegate.create(this, this.transformAndUpdateCallback), this._domElementId, this._autoRefreshPeriod);
                }
                else {
                    this._environment.transformAndUpdate(this._domElementId, contentUrl, xsltUrl, xsltParameters, Delegate.create(this, this.transformAndUpdateCallback));
                }
            }
            else {
                this._environment.updateDomElement(this._domElementId, '');
            }
        }
        else {
            this.hide();
        }
    },
    
    _updateMarketGroup$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_updateMarketGroup$2(IDFWMarketGroup) {
        if (!String.isNullOrEmpty(IDFWMarketGroup)) {
            var tabDomElement = this.getPrivateDomElement('tab-' + IDFWMarketGroup);
            if (tabDomElement) {
                var liTabs = tabDomElement.parentNode.childNodes;
                for (var i = 0; i < liTabs.length; i++) {
                    var curLi = liTabs[i];
                    curLi.className = (curLi.id === tabDomElement.id) ? 'cur' : '';
                    var curDiv = this.getPrivateDomElement(curLi.id.split('-tab-')[1]);
                    curDiv.className = 'botab' + ((curLi.id === tabDomElement.id) ? ' botabshown' : '');
                }
            }
        }
    },
    
    _getSectionsListSelectionCheckBox$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_getSectionsListSelectionCheckBox$2(IDFWMarketGroupType, IDFWMarketGroup, IDFOSelection) {
        return this.getPrivateDomElement(String.format('{0}-{1}-{2}', IDFWMarketGroupType, IDFWMarketGroup, IDFOSelection));
    },
    
    _checkNoOfSelectionsInEachSection$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_checkNoOfSelectionsInEachSection$2(IDFWMarketGroup, AllowedSelsInSection, SelectionJustAdded) {
        var coupon = this._sectionsListBetSlipService$2.getCoupon(IDFWMarketGroup);
        for (var i = 0; i < coupon.selectionsPerSection.length; i++) {
            if (coupon.selectionsPerSection[i] > AllowedSelsInSection) {
                var $dict1 = coupon.selectionsMarketSection;
                for (var $key2 in $dict1) {
                    var item = { key: $key2, value: $dict1[$key2] };
                    if ((item.value.toString() === i.toString()) && (item.key !== SelectionJustAdded.toString())) {
                        this._sectionsListBetSlipService$2.removeSectionsListSelection(coupon.idfwMarketGroupType, IDFWMarketGroup, Number.parse(item.key));
                        this._checkSectionsListBetSlipSelections$2(IDFWMarketGroup);
                    }
                }
            }
        }
    },
    
    _updateSectionsListBetSlipData$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_updateSectionsListBetSlipData$2(IDFWMarketGroup, updateUnitStake) {
        var coupon = this._sectionsListBetSlipService$2.getCoupon(IDFWMarketGroup);
        var totalStakeDomElement = this.getPrivateDomElement(String.format('sections-list-bet-slip-total-stake-{0}', IDFWMarketGroup));
        var potentialReturnDomElement = this.getPrivateDomElement(String.format('sections-list-bet-slip-potential-return-{0}', IDFWMarketGroup));
        var placeBetSlipButton = this.getPrivateDomElement(String.format('sections-list-bet-slip-place-bet-{0}', IDFWMarketGroup));
        if (!coupon.calculation) {
            if (totalStakeDomElement) {
                totalStakeDomElement.innerText = String.Empty;
            }
            if (potentialReturnDomElement) {
                potentialReturnDomElement.innerText = String.Empty;
            }
            if (placeBetSlipButton) {
                placeBetSlipButton.style.display = 'none';
            }
        }
        else {
            if (totalStakeDomElement) {
                totalStakeDomElement.innerText = coupon.calculation.TotalStake.toFixed(2);
            }
            if (potentialReturnDomElement) {
                potentialReturnDomElement.innerText = coupon.calculation.PotentialReturn.toFixed(2);
            }
            if (placeBetSlipButton) {
                placeBetSlipButton.style.display = 'block';
            }
        }
        if (updateUnitStake) {
            var unitStakeDomElement = this.getPrivateDomElement(String.format('sections-list-bet-slip-unit-stake-{0}', IDFWMarketGroup));
            if (unitStakeDomElement) {
                unitStakeDomElement.value = (!coupon.unitStake) ? String.Empty : coupon.unitStake.toFixed(2);
            }
        }
        this._checkSectionsListBetSlipSelections$2(IDFWMarketGroup);
    },
    
    _checkSectionsListBetSlipSelections$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_checkSectionsListBetSlipSelections$2(IDFWMarketGroup) {
        var infoDomElement = this.getPrivateDomElement(String.format('sections-list-bet-slip-info-{0}', IDFWMarketGroup));
        if (infoDomElement) {
            infoDomElement.style.display = (this._sectionsListBetSlipService$2.checkSelectionsPerSection(IDFWMarketGroup)) ? 'none' : 'block';
        }
        var errorDomElement = this.getPrivateDomElement(String.format('sections-list-bet-slip-error-{0}', IDFWMarketGroup));
        if (errorDomElement) {
            errorDomElement.style.display = (this._sectionsListBetSlipService$2.checkSelectionsPerIDFOEvent(IDFWMarketGroup)) ? 'none' : 'block';
        }
    },
    
    transformAndUpdateCallback: function BFMarketGroupListComponent_BFMarketGroupListComponent$transformAndUpdateCallback() {
        BFMarketGroupListComponent.BFMarketGroupListComponent.callBase(this, 'transformAndUpdateCallback');
        var coupons = this._sectionsListBetSlipService$2.getCoupons();
        var $dict1 = coupons;
        for (var $key2 in $dict1) {
            var couponEntry = { key: $key2, value: $dict1[$key2] };
            var coupon = couponEntry.value;
            this._updateSectionsListBetSlipData$2(coupon.idfwMarketGroup, true);
        }
    },
    
    updateCheckboxes: function BFMarketGroupListComponent_BFMarketGroupListComponent$updateCheckboxes() {
        BFMarketGroupListComponent.BFMarketGroupListComponent.callBase(this, 'updateCheckboxes');
        var coupons = this._sectionsListBetSlipService$2.getCoupons();
        var $dict1 = coupons;
        for (var $key2 in $dict1) {
            var couponEntry = { key: $key2, value: $dict1[$key2] };
            var coupon = couponEntry.value;
            var $dict3 = coupon.selections;
            for (var $key4 in $dict3) {
                var selectionEntry = { key: $key4, value: $dict3[$key4] };
                var selection = selectionEntry.value;
                var sectionsListSelectionCheckBoxElement = this._getSectionsListSelectionCheckBox$2(coupon.idfwMarketGroupType, coupon.idfwMarketGroup, selection.IDFOSelection);
                if (sectionsListSelectionCheckBoxElement) {
                    sectionsListSelectionCheckBoxElement.checked = true;
                }
            }
        }
    },
    
    _generateRandomSelectionIndex$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_generateRandomSelectionIndex$2(ceiling) {
        return Math.floor(Math.random() * ceiling);
    },
    
    _generateSectionsListSelectionFromString$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_generateSectionsListSelectionFromString$2(IDFWMarketGroupType, IDFWMarketGroup, marketSection, propertyString) {
        if (String.isNullOrEmpty(propertyString)) {
            return null;
        }
        else {
            var propertyList = propertyString.split('~');
            for (var i = 0; i < propertyList.length; i++) {
                propertyList[i] = propertyList[i].trim();
            }
            if (propertyList.length === 17) {
                return FixedOddsBettingService.Selection.createSectionsListSelection([ 'CP' ], 0, this._jsStringToNumber$2(propertyList[15]), propertyList[16], this._jsStringToNumber$2(propertyList[8]), propertyList[9], propertyList[10], propertyList[11], propertyList[12], propertyList[13], propertyList[4], this._jsStringToNumber$2(propertyList[5]), this._jsStringToNumber$2(propertyList[6]), this._jsStringToNumber$2(propertyList[7]), this._jsStringToNumber$2(propertyList[0]), propertyList[1], this._jsStringToNumber$2(propertyList[2]), this._jsStringToNumber$2(propertyList[3]));
            }
            else {
                return null;
            }
        }
    },
    
    _jsStringToNumber$2: function BFMarketGroupListComponent_BFMarketGroupListComponent$_jsStringToNumber$2(input) {
        if (input === 'null' || input === '') {
            return null;
        }
        else {
            return Number.parse(input);
        }
    },
    
    repaintMarket: function BFMarketGroupListComponent_BFMarketGroupListComponent$repaintMarket(IDFOMarket, displayShowAll) {
        this._log.debug(String.format('RepaintMarket IDFOMarket={0}] displayShowAll=[{1}]', IDFOMarket, displayShowAll));
        this.setActiveRacePoolTab(Number.parse(IDFOMarket));
        if (this.getMarketElement(IDFOMarket)) {
            this.getMarketElement(IDFOMarket).style.display = 'block';
        }
        else {
            this._log.debug(String.format('No element with id {0}-{1}, skipping market repaint', this._domElementId, IDFOMarket));
        }
        var contentUrl = this._marketContentUrl.replace('${idfomarket}', IDFOMarket);
        this._environment.periodicalTransformAndUpdate(this._domElementId + '-' + IDFOMarket, contentUrl, this._marketGroupXsltUrl, this.getXsltParameters(displayShowAll), Delegate.create(this, this.transformAndUpdateCallback), this._domElementId, this._autoRefreshPeriod);
    },
    
    showMarketGroup: function BFMarketGroupListComponent_BFMarketGroupListComponent$showMarketGroup(IDFWMarketGroup) {
        this._log.debug(String.format('ShowMarketGroup IDFWMarketGroup=[{0}]', IDFWMarketGroup));
        this._bettingNavigationService.setMarketGroup(3, IDFWMarketGroup);
    },
    
    hideRightSide: function BFMarketGroupListComponent_BFMarketGroupListComponent$hideRightSide() {
        var right = document.getElementById('right');
        if (right) {
            right.style.display = 'none';
        }
    },
    
    toggleMarket: function BFMarketGroupListComponent_BFMarketGroupListComponent$toggleMarket(IDFOMarket) {
        this._log.debug(String.format('ToggleMarket IDFOMarket=[{0}]', IDFOMarket));
        if (this.getMarketElement(IDFOMarket).style.display === 'none') {
            if (String.isNullOrEmpty(this.getMarketElement(IDFOMarket).innerHTML)) {
                this.repaintMarket(IDFOMarket, true);
            }
            this.getMarketElement(IDFOMarket).style.display = 'block';
        }
        else {
            this.getMarketElement(IDFOMarket).style.display = 'none';
        }
    },
    
    toggleMarketAndMore: function BFMarketGroupListComponent_BFMarketGroupListComponent$toggleMarketAndMore(IDFOMarket, oElement) {
        var elementText = oElement.innerHTML;
        if (elementText === 'Show') {
            oElement.innerHTML = 'Hide';
            oElement.className = 'hide';
            var oParentElement = oElement.parentNode;
            oParentElement.className = 'togglehide';
        }
        else {
            oElement.innerHTML = 'Show';
            oElement.className = 'show';
            var oParentElement = oElement.parentNode;
            oParentElement.className = 'toggleshow';
        }
        this.toggleMarket(IDFOMarket);
    },
    
    onLuckyDipClick: function BFMarketGroupListComponent_BFMarketGroupListComponent$onLuckyDipClick(IDFWMarketGroupType, IDFWMarketGroup, selectionsPerSection) {
        this._log.debug(String.format('OnLuckyDipClick IDFWMarketGroupType=[{0}] IDFWMarketGroup=[{1}] selectionsPerSection=[{2}]', IDFWMarketGroup, IDFWMarketGroup, selectionsPerSection));
        if (!this.getPrivateDomElement(String.format('{0}-{1}-sectionslist-table', IDFWMarketGroupType, IDFWMarketGroup))) {
            return;
        }
        var sectionsListInputCollection = this.getPrivateDomElement(String.format('{0}-{1}-sectionslist-table', IDFWMarketGroupType, IDFWMarketGroup)).getElementsByTagName('input');
        var selectionPropertiesList = new Array(BFMarketGroupListComponent.BFMarketGroupListComponent._sections$2);
        var randomNumbers = new Array(BFMarketGroupListComponent.BFMarketGroupListComponent._sections$2 * selectionsPerSection);
        var randomSelectionsMarketSections = [];
        var randomSelections = [];
        for (var i = 0; i < BFMarketGroupListComponent.BFMarketGroupListComponent._sections$2; i++) {
            selectionPropertiesList[i] = [];
        }
        for (var i = 0; i < sectionsListInputCollection.length; i++) {
            if (!String.isNullOrEmpty(sectionsListInputCollection[i].getAttribute('marketsection'))) {
                selectionPropertiesList[Number.parse(sectionsListInputCollection[i].getAttribute('marketsection').toString())].add(sectionsListInputCollection[i].getAttribute('selectionProperties'));
            }
        }
        for (var i = 0; i < randomNumbers.length; i++) {
            var marketSection = (selectionsPerSection === 2) ? Math.floor(i / 2) : i;
            randomNumbers[i] = this._generateRandomSelectionIndex$2(selectionPropertiesList[marketSection].length);
            var newSelection = this._generateSectionsListSelectionFromString$2(IDFWMarketGroupType, IDFWMarketGroup, marketSection, selectionPropertiesList[marketSection][randomNumbers[i]].toString());
            if (selectionsPerSection === 2 && (i % 2)) {
                var previousIDFOEvent = (randomSelections[i - 1]).IDFOEvent;
                while (previousIDFOEvent === newSelection.IDFOEvent) {
                    randomNumbers[i] = this._generateRandomSelectionIndex$2((selectionPropertiesList[marketSection]).length);
                    newSelection = this._generateSectionsListSelectionFromString$2(IDFWMarketGroupType, IDFWMarketGroup, marketSection, selectionPropertiesList[marketSection][randomNumbers[i]].toString());
                }
            }
            randomSelections.add(newSelection);
            randomSelectionsMarketSections.add(marketSection);
        }
        this._sectionsListBetSlipService$2.addSectionsListSelection(IDFWMarketGroupType, IDFWMarketGroup, randomSelectionsMarketSections, randomSelections, true);
    },
    
    onSectionsListClick: function BFMarketGroupListComponent_BFMarketGroupListComponent$onSectionsListClick(IDFWMarketGroupType, IDFWMarketGroup, marketSection, IDFOSelection) {
        this._log.debug(String.format('OnSectionsListClick IDFWMarketGroupType=[{0}] IDFWMarketGroup=[{1}] marketSection=[{2}] IDFOSelection=[{3}]', IDFWMarketGroupType, IDFWMarketGroup, marketSection, IDFOSelection));
        var sectionsCheckBoxElement = this._getSectionsListSelectionCheckBox$2(IDFWMarketGroupType, IDFWMarketGroup, IDFOSelection);
        if (!sectionsCheckBoxElement) {
            return;
        }
        if (sectionsCheckBoxElement.checked) {
            var newSelection = this._generateSectionsListSelectionFromString$2(IDFWMarketGroupType, IDFWMarketGroup, marketSection, sectionsCheckBoxElement.getAttribute('selectionProperties'));
            if (newSelection) {
                this._sectionsListBetSlipService$2.addSectionsListSelection(IDFWMarketGroupType, IDFWMarketGroup, [ marketSection ], [ newSelection ], false);
            }
        }
        else {
            this._sectionsListBetSlipService$2.removeSectionsListSelection(IDFWMarketGroupType, IDFWMarketGroup, IDFOSelection);
        }
        this._checkSectionsListBetSlipSelections$2(IDFWMarketGroup);
    },
    
    setUnitStakePerCoupon: function BFMarketGroupListComponent_BFMarketGroupListComponent$setUnitStakePerCoupon(IDFWMarketGroupType, IDFWMarketGroup, unitStake) {
        this._log.debug(String.format('SetUnitStakePerCoupon IDFWMarketGroupType=[{0}] IDFWMarketGroup=[{1}] unitStake=[{2}]', IDFWMarketGroupType, IDFWMarketGroup, unitStake));
        this._sectionsListBetSlipService$2.setUnitStakePerCoupon(IDFWMarketGroupType, IDFWMarketGroup, Number.parse(unitStake));
    },
    
    placeCoupon: function BFMarketGroupListComponent_BFMarketGroupListComponent$placeCoupon(IDFWMarketGroup) {
        this._log.debug(String.format('PlaceCoupon IDFWMarketGroup=[{0}]', IDFWMarketGroup));
        if (!this._userService.isLoggedIn()) {
            alert('Please log in');
        }
        else if (this._sectionsListBetSlipService$2.getCoupon(IDFWMarketGroup).calculation) {
            var placeBetSlipButton = this.getPrivateDomElement(String.format('sections-list-bet-slip-place-bet-{0}', IDFWMarketGroup));
            if (placeBetSlipButton) {
                placeBetSlipButton.disabled = true;
            }
            this._sectionsListBetSlipService$2.placeCoupon(IDFWMarketGroup);
        }
    }
}


BFMarketGroupListComponent.BFMarketGroupListComponent.createClass('BFMarketGroupListComponent.BFMarketGroupListComponent', AbstractWarpComponents.AbstractMarketGroupListComponent, SectionsListBetSlipService.ISectionsListSelectionAddedListener, SectionsListBetSlipService.ISectionsListSelectionRemovedListener, SectionsListBetSlipService.ISectionsListBetSlipCalculationChangedListener, NavigationService.IPageFilterChangedListener);
BFMarketGroupListComponent.BFMarketGroupListComponent._sections$2 = 5;
BFMarketGroupListComponent.BFMarketGroupListComponent.marketsPerSection = 6;

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('FastSearchResultsComponent');

////////////////////////////////////////////////////////////////////////////////
// FastSearchResultsComponent.FastSearchResultsComponent

FastSearchResultsComponent.FastSearchResultsComponent = function FastSearchResultsComponent_FastSearchResultsComponent() {
    FastSearchResultsComponent.FastSearchResultsComponent.constructBase(this);
}
FastSearchResultsComponent.FastSearchResultsComponent.prototype = {
    _fastSearchUrl$2: null,
    
    init: function FastSearchResultsComponent_FastSearchResultsComponent$init(environment, componentInstanceName, domElementId, parameters) {
        FastSearchResultsComponent.FastSearchResultsComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._fastSearchUrl$2 = parameters['fast-search-content-url'];
    },
    
    start: function FastSearchResultsComponent_FastSearchResultsComponent$start() {
        FastSearchResultsComponent.FastSearchResultsComponent.callBase(this, 'start');
        this._navigationService.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.phrase);
    },
    
    repaint: function FastSearchResultsComponent_FastSearchResultsComponent$repaint() {
        this._log.debug('Repaint');
        if (this.isVisible(this._parameters.get_visibleOn(), this._parameters.get_notVisibleOn(), this._navigationService.getAction())) {
            this.show();
            var xsltParameters = {};
            xsltParameters['component-instance-name'] = this._componentInstanceName;
            xsltParameters['component-dom-element-id'] = this._domElementId;
            var phrase = this._bettingNavigationService.getSearchPhrase();
            var contentUrl = this._fastSearchUrl$2.replace('${phrase}', eval('escape(escape(\'' + phrase + '\'))').toString());
            this._environment.transformAndUpdate(this._domElementId, contentUrl, this._parameters.get_xsltUrl(), xsltParameters, null);
        }
        else {
            this.hide();
        }
    }
}


FastSearchResultsComponent.FastSearchResultsComponent.createClass('FastSearchResultsComponent.FastSearchResultsComponent', AbstractWarpComponents.AbstractMarketGroupListComponent);

// ---- 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,
    _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');
        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);
    },
    
    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)
// -----------------------------------
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('MultibetsBetSlipComponent');

////////////////////////////////////////////////////////////////////////////////
// MultibetsBetSlipComponent.MultibetsBetSlipComponent

MultibetsBetSlipComponent.MultibetsBetSlipComponent = function MultibetsBetSlipComponent_MultibetsBetSlipComponent() {
    MultibetsBetSlipComponent.MultibetsBetSlipComponent.constructBase(this);
}
MultibetsBetSlipComponent.MultibetsBetSlipComponent._formatNumber$1 = function MultibetsBetSlipComponent_MultibetsBetSlipComponent$_formatNumber$1(number) {
    return number.toFixed(2);
}
MultibetsBetSlipComponent.MultibetsBetSlipComponent.prototype = {
    _parameters$1: null,
    
    _populateBetsTable$1: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$_populateBetsTable$1() {
        this._log.debug('PopulateBetsTable');
        if (!this.isVisible(this._parameters$1.get_visibleOn(), this._parameters$1.get_notVisibleOn(), this._navigationService$1.getAction())) {
            return;
        }
        this._log.debug('PopulateBetsTable populating single bets table');
        var tableContent = '\r\n\t\t\t\t\t<table id=\'BS_selTable\'><tbody>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<th>Market</th>\r\n\t\t\t\t\t\t\t<th>&nbsp;</th>\r\n\t\t\t\t\t\t\t<th>Selection</th>\r\n\t\t\t\t\t\t\t<th>Odds</th>\r\n\t\t\t\t\t\t\t<th>Stake</th>\r\n\t\t\t\t\t\t\t<th>Total</th>\r\n\t\t\t\t\t\t\t<th>Estimated return</th>\r\n\t\t\t\t\t\t\t<th>Remove</th>';
        var currentBet = 0;
        var betSlipCalculation = this._betSlipService$1.getBetSlipCalculation();
        var row = 0;
        var $dict1 = this._betSlipService$1.getSelections();
        for (var $key2 in $dict1) {
            var entry = { key: $key2, value: $dict1[$key2] };
            var selection = entry.value;
            var selectionKey = this._betSlipService$1.getSelectionKey(selection);
            var stakePerSelection = this._betSlipService$1.getStakePerSelection()[selectionKey];
            var parameters = null;
            if (!selection.IDFOEventScorecast) {
                parameters = String.format('\'{0}\', {1}', selection.IDFOPriceType, selection.IDFOSelection);
            }
            else {
                parameters = String.format('{0}, \'{1}\', {2}, {3}', selection.IDFOEventScorecast, selection.IDFOPriceType, selection.IDFOSelection, selection.IDFOSelectionCS);
            }
            tableContent += String.format('\r\n\t\t\t\t\t\t<tr class=\'row{0}\'>\r\n\t\t\t\t\t\t\t<td>{1}<br/><span class=\'betslipinfoMarket\'>{2}</span></td>\r\n\t\t\t\t\t\t\t<td class=\'BSIRTagColour{3}\'>&nbsp;</td>\r\n\t\t\t\t\t\t\t<td><strong>{4}</strong></td>\r\n\t\t\t\t\t\t\t<td>{5}</td>\r\n\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t<input\r\n\t\t\t\t\t\t\t\t\ttype=\'text\'\r\n\t\t\t\t\t\t\t\t\tsize=\'5\'\r\n\t\t\t\t\t\t\t\t\tvalue=\'{6}\'\r\n\t\t\t\t\t\t\t\t\tonchange=\"{7}.setStakePer{8}Selection({9}, this.value)\"\r\n\t\t\t\t\t\t\t\t\tonkeyup=\"{7}.setStakePer{8}Selection({9}, this.value)\"\r\n\t\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t<td id=\'{10}-{11}-total-stake\'>{12}</td>\r\n\t\t\t\t\t\t\t<td id=\'{10}-{11}-potential-return\'>{13}</td>\r\n\t\t\t\t\t\t\t<td align=\'center\'><a href=\'#\' class=\'x\' onclick=\"{7}.remove{8}Selection({9})\">remove</a></td>\r\n\t\t\t\t\t\t</tr>', (row++) % 2, decodeURI(selection.EventName), decodeURI(selection.MarketName), this._betSlipService$1.getSelectionsInterRelationColors()[selection.IDFOSelection.toString()], decodeURI(selection.SelectionName), this._fixedOddsBettingService$1.formatOdds(selection.IDFOPriceType[selection.ActivePriceType], selection.PriceUp, selection.PriceDown), stakePerSelection, this._componentInstanceName, (!selection.IDFOEventScorecast) ? '' : 'Scorecast', parameters, this._domElementId, selectionKey, (!stakePerSelection) ? '' : betSlipCalculation[currentBet].TotalStake.toString(), (!stakePerSelection) ? '' : MultibetsBetSlipComponent.MultibetsBetSlipComponent._formatNumber$1(betSlipCalculation[currentBet].PotentialReturn));
            if (stakePerSelection) {
                currentBet++;
            }
        }
        tableContent += '</tbody></table>';
        this._environment.updateDomElement(this._domElementId + '-single-bets', tableContent);
        this._log.debug('PopulateBetsTable populating multiple bets table');
        tableContent = '\r\n\t\t\t\t\t<table>\r\n\t\t\t\t\t\t<tbody>\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<th>Bet type</th>\r\n\t\t\t\t\t\t\t\t<th>Stake</th>\r\n\t\t\t\t\t\t\t\t<th class=\'multibets-column-cost\'>Cost</th>\r\n\t\t\t\t\t\t\t\t<th class=\'multibets-column-return\'>Estimated return</th>\r\n\t\t\t\t\t\t\t</tr>';
        var allowedBetTypes = this._betSlipService$1.getAllowedBetTypes();
        for (var i = 0; i < allowedBetTypes.length; i++) {
            tableContent += String.format('\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<td>{0}</td>\r\n\t\t\t\t\t\t\t\t<td>\r\n\t\t\t\t\t\t\t\t\t<input\r\n\t\t\t\t\t\t\t\t\t\ttype=\'text\'\r\n\t\t\t\t\t\t\t\t\t\tsize=\'5\'\r\n\t\t\t\t\t\t\t\t\t\tvalue=\'{1}\'\r\n\t\t\t\t\t\t\t\t\t\tonchange=\"{2}.setStakePerBetType(\'{3}\', this.value)\"\r\n\t\t\t\t\t\t\t\t\t\tonkeyup=\"{2}.setStakePerBetType(\'{3}\', this.value)\"\r\n\t\t\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t\t\t</td>\r\n\t\t\t\t\t\t\t\t<td class=\'multibets-column-cost\' id=\'{4}-{3}-total-stake\'>{5}</td>\r\n\t\t\t\t\t\t\t\t<td class=\'multibets-column-return\' id=\'{4}-{3}-estimated-return\'>{6}</td>\r\n\t\t\t\t\t\t\t</tr>', allowedBetTypes[i].Name, this._betSlipService$1.getStakePerBetType()[allowedBetTypes[i].IDFOBetType], this._componentInstanceName, allowedBetTypes[i].IDFOBetType, this._domElementId, (!this._betSlipService$1.getStakePerBetType()[allowedBetTypes[i].IDFOBetType]) ? '' : betSlipCalculation[currentBet].TotalStake.toString(), (!this._betSlipService$1.getStakePerBetType()[allowedBetTypes[i].IDFOBetType]) ? '' : MultibetsBetSlipComponent.MultibetsBetSlipComponent._formatNumber$1(betSlipCalculation[currentBet].PotentialReturn));
            if (this._betSlipService$1.getStakePerBetType()[allowedBetTypes[i].IDFOBetType]) {
                currentBet++;
            }
        }
        var totalStake = 0, potentialReturn = 0;
        if (betSlipCalculation) {
            for (var i = 0; i < betSlipCalculation.length; i++) {
                totalStake += betSlipCalculation[i].TotalStake;
                potentialReturn += betSlipCalculation[i].PotentialReturn;
            }
        }
        tableContent += String.format('\r\n\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t<th colspan=\'2\'>\r\n\t\t\t\t\t\t\t\t\tTotal cost:\r\n\t\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t\t\t<th class=\'multibets-column-cost\'>\r\n\t\t\t\t\t\t\t\t\t<input class=\'cameleon\' name=\'BS_betcost\' id=\'BS_betcost\' size=\'5\' readonly=\'readonly\' type=\'text\' value=\'{0}\' />\r\n\t\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t\t\t<th class=\'multibets-column-return\'>\r\n\t\t\t\t\t\t\t\t\t<input class=\'cameleon\' name=\'BS_betreturn\' id=\'BS_betreturn\' size=\'10\' readonly=\'readonly\' type=\'text\' value=\'{1:n2}\' />\r\n\t\t\t\t\t\t\t\t</th>\r\n\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t</tbody>\r\n\t\t\t\t\t</table>', totalStake, potentialReturn);
        this._log.debug('PopulateBetsTable populating total stake and potential return');
        this._environment.updateDomElement(this._domElementId + '-multiple-bets', tableContent);
        this._updateInterrelationNote$1();
    },
    
    _updateInterrelationNote$1: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$_updateInterrelationNote$1() {
        var element = document.getElementById(this._domElementId + '-irnote');
        if (element) {
            element.style.display = (Object.getKeyCount(this._betSlipService$1.getSelectionsInterRelationColors()) > 0) ? 'block' : 'none';
        }
    },
    
    _betSlipService$1: null,
    
    setBetSlipService: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setBetSlipService(betSlipService) {
        this._log.debug('SetBetSlipService');
        this._betSlipService$1 = betSlipService;
    },
    
    onSelectionsRemoved: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$onSelectionsRemoved(eventSource, selection) {
        this._log.debug('OnSelectionsRemoved');
        this._populateBetsTable$1();
    },
    
    onBetSlipCalculationChanged: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$onBetSlipCalculationChanged(eventSource) {
        this._log.debug('OnBetSlipCalculationChanged');
        this._populateBetsTable$1();
    },
    
    _fixedOddsBettingService$1: null,
    
    setFixedOddsBettingService: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setFixedOddsBettingService(fixedOddsBettingService) {
        this._log.debug('SetFixedOddsBettingService');
        this._fixedOddsBettingService$1 = fixedOddsBettingService;
    },
    
    onOddsTypeChanged: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$onOddsTypeChanged(fixedOddsBettingService) {
        this._log.debug('OnOddsTypeChanged');
        this.repaint();
    },
    
    _navigationService$1: null,
    
    setNavigationService: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.action);
    },
    
    onPageFilterChanged: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this.repaint();
    },
    
    _userService$1: null,
    
    setUserService: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$1 = userService;
    },
    
    init: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$init(environment, componentInstanceName, domElementId, parameters) {
        MultibetsBetSlipComponent.MultibetsBetSlipComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
    },
    
    repaint: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$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['component-dom-element-id'] = this._domElementId;
            this._environment.transformAndUpdate(this._domElementId, this._parameters$1.get_contentUrl(), this._parameters$1.get_xsltUrl(), xsltParameters, Delegate.create(this, function() {
                this._populateBetsTable$1();
            }));
        }
        else {
            this.hide();
        }
    },
    
    setStakePerSelection: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setStakePerSelection(IDFOPriceType, IDFOSelection, stake) {
        this._log.debug(String.format('SetStakePerSelection IDFOPriceType=[{0}] IDFOSelection=[{1}] stake=[{2}]', IDFOPriceType, IDFOSelection, stake));
        this._betSlipService$1.setStakePerSelection(IDFOSelection, Number.parse(stake));
    },
    
    setStakePerScorecastSelection: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setStakePerScorecastSelection(IDFOEventScorecast, IDFOPriceType, IDFOSelection1GS, IDFOSelectionCS, stake) {
        this._log.debug(String.format('SetStakePerScorecastSelection IDFOEventScorecast=[{0}] IDFOPriceType=[{1}] IDFOSelection1GS=[{2}] IDFOSelectionCS=[{3}] stake=[{4}]', IDFOEventScorecast, IDFOPriceType, IDFOSelection1GS, IDFOSelectionCS, stake));
        this._betSlipService$1.setStakePerScorecastSelection(IDFOEventScorecast, IDFOSelection1GS, IDFOSelectionCS, stake);
    },
    
    setStakePerBetType: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setStakePerBetType(IDFOBetType, stake) {
        this._log.debug(String.format('SetStakePerBetType IDFOBetType=[{0}] stake=[{1}]', IDFOBetType, stake));
        this._betSlipService$1.setStakePerBetType(IDFOBetType, Number.parse(stake), false);
    },
    
    removeSelection: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$removeSelection(IDFOPriceType, IDFOSelection) {
        this._log.debug(String.format('RemoveSelection IDFOPriceType=[{0}] IDFOSelection=[{1}]', IDFOPriceType, IDFOSelection));
        this._betSlipService$1.removeSelection(IDFOSelection);
    },
    
    removeScorecastSelection: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$removeScorecastSelection(IDFOEventScorecast, IDFOPriceType, IDFOSelection1GS, IDFOSelectionCS) {
        this._log.debug(String.format('RemoveScorecastSelection IDFOEventScorecast=[{0}] IDFOPriceType=[{1}] IDFOSelection1GS=[{2}] IDFOSelectionCS=[{3}]', IDFOEventScorecast, IDFOPriceType, IDFOSelection1GS, IDFOSelectionCS));
        this._betSlipService$1.removeScorecastSelection(IDFOEventScorecast, IDFOSelection1GS, IDFOSelectionCS);
    },
    
    setRetainSelectionsAfterPlacement: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$setRetainSelectionsAfterPlacement(retainSelectionsAfterPlacement) {
        this._log.debug(String.format('SetRetainSelectionsAfterPlacement retainSelectionsAfterPlacement=[{0}]', retainSelectionsAfterPlacement));
        this._betSlipService$1.setRetainSelectionsAfterPlacement(retainSelectionsAfterPlacement);
    },
    
    placeBetSlip: function MultibetsBetSlipComponent_MultibetsBetSlipComponent$placeBetSlip() {
        this._log.debug('PlaceBetSlip');
        if (!this._userService$1.isLoggedIn()) {
            alert('Please log in');
        }
        else if (!this._betSlipService$1.getBetSlipCalculation().length) {
            alert('Please choose a selection');
        }
        else {
            this._navigationService$1.goTo(this._navigationService$1.getPageArea(), { action: 'bet-placement' });
        }
    }
}


MultibetsBetSlipComponent.MultibetsBetSlipComponent.createClass('MultibetsBetSlipComponent.MultibetsBetSlipComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener, BetSlipService.ISelectionsRemovedListener, BetSlipService.IBetSlipCalculationChangedListener, FixedOddsBettingService.IOddsTypeChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BFAffiliateTrackingComponent');

////////////////////////////////////////////////////////////////////////////////
// BFAffiliateTrackingComponent.BFAffiliateTrackingComponent

BFAffiliateTrackingComponent.BFAffiliateTrackingComponent = function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent() {
    BFAffiliateTrackingComponent.BFAffiliateTrackingComponent.constructBase(this);
}
BFAffiliateTrackingComponent.BFAffiliateTrackingComponent.prototype = {
    _kowabungaOnUserRegistered$1: '\r\n\t\t\t<img src=\'https://ee.connextra.com/Betfred/pc.gif?page=regconfirm\' height=\'0\' width=\'0\' alt=\'\' />\r\n\t\t\t<img src=\'https://affiliate.connextra.com/addlead.asp?c={0}\' height=\'0\' width=\'0\' alt=\'\' />',
    _kowabungaMinimalTotalStake$1: 10,
    _kowabungaOnBetPlaced$1: '\r\n\t\t\t<img src=\'http://aa.connextra.com/Betfred/pc.gif?page=betconfirm\' height=\'0\' width=\'0\' alt=\'\' />',
    _kowabungaOnBetPlacedConditional$1: '\r\n\t\t\t<img src=\'http://affiliate.connextra.com/addorder.asp?a={0}&c={1}\' height=\'0\' width=\'0\' alt=\'\' />',
    _isRegistrationPending$1: false,
    
    _handleRegistration$1: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$_handleRegistration$1() {
        var domElement = this._environment.getDomElement(this._domElementId);
        var creditAccountDetails = this._accountService$1.get_creditAccountDetails();
        domElement.innerHTML += String.format(this._kowabungaOnUserRegistered$1, creditAccountDetails.AccountNumber);
        this._isRegistrationPending$1 = false;
    },
    
    _accountService$1: null,
    
    setAccountService: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$setAccountService(accountService) {
        this._log.debug('SetAccountService');
        this._accountService$1 = accountService;
    },
    
    onBalanceChanged: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$onBalanceChanged(eventSource) {
        this._log.debug('OnBalanceChanged');
        if (this._isRegistrationPending$1 && this._accountService$1.get_accountsDetails()) {
            this._handleRegistration$1();
        }
    },
    
    _bfUserService$1: null,
    
    setBFUserService: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$setBFUserService(bfUserService) {
        this._log.debug('SetBFUserService');
        this._bfUserService$1 = bfUserService;
    },
    
    onUserRegistered: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$onUserRegistered() {
        this._log.debug('OnUserRegistered');
        if (this._accountService$1.get_accountsDetails() && this._accountService$1.get_accountsDetails().length) {
            this._handleRegistration$1();
        }
        else {
            this._isRegistrationPending$1 = true;
        }
    },
    
    _fixedOddsBettingService$1: null,
    
    setFixedOddsBettingService: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$setFixedOddsBettingService(fixedOddsBettingService) {
        this._log.debug('SetFixedOddsBettingService');
        this._fixedOddsBettingService$1 = fixedOddsBettingService;
    },
    
    onBetPlacementStateChanged: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$onBetPlacementStateChanged() {
        this._log.debug('OnBetPlacementStateChanged');
        if (this._fixedOddsBettingService$1.get_betPlacementState() === FixedOddsBettingService.BetPlacementState.placed) {
            var creditAccountDetails = this._accountService$1.get_creditAccountDetails();
            var betSlipCalculation = this._fixedOddsBettingService$1.get_betSlipCalculation();
            var totalStake = 0;
            for (var i = 0; i < betSlipCalculation.length; i++) {
                totalStake += betSlipCalculation[i].TotalStake;
            }
            var IDFOBetSlip = this._fixedOddsBettingService$1.get_betSlipOutbound().IDFOBetSlip;
            var domElement = this._environment.getDomElement(this._domElementId);
            if (domElement) {
                domElement.innerHTML += this._kowabungaOnBetPlaced$1;
                if (totalStake >= this._kowabungaMinimalTotalStake$1) {
                    domElement.innerHTML += String.format(this._kowabungaOnBetPlacedConditional$1, totalStake, creditAccountDetails.AccountNumber);
                }
            }
        }
    },
    
    init: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$init(environment, componentInstanceName, domElementId, parameters) {
        BFAffiliateTrackingComponent.BFAffiliateTrackingComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._log.debug('Init');
    },
    
    start: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$start() {
        this._log.debug('Start');
    },
    
    repaint: function BFAffiliateTrackingComponent_BFAffiliateTrackingComponent$repaint() {
        this._log.debug('Repaint');
    }
}


BFAffiliateTrackingComponent.BFAffiliateTrackingComponent.createClass('BFAffiliateTrackingComponent.BFAffiliateTrackingComponent', Framework.AbstractComponent, BFUserService.IUserRegisteredListener, AccountService.IBalanceChangedListener, FixedOddsBettingService.IBetPlacementStateChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('DebugInfoComponent');

////////////////////////////////////////////////////////////////////////////////
// DebugInfoComponent.DebugInfoComponent

DebugInfoComponent.DebugInfoComponent = function DebugInfoComponent_DebugInfoComponent() {
    DebugInfoComponent.DebugInfoComponent.constructBase(this);
}
DebugInfoComponent.DebugInfoComponent.prototype = {
    _parameters: null,
    _textColor$1: null,
    _loadDelaySeconds$1: 0,
    
    init: function DebugInfoComponent_DebugInfoComponent$init(environment, componentInstanceName, domElementId, parameters) {
        DebugInfoComponent.DebugInfoComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters = new Framework.CommonComponentParameters(parameters);
        this._loadDelaySeconds$1 = parameters['load-delay-seconds'];
        this._textColor$1 = parameters['text-color'];
    },
    
    start: function DebugInfoComponent_DebugInfoComponent$start() {
        window.setTimeout(Delegate.create(this, this.repaint), this._loadDelaySeconds$1);
    },
    
    repaint: function DebugInfoComponent_DebugInfoComponent$repaint() {
        this._log.debug('Repaint');
        var placeHolder = document.getElementById(this._domElementId);
        placeHolder.style.color = this._textColor$1;
        this._environment.updateDomElementDirect(placeHolder, this._environment.get_debugInfo());
    }
}


DebugInfoComponent.DebugInfoComponent.createClass('DebugInfoComponent.DebugInfoComponent', Framework.AbstractComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BFSportsHomeComponent');

////////////////////////////////////////////////////////////////////////////////
// BFSportsHomeComponent.BFSportsHomeComponent

BFSportsHomeComponent.BFSportsHomeComponent = function BFSportsHomeComponent_BFSportsHomeComponent() {
    BFSportsHomeComponent.BFSportsHomeComponent.constructBase(this);
}
BFSportsHomeComponent.BFSportsHomeComponent.prototype = {
    _parameters$1: null,
    _navigationService$1: null,
    
    setNavigationService: function BFSportsHomeComponent_BFSportsHomeComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
    },
    
    init: function BFSportsHomeComponent_BFSportsHomeComponent$init(environment, componentInstanceName, domElementId, parameters) {
        BFSportsHomeComponent.BFSportsHomeComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
    },
    
    repaint: function BFSportsHomeComponent_BFSportsHomeComponent$repaint() {
        this._log.debug('Repaint');
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        this._environment.transformAndUpdate(this._domElementId, null, this._parameters$1.get_xsltUrl(), xsltParameters, null);
    },
    
    gotoSportsHome: function BFSportsHomeComponent_BFSportsHomeComponent$gotoSportsHome() {
        this._log.debug('GotoSportsHome');
        this._navigationService$1.goTo('homepage', {});
        return false;
    }
}


BFSportsHomeComponent.BFSportsHomeComponent.createClass('BFSportsHomeComponent.BFSportsHomeComponent', Framework.AbstractComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('QuickLinksComponent');

////////////////////////////////////////////////////////////////////////////////
// QuickLinksComponent.QuickLinksComponent

QuickLinksComponent.QuickLinksComponent = function QuickLinksComponent_QuickLinksComponent() {
    QuickLinksComponent.QuickLinksComponent.constructBase(this);
}
QuickLinksComponent.QuickLinksComponent.prototype = {
    _parameters$1: null,
    _limit$1: null,
    _category$1: null,
    _bettingNavigationService$1: null,
    
    setBettingNavigationService: function QuickLinksComponent_QuickLinksComponent$setBettingNavigationService(bettingNavigationService) {
        this._log.debug('SetBettingNavigationService');
        this._bettingNavigationService$1 = bettingNavigationService;
    },
    
    _navigationService$1: null,
    
    setNavigationService: function QuickLinksComponent_QuickLinksComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketFromEvent);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketFromMarketGroup);
    },
    
    onPageFilterChanged: function QuickLinksComponent_QuickLinksComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this._highlightActiveMarket$1();
    },
    
    init: function QuickLinksComponent_QuickLinksComponent$init(environment, componentInstanceName, domElementId, parameters) {
        QuickLinksComponent.QuickLinksComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._limit$1 = parameters['limit'];
        this._category$1 = parameters['category'];
    },
    
    repaint: function QuickLinksComponent_QuickLinksComponent$repaint() {
        this._log.debug('Repaint');
        var contentUrl = this._parameters$1.get_contentUrl().replace('${limit}', this._limit$1).replace('${category}', this._category$1);
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        this._environment.transformAndUpdate(this._domElementId, contentUrl, this._parameters$1.get_xsltUrl(), xsltParameters, Delegate.create(this, function() {
            this._highlightActiveMarket$1();
        }));
    },
    
    _highlightActiveMarket$1: function QuickLinksComponent_QuickLinksComponent$_highlightActiveMarket$1() {
        var IDFOMarket = null;
        var IDFOMarketFromEvent = this._bettingNavigationService$1.getMarketFromEvent();
        if (!String.isNullOrEmpty(IDFOMarketFromEvent)) {
            IDFOMarket = IDFOMarketFromEvent;
        }
        else {
            var IDFOMarketFromMarketGroup = this._bettingNavigationService$1.getMarketFromMarketGroup();
            if (!String.isNullOrEmpty(IDFOMarketFromMarketGroup)) {
                IDFOMarket = IDFOMarketFromMarketGroup;
            }
        }
        this._highlightActiveMarketRecursive$1(IDFOMarket, this._environment.getDomElement(this._domElementId));
    },
    
    _highlightActiveMarketRecursive$1: function QuickLinksComponent_QuickLinksComponent$_highlightActiveMarketRecursive$1(IDFOMarket, domElement) {
        if (!String.isNullOrEmpty(domElement.id) && domElement.id.indexOf('-link-') >= 0) {
            if (!String.isNullOrEmpty(IDFOMarket) && domElement.id.endsWith(IDFOMarket)) {
                domElement.className += (domElement.className.indexOf('active') < 0) ? ' active' : '';
            }
            else {
                domElement.className = domElement.className.replace('active', '');
            }
        }
        for (var i = 0; i < domElement.childNodes.length; i++) {
            this._highlightActiveMarketRecursive$1(IDFOMarket, domElement.childNodes[i]);
        }
    },
    
    toggle: function QuickLinksComponent_QuickLinksComponent$toggle() {
        this._log.debug('Toggle');
        var domElement = this.getPrivateDomElement('link');
        if (domElement) {
            if (domElement.className.indexOf('expanded') >= 0) {
                domElement.className = domElement.className.replace('expanded', 'collapsed');
            }
            else {
                domElement.className = domElement.className.replace('collapsed', 'expanded');
            }
        }
        return false;
    },
    
    setMarket: function QuickLinksComponent_QuickLinksComponent$setMarket(IDFOMarket) {
        this._log.debug(String.format('SetMarket IDFOMarket=[{0}]', IDFOMarket));
        this._bettingNavigationService$1.setNavigation(null, null, null, null, IDFOMarket, null);
        return false;
    },
    
    setMarketGroup: function QuickLinksComponent_QuickLinksComponent$setMarketGroup(IDFWMarketGroup) {
        this._log.debug(String.format('SetMarketGroup IDFWMarketGroup=[{0}]', IDFWMarketGroup));
        this._bettingNavigationService$1.setNavigation(null, IDFWMarketGroup, null, null, null, null);
        return false;
    }
}


QuickLinksComponent.QuickLinksComponent.createClass('QuickLinksComponent.QuickLinksComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BFTreeNavigationComponent');

// C:\DOC\Build\MM2Workspace\BTI\Warp_from_svn\releases\2.3.46\integrations\nextgen\connecticut\client\BFTreeNavigationComponent
// BFTreeNavigationComponent.BFTreeNavigationComponent

BFTreeNavigationComponent.BFTreeNavigationComponent = function BFTreeNavigationComponent_BFTreeNavigationComponent() {
    this._mkDisplayLimit = -1;
    BFTreeNavigationComponent.BFTreeNavigationComponent.constructBase(this);
}
BFTreeNavigationComponent.BFTreeNavigationComponent.prototype = {
    _autoRefreshPeriod: 10000,
    _parameters$1: null,
    _bettingNavigationService$1: null,
    
    setBettingNavigationService: function BFTreeNavigationComponent_BFTreeNavigationComponent$setBettingNavigationService(bettingNavigationService) {
        this._log.debug('SetBettingNavigationService');
        this._bettingNavigationService$1 = bettingNavigationService;
    },
    
    _navigationService$1: null,
    
    setNavigationService: function BFTreeNavigationComponent_BFTreeNavigationComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.boNavigation);
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.marketGroup);
    },
    
    onPageFilterChanged: function BFTreeNavigationComponent_BFTreeNavigationComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this.repaint();
    },
    
    init: function BFTreeNavigationComponent_BFTreeNavigationComponent$init(environment, componentInstanceName, domElementId, parameters) {
        BFTreeNavigationComponent.BFTreeNavigationComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._autoRefreshPeriod = Number.parse(parameters['auto-refresh-period']);
        this._mkDisplayLimit = Number.parse(parameters['mk-display-limit']);
    },
    
    _getXsltParameters$1: function BFTreeNavigationComponent_BFTreeNavigationComponent$_getXsltParameters$1(BONavigationContext) {
        var result = {};
        result['component-instance-name'] = this._componentInstanceName;
        result['component-dom-element-id'] = this._domElementId;
        result['level'] = BONavigationContext.length;
        var context = '[';
        for (var i = 0; i < BONavigationContext.length; i++) {
            context += String.format('\'{0}\'{1}', BONavigationContext[i], (i < BONavigationContext.length - 1) ? ', ' : '');
        }
        context += ']';
        result['bo-navigation-context'] = context;
        result['mk-display-limit'] = this._mkDisplayLimit;
        if (BONavigationContext.length > 0) {
            if (BONavigationContext.length === 1) {
                var oManuRootElement = $(this._domElementId + '-link-' + BONavigationContext[0]);
                if (oManuRootElement) {
                    result['bo-group-name'] = oManuRootElement.getElementsByTagName('a')[0].innerText;
                }
            }
            if (BONavigationContext.length === 2) {
                var oManuRootElement = $(this._domElementId + '-link-' + BONavigationContext[0]);
                if (oManuRootElement) {
                    result['bo-group-name'] = oManuRootElement.getElementsByTagName('a')[0].innerText;
                }
                var oManuRootSubElement = $(this._domElementId + '-link-' + BONavigationContext[1]);
                if (oManuRootSubElement) {
                    result['bo-group-subitem-name'] = oManuRootSubElement.getElementsByTagName('a')[0].innerText;
                }
            }
        }
        return result;
    },
    
    _repaintLevel$1: function BFTreeNavigationComponent_BFTreeNavigationComponent$_repaintLevel$1(currentBONavigation, IDFWMarketGroup, level) {
        if (level >= Math.min(2, currentBONavigation.length)) {
            this._adjust$1(currentBONavigation, IDFWMarketGroup, this._environment.getDomElement(this._domElementId), 0);
            return;
        }
        var domElement = this.getPrivateDomElement('link-' + currentBONavigation[level]);
        if (domElement.className.indexOf(BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1) >= 0) {
            this._repaintLevel$1(currentBONavigation, IDFWMarketGroup, level + 1);
        }
        else if (domElement.className.indexOf(BFTreeNavigationComponent.BFTreeNavigationComponent._collapsed$1) >= 0) {
            domElement.className = domElement.className.replace(BFTreeNavigationComponent.BFTreeNavigationComponent._collapsed$1, BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1);
            this._repaintLevel$1(currentBONavigation, IDFWMarketGroup, level + 1);
        }
        else {
            var contentId = this._parameters$1.get_contentUrl().replace('${idfwbonavigation}', currentBONavigation[level]);
            var BONavigationContext = currentBONavigation.extract(0, level + 1);
            domElement.className += ' ' + BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1;
            this._environment.transformAndUpdate(this._domElementId + '-child-' + currentBONavigation[level], contentId, this._parameters$1.get_xsltUrl(), this._getXsltParameters$1(BONavigationContext), Delegate.create(this, function() {
                this._repaintLevel$1(currentBONavigation, IDFWMarketGroup, level + 1);
            }));
        }
    },
    
    _adjust$1: function BFTreeNavigationComponent_BFTreeNavigationComponent$_adjust$1(BONavigationContext, IDFWMarketGroup, domElement, depth) {
        if (!String.isNullOrEmpty(domElement.id)) {
            if (domElement.id.indexOf('-link-') >= 0) {
                if (depth === 2) {
                    if (BONavigationContext.length === depth + 1 && domElement.id.endsWith('-' + BONavigationContext[2])) {
                        domElement.className += (domElement.className.indexOf('active') < 0) ? ' active' : '';
                    }
                    else {
                        domElement.className = domElement.className.replace('active', '');
                    }
                }
                else {
                    if (depth >= BONavigationContext.length || !domElement.id.endsWith('-' + BONavigationContext[depth])) {
                        if (domElement.className.indexOf(BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1) >= 0) {
                            domElement.className = domElement.className.replace(BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1, BFTreeNavigationComponent.BFTreeNavigationComponent._collapsed$1);
                        }
                    }
                    else if (depth < BONavigationContext.length && domElement.id.endsWith('-' + BONavigationContext[depth])) {
                        if (domElement.className.indexOf(BFTreeNavigationComponent.BFTreeNavigationComponent._collapsed$1) >= 0) {
                            domElement.className = domElement.className.replace(BFTreeNavigationComponent.BFTreeNavigationComponent._collapsed$1, BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1);
                        }
                        else if (domElement.className.indexOf(BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1) < 0) {
                            domElement.className += ' ' + BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1;
                        }
                    }
                }
                depth++;
            }
            else if (domElement.id.indexOf('-mg-') >= 0) {
                if (!String.isNullOrEmpty(IDFWMarketGroup) && domElement.id.endsWith(IDFWMarketGroup)) {
                    domElement.className += (domElement.className.indexOf('active') < 0) ? ' active' : '';
                }
                else {
                    domElement.className = domElement.className.replace('active', '');
                }
            }
        }
        for (var i = 0; i < domElement.childNodes.length; i++) {
            this._adjust$1(BONavigationContext, IDFWMarketGroup, domElement.childNodes[i], depth);
        }
    },
    
    repaint: function BFTreeNavigationComponent_BFTreeNavigationComponent$repaint() {
        this._log.debug('Repaint');
        var currentBONavigation = this._bettingNavigationService$1.getBONavigation();
        var IDFWMarketGroup = this._bettingNavigationService$1.getMarketGroup();
        var contentUrl = this._parameters$1.get_contentUrl().replace('${idfwbonavigation}', 'top');
        if (!this._environment.getDomElement(this._domElementId).childNodes.length) {
            if (!this._autoRefreshPeriod) {
                this._environment.transformAndUpdate(this._domElementId, contentUrl, this._parameters$1.get_xsltUrl(), this._getXsltParameters$1([]), Delegate.create(this, function() {
                    this._repaintLevel$1(currentBONavigation, IDFWMarketGroup, 0);
                }));
            }
            else {
                this._environment.clearPeriodicalTransformAndUpdate(this._domElementId);
                this._environment.periodicalTransformAndUpdate(this._domElementId, contentUrl, this._parameters$1.get_xsltUrl(), this._getXsltParameters$1([]), Delegate.create(this, function() {
                    var idFWMarketGroup = this._bettingNavigationService$1.getMarketGroup();
                    if (this._lastToggle$1) {
                        var bONavigationContext = this._lastToggle$1['BONavigationContext'];
                        var idFWBONavigation = this._lastToggle$1['IDFWBONavigation'];
                        if (bONavigationContext[bONavigationContext.length - 1] !== idFWBONavigation) {
                            bONavigationContext[bONavigationContext.length] = idFWBONavigation;
                        }
                        this._repaintLevel$1(bONavigationContext, idFWMarketGroup, 0);
                    }
                    else {
                        this._repaintLevel$1(currentBONavigation, idFWMarketGroup, 0);
                    }
                }), this._domElementId, this._autoRefreshPeriod);
            }
        }
        else {
            this._lastToggle$1 = { BONavigationContext: currentBONavigation, IDFWBONavigation: currentBONavigation[currentBONavigation.length - 1] };
            this._repaintLevel$1(currentBONavigation, IDFWMarketGroup, 0);
        }
    },
    
    _lastToggle$1: null,
    
    toggle: function BFTreeNavigationComponent_BFTreeNavigationComponent$toggle(BONavigationContext, IDFWBONavigation, callback) {
        this._log.debug(String.format('Toggle BONavigationContext=[{0}] IDFWBONavigation=[{1}]', BONavigationContext, IDFWBONavigation));
        this._lastToggle$1 = { BONavigationContext: BONavigationContext, IDFWBONavigation: IDFWBONavigation };
        var callbackCalled = false;
        if (BONavigationContext.length === 2) {
            var newBONavigation = [];
            newBONavigation.addRange(BONavigationContext);
            newBONavigation.add(IDFWBONavigation);
            this._bettingNavigationService$1.setBONavigationLevels(newBONavigation);
        }
        else {
            var domElement = this.getPrivateDomElement('link-' + IDFWBONavigation);
            var expandedBONavigation = [];
            expandedBONavigation.addRange(BONavigationContext);
            if (domElement.className.indexOf(BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1) < 0) {
                expandedBONavigation.add(IDFWBONavigation);
                if (domElement.className.indexOf(BFTreeNavigationComponent.BFTreeNavigationComponent._collapsed$1) < 0) {
                    var contentUrl = this._parameters$1.get_contentUrl().replace('${idfwbonavigation}', IDFWBONavigation);
                    callbackCalled = true;
                    this._environment.transformAndUpdate(String.format('{0}-child-{1}', this._domElementId, IDFWBONavigation), contentUrl, this._parameters$1.get_xsltUrl(), this._getXsltParameters$1(expandedBONavigation), callback);
                }
            }
            var IDFWMarketGroup = this._bettingNavigationService$1.getMarketGroup();
            this._adjust$1(expandedBONavigation, IDFWMarketGroup, this._environment.getDomElement(this._domElementId), 0);
            if (!callbackCalled && callback) {
                callback.invoke();
            }
        }
    },
    
    setMarketGroup: function BFTreeNavigationComponent_BFTreeNavigationComponent$setMarketGroup(BONavigationContext, IDFWMarketGroup) {
        this._log.debug(String.format('SetMarketGroup BONavigationContext=[{0}] IDFWMarketGroup=[{1}]', BONavigationContext, IDFWMarketGroup));
        this._bettingNavigationService$1.setNavigation(BONavigationContext, IDFWMarketGroup, null, null, null, null);
        window.scrollTo(0, 0);
    }
}


BFTreeNavigationComponent.BFTreeNavigationComponent.createClass('BFTreeNavigationComponent.BFTreeNavigationComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener);
BFTreeNavigationComponent.BFTreeNavigationComponent._expanded$1 = 'expanded';
BFTreeNavigationComponent.BFTreeNavigationComponent._collapsed$1 = 'collapsed';

// ---- Do not remove this footer ----
// Generated using Script# v0.5.0.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'];
    },
    
    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, null);
    },
    
    setOddsType: function OddsTypeSelectorComponent_OddsTypeSelectorComponent$setOddsType(oddsType) {
        this._log.debug('SetOddsType oddsType = [' + oddsType + ']');
        this._userOddsFormat$1 = oddsType;
        this._fixedOddsBettingService$1.setOddsType(oddsType);
    }
}


OddsTypeSelectorComponent.OddsTypeSelectorComponent.createClass('OddsTypeSelectorComponent.OddsTypeSelectorComponent', Framework.AbstractComponent, FixedOddsBettingService.IOddsTypeChangedListener, UserService.IUserChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BFServicesComponent');

// C:\DOC\Build\MM2Workspace\BTI\Warp_from_svn\releases\2.3.46\integrations\betfred\connecticut\client\BFServicesComponent
// BFServicesComponent.BFServicesComponent

BFServicesComponent.BFServicesComponent = function BFServicesComponent_BFServicesComponent() {
    BFServicesComponent.BFServicesComponent.constructBase(this);
}
BFServicesComponent.BFServicesComponent.prototype = {
    _parameters$1: null,
    _boNavigationListURL$1: '',
    _currentBONavigationNode$1: 0,
    _userService: null,
    
    setUserService: function BFServicesComponent_BFServicesComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService = userService;
    },
    
    _navigationService$1: null,
    
    setNavigationService: function BFServicesComponent_BFServicesComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerPageFilterChangedListener(this);
    },
    
    onPageFilterChanged: function BFServicesComponent_BFServicesComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this.repaint();
    },
    
    init: function BFServicesComponent_BFServicesComponent$init(environment, componentInstanceName, domElementId, parameters) {
        BFServicesComponent.BFServicesComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._boNavigationListURL$1 = parameters['bonavigationlist-url'];
    },
    
    repaint: function BFServicesComponent_BFServicesComponent$repaint() {
        this._log.debug('Repaint');
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        var isVirtualOpener = (this._parameters$1.get_xsltUrl().toString().toLowerCase().indexOf('virtual-opener') !== -1);
        if (isVirtualOpener) {
            this.hide();
        }
        var _fullHostURL = window.location.protocol + '//' + window.location.hostname;
        if (window.location.port.toString() !== '') {
            _fullHostURL += ':' + window.location.port.toString();
        }
        _fullHostURL += '/';
        xsltParameters['bonavigationlist-url'] = _fullHostURL + this._boNavigationListURL$1.replace('${region}', this._environment.getRegion()).replace('${language}', this._environment.getLanguage());
        var myPageFilter = this._navigationService$1.getPageFilter();
        if (Object.keyExists(myPageFilter, 'bo-navigation')) {
            this._currentBONavigationNode$1 = Number.parse(myPageFilter['bo-navigation']);
        }
        else {
            this._currentBONavigationNode$1 = 0;
        }
        xsltParameters['current-bonavigationnode'] = this._currentBONavigationNode$1;
        if (isVirtualOpener && this._currentBONavigationNode$1) {
            this.show();
        }
        this._environment.transformAndUpdate(this._domElementId, null, this._parameters$1.get_xsltUrl(), xsltParameters, null);
    },
    
    _processNode$1: function BFServicesComponent_BFServicesComponent$_processNode$1(domElement, context) {
        var prefix = this._domElementId + '-service-';
        var children = domElement.childNodes;
        for (var i = 0; i < children.length; i++) {
            var current = children[i];
            if (!String.isNullOrEmpty(current.id)) {
                var id = (current.id.startsWith(prefix)) ? current.id.substr(prefix.length) : null;
                if (current.className.indexOf('collapsed') >= 0 && context.contains(id)) {
                    current.className = current.className.replace('collapsed', 'expanded');
                }
                else if (current.className.indexOf('expanded') >= 0 && !context.contains(id)) {
                    current.className = current.className.replace('expanded', 'collapsed');
                }
            }
            this._processNode$1(current, context);
        }
    },
    
    toggle: function BFServicesComponent_BFServicesComponent$toggle(context, isAction) {
        this._log.debug('Toggle');
        this._processNode$1($(this._domElementId), context);
        if (isAction) {
            var pageFilter = this._navigationService$1.getPageFilter();
            pageFilter[NavigationService.NavigationService.action] = 'include';
            var page = 'services';
            for (var i = 0; i < context.length; i++) {
                page += '/' + context[i];
            }
            pageFilter[NavigationService.NavigationService.page] = page;
            this._navigationService$1.goTo(this._navigationService$1.getPageArea(), pageFilter);
        }
        return false;
    },
    
    openStream: function BFServicesComponent_BFServicesComponent$openStream(virtualSport, area) {
        this._log.debug('OpenStream ' + virtualSport);
        if (this._userService.isLoggedIn()) {
            var pageFilter = this._navigationService$1.getPageFilter();
            pageFilter[NavigationService.NavigationService.action] = virtualSport.toLowerCase();
            window.open(this._environment.buildUrl(area.toLowerCase(), pageFilter, this._environment.getProtocol()), 'BFWRPvirtualstream', 'toolbar=no,status=no,width=320,height=240,scrollbars=no,menubar=no,resizable=no');
        }
        else {
            alert('Please login first - virtual streams can only be viewed once you have logged in.');
        }
        return false;
    },
    
    loadHeadline: function BFServicesComponent_BFServicesComponent$loadHeadline(virtualSport) {
        this._log.debug('LoadHeadline ' + virtualSport);
        var xsltParameters = {};
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        xsltParameters['headline-images-base-url'] = '/common/images/headline';
        xsltParameters['category'] = virtualSport.toUpperCase();
        xsltParameters['limit'] = 1;
        xsltParameters['css-class'] = 'virtualheadline vh' + virtualSport.toLowerCase();
        xsltParameters['show-title'] = 'false';
        xsltParameters['show-text'] = 'false';
        var xsltUrl = 'components/HeadlineComponent/headline-virtual.xslt';
        var contentUrl = '/cache/headline/${region}/${language}/${limit}/${category}.xml'.replace('${region}', this._environment.getRegion()).replace('${language}', this._environment.getLanguage()).replace('${limit}', '1').replace('${category}', virtualSport.toUpperCase());
        this._environment.transformAndUpdate(this._domElementId + '-headline', contentUrl, xsltUrl, xsltParameters, null);
    }
}


BFServicesComponent.BFServicesComponent.createClass('BFServicesComponent.BFServicesComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('GamesFrameComponent');

////////////////////////////////////////////////////////////////////////////////
// GamesFrameComponent.GamesFrameComponent

GamesFrameComponent.GamesFrameComponent = function GamesFrameComponent_GamesFrameComponent() {
    GamesFrameComponent.GamesFrameComponent.constructBase(this);
}
GamesFrameComponent.GamesFrameComponent.prototype = {
    _parameters$1: null,
    _repaintOnPageFilterChanged$1: false,
    _frameSection$1: null,
    _width$1: null,
    _height$1: null,
    _scrolling$1: null,
    _frameborder$1: null,
    _repaintOnUserChanged$1: false,
    _navigationService$1: null,
    
    setNavigationService: function GamesFrameComponent_GamesFrameComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
    },
    
    _accountService$1: null,
    
    setAccountService: function GamesFrameComponent_GamesFrameComponent$setAccountService(accountService) {
        this._log.debug('SetAccountService');
        this._accountService$1 = accountService;
    },
    
    _gamesHostService$1: null,
    
    setGamesHostService: function GamesFrameComponent_GamesFrameComponent$setGamesHostService(gamesHostService) {
        this._log.debug('SetGamesHostService');
        this._gamesHostService$1 = gamesHostService;
    },
    
    _businessUnitService$1: null,
    
    setBusinessUnitService: function GamesFrameComponent_GamesFrameComponent$setBusinessUnitService(businessUnitService) {
        this._log.debug('SetBusinessUnitService');
        this._businessUnitService$1 = businessUnitService;
    },
    
    _userService$1: null,
    
    setUserService: function GamesFrameComponent_GamesFrameComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$1 = userService;
    },
    
    onUserChanged: function GamesFrameComponent_GamesFrameComponent$onUserChanged(eventSource) {
        this._log.debug('OnUserChanged');
        if (this._repaintOnUserChanged$1) {
            if (this._userService$1 && this._gamesHostService$1) {
                if (this._userService$1.isLoggedIn()) {
                    if (!this._gamesHostService$1.isLoggedIn()) {
                        this._gamesHostService$1.login(Delegate.create(this, this._loginSuccess$1), Delegate.create(this, this._loginFailure$1));
                    }
                }
                else {
                    if (this._gamesHostService$1.isLoggedIn()) {
                        this._gamesHostService$1.logout(Delegate.create(this, this._logoutSuccess$1), Delegate.create(this, this._logoutFailure$1));
                    }
                }
            }
        }
    },
    
    _logoutSuccess$1: function GamesFrameComponent_GamesFrameComponent$_logoutSuccess$1(result) {
        this._log.debug('logoutSuccess');
        this.repaint();
    },
    
    _logoutFailure$1: function GamesFrameComponent_GamesFrameComponent$_logoutFailure$1(e) {
        this._log.debug('logoutFailure: ' + e.message);
    },
    
    _loginSuccess$1: function GamesFrameComponent_GamesFrameComponent$_loginSuccess$1(result) {
        this._log.debug('loginSuccess');
        this.repaint();
    },
    
    _loginFailure$1: function GamesFrameComponent_GamesFrameComponent$_loginFailure$1(e) {
        this._log.debug('loginFailure: ' + e.message);
    },
    
    onPageFilterChanged: function GamesFrameComponent_GamesFrameComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        if (this._repaintOnPageFilterChanged$1) {
            this.repaint();
        }
    },
    
    init: function GamesFrameComponent_GamesFrameComponent$init(environment, componentInstanceName, domElementId, parameters) {
        GamesFrameComponent.GamesFrameComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._repaintOnPageFilterChanged$1 = Boolean.parse(parameters['repaint-onpagefilterchanged']);
        this._frameSection$1 = parameters['frame-section'];
        this._width$1 = parameters['width'];
        this._height$1 = parameters['height'];
        this._scrolling$1 = parameters['scrolling'];
        this._frameborder$1 = parameters['frameborder'];
        this._repaintOnUserChanged$1 = Boolean.parse(parameters['repaint-onuserchanged']);
    },
    
    repaint: function GamesFrameComponent_GamesFrameComponent$repaint() {
        this._log.debug('Repaint');
        if (this.isVisible(this._parameters$1.get_visibleOn(), this._parameters$1.get_notVisibleOn(), this._navigationService$1.getAction())) {
            this._repaintInner$1(Delegate.create(this, function() {
                var elements = Framework.DocumentFinder.getElementsBySelector('input.games-document-domain');
                if (elements && elements.length > 0) {
                    var evalString = String.format('document.domain = \'{0}\';', (elements[0]).value);
                    eval(evalString);
                }
                this.show();
            }));
        }
        else {
            this.hide();
        }
    },
    
    repaintForAdmin: function GamesFrameComponent_GamesFrameComponent$repaintForAdmin() {
        this._repaintInner$1(null);
        GamesFrameComponent.GamesFrameComponent.callBase(this, 'disableForAdmin');
    },
    
    refreshBalance: function GamesFrameComponent_GamesFrameComponent$refreshBalance() {
        if (this._userService$1.isLoggedIn()) {
            this._accountService$1.fetchAccountsDetails();
        }
    },
    
    _repaintInner$1: function GamesFrameComponent_GamesFrameComponent$_repaintInner$1(callback) {
        var sessionid = '';
        if (this._gamesHostService$1.isLoggedIn()) {
            sessionid = this._gamesHostService$1.get_gamesSessionID();
        }
        if (!this._businessUnitService$1.getBusinessUnitId()) {
            this._businessUnitService$1.getBusinessUnitIdAsync(Delegate.create(this, function(result) {
                this.getBusinessUnitCallback(result, callback, sessionid);
            }), Delegate.create(this, function(ex) {
                alert('Unable to retrieve business unit');
            }));
        }
        else {
            this.getBusinessUnitCallback(this._businessUnitService$1.getBusinessUnitId(), callback, sessionid);
        }
    },
    
    getBusinessUnitCallback: function GamesFrameComponent_GamesFrameComponent$getBusinessUnitCallback(businessUnit, callback, sessionid) {
        var xsltParameters = {};
        var sessid = '';
        if (this._gamesHostService$1.isLoggedIn()) {
            sessid = this._gamesHostService$1.get_gamesSessionID();
        }
        xsltParameters['component-instance-name'] = this._componentInstanceName;
        xsltParameters['component-dom-element-id'] = this._domElementId;
        xsltParameters['frame-section'] = this._frameSection$1;
        xsltParameters['language'] = this._environment.getLanguage();
        xsltParameters['region'] = this._environment.getRegion();
        xsltParameters['width'] = this._width$1;
        xsltParameters['height'] = this._height$1;
        xsltParameters['scrolling'] = this._scrolling$1;
        xsltParameters['frameborder'] = this._frameborder$1;
        xsltParameters['sessionid'] = sessid;
        var contentUrl = this._parameters$1.get_contentUrl().replace('${framename}', this._frameSection$1).replace('${idmmbusinessunit}', businessUnit);
        this._environment.transformAndUpdate(this._domElementId, contentUrl, this._parameters$1.get_xsltUrl(), xsltParameters, callback);
    }
}


GamesFrameComponent.GamesFrameComponent.createClass('GamesFrameComponent.GamesFrameComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener, UserService.IUserChangedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
