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('SlideshowHeadlineComponent');

////////////////////////////////////////////////////////////////////////////////
// SlideshowHeadlineComponent.SlideshowHeadlineComponent

SlideshowHeadlineComponent.SlideshowHeadlineComponent = function SlideshowHeadlineComponent_SlideshowHeadlineComponent() {
    this._currentTimeout$1 = -1;
    SlideshowHeadlineComponent.SlideshowHeadlineComponent.constructBase(this);
}
SlideshowHeadlineComponent.SlideshowHeadlineComponent.prototype = {
    _parameters$1: null,
    _headlineImagesBaseUrl$1: null,
    _limit$1: null,
    _category$1: null,
    _cssclassHeight$1: null,
    _autoRefreshPeriod$1: null,
    _currentFrame$1: null,
    _IsInRunningState$1: true,
    _navigationService$1: null,
    
    setNavigationService: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$1 = navigationService;
        this._navigationService$1.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.action);
    },
    
    onPageFilterChanged: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        this.repaint();
    },
    
    init: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$init(environment, componentInstanceName, domElementId, parameters) {
        SlideshowHeadlineComponent.SlideshowHeadlineComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters$1 = new Framework.CommonComponentParameters(parameters);
        this._headlineImagesBaseUrl$1 = parameters['headline-images-base-url'];
        this._limit$1 = parameters['limit'];
        this._category$1 = parameters['category'];
        this._cssclassHeight$1 = parameters['cssclass-height'];
        this._autoRefreshPeriod$1 = Number.parse(parameters['auto-refresh-period']) || 2000;
        this._IsInRunningState$1 = true;
        this._currentFrame$1 = -1;
    },
    
    repaint: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$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('${limit}', this._limit$1).replace('${category}', this._category$1).replace('${cssclass-height}', this._cssclassHeight$1);
            var xsltParameters = {};
            xsltParameters['component-instance-name'] = this._componentInstanceName;
            xsltParameters['component-dom-element-id'] = this._domElementId;
            xsltParameters['headline-images-base-url'] = this._headlineImagesBaseUrl$1;
            xsltParameters['cssclass-height'] = this._cssclassHeight$1;
            this._environment.transformAndUpdate(this._domElementId, contentUrl, this._parameters$1.get_xsltUrl(), xsltParameters, null);
        }
        else {
            this.hide();
        }
    },
    
    moveForward: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$moveForward(headlines) {
        this._pauseSlideshow$1();
        this._calculateNextFrame$1(headlines);
        this._renderUI$1(headlines, this._currentFrame$1);
    },
    
    moveBackward: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$moveBackward(headlines, active) {
        this._pauseSlideshow$1();
        this._calculatePreviousFrame$1(headlines);
        this._renderUI$1(headlines, this._currentFrame$1);
    },
    
    runSlideShow: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$runSlideShow(headlines, action) {
        this._clearTimeout$1();
        if (action === SlideshowHeadlineComponent.SlideshowHeadlineComponent._pausE_OR_RESUME_ACTION$1) {
            this._currentFrame$1--;
            this._IsInRunningState$1 = !this._IsInRunningState$1;
        }
        this._calculateNextFrame$1(headlines);
        this._renderUI$1(headlines, this._currentFrame$1);
        if (this._IsInRunningState$1) {
            this._currentTimeout$1 = window.setTimeout(Delegate.create(this, function() {
                this.runSlideShow(headlines, '');
            }), this._autoRefreshPeriod$1);
        }
    },
    
    runFromSpecifiedFrame: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$runFromSpecifiedFrame(headlines, specframe) {
        this._clearTimeout$1();
        this._currentFrame$1 = specframe - 2;
        this._calculateNextFrame$1(headlines);
        this._renderUI$1(headlines, this._currentFrame$1);
        if (this._IsInRunningState$1) {
            this._currentTimeout$1 = window.setTimeout(Delegate.create(this, function() {
                this.runSlideShow(headlines, '');
            }), this._autoRefreshPeriod$1);
        }
    },
    
    _calculatePreviousFrame$1: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$_calculatePreviousFrame$1(headlines) {
        this._currentFrame$1--;
        if (this._currentFrame$1 < 0) {
            this._currentFrame$1 = headlines - 1;
        }
    },
    
    _calculateNextFrame$1: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$_calculateNextFrame$1(headlines) {
        this._currentFrame$1++;
        if (this._currentFrame$1 >= headlines) {
            this._currentFrame$1 = 0;
        }
    },
    
    _renderUI$1: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$_renderUI$1(headlines, active) {
        if (this._IsInRunningState$1) {
            document.getElementById(this._domElementId + '-pause').className = 'pausedisabled';
        }
        else {
            document.getElementById(this._domElementId + '-pause').className = 'pause';
        }
        for (var i = 0; i < headlines; i++) {
            this.getPrivateDomElement(i.toString()).style.display = ((i === active) ? 'block' : 'none');
            document.getElementById(this._domElementId + '-si-' + i.toString()).className = ((i === active) ? 'cur' : '');
        }
    },
    
    _pauseSlideshow$1: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$_pauseSlideshow$1() {
        this._IsInRunningState$1 = false;
        this._clearTimeout$1();
    },
    
    _clearTimeout$1: function SlideshowHeadlineComponent_SlideshowHeadlineComponent$_clearTimeout$1() {
        if (this._currentTimeout$1 !== -1) {
            window.clearTimeout(this._currentTimeout$1);
        }
    }
}


SlideshowHeadlineComponent.SlideshowHeadlineComponent.createClass('SlideshowHeadlineComponent.SlideshowHeadlineComponent', Framework.AbstractComponent, NavigationService.IPageFilterChangedListener);
SlideshowHeadlineComponent.SlideshowHeadlineComponent._runninG_STATE$1 = 'RUNNING';
SlideshowHeadlineComponent.SlideshowHeadlineComponent._pausE_STATE$1 = 'PAUSE';
SlideshowHeadlineComponent.SlideshowHeadlineComponent._pausE_OR_RESUME_ACTION$1 = 'PAUSE_OR_RESUME';

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('BoolabusFlashHostComponent');

////////////////////////////////////////////////////////////////////////////////
// BoolabusFlashHostComponent.boolabusAddSelection

BoolabusFlashHostComponent.boolabusAddSelection = function BoolabusFlashHostComponent_boolabusAddSelection(selectionstring) {
    this.eachWayReduction = new Array(0);
    this.eachWayPlaceTerms = new Array(0);
    var selectionParams = selectionstring.split('$');
    this.idfoPriceType = selectionParams[0].split(',');
    this.activePriceTypes = selectionParams[1];
    this.idfoEvent = Number.parse(selectionParams[2]);
    this.eventName = selectionParams[3];
    this.idfoMarket = Number.parse(selectionParams[4]);
    this.marketName = selectionParams[5];
    this.mTag = selectionParams[6];
    this.tTagLeft = selectionParams[7];
    this.tTagRight = selectionParams[8];
    this.cTag = selectionParams[9];
    this.isTrapBettingOptionOn = Boolean.parse(selectionParams[10]);
    this.hadValue = selectionParams[11];
    this.handicap = selectionParams[12];
    this.upperBand = (selectionParams[13] === 'null') ? '' : selectionParams[13];
    this.lowerBand = selectionParams[14];
    if (selectionParams[15].length > 0) {
        var Reductions = selectionParams[15].split(',');
        this.eachWayReduction = new Array(Reductions.length - 1);
        var i = 0;
        var $enum1 = Reductions.getEnumerator();
        while ($enum1.moveNext()) {
            var reduction = $enum1.get_current();
            this.eachWayReduction[i] = Number.parse(reduction);
            i++;
        }
    }
    if (selectionParams[16].length > 0) {
        var PlaceTerms = selectionParams[16].split(',');
        this.eachWayPlaceTerms = new Array(PlaceTerms.length - 1);
        var i = 0;
        var $enum2 = PlaceTerms.getEnumerator();
        while ($enum2.moveNext()) {
            var term = $enum2.get_current();
            this.eachWayPlaceTerms[i] = Number.parse(term);
            i++;
        }
    }
    this.idfoSelection = Number.parse(selectionParams[17]);
    this.selectionName = selectionParams[18];
    this.priceUp = Number.parse(selectionParams[19]);
    this.priceDown = Number.parse(selectionParams[20]);
    this.activeBetTypes = selectionParams[21];
    this.fixedOddsPriceTypes = selectionParams[22].split(',');
    this.selectionHashCode = Number.parse(selectionParams[23]);
    this.isTradable = Boolean.parse(selectionParams[24]);
}
BoolabusFlashHostComponent.boolabusAddSelection.prototype = {
    idfoPriceType: null,
    activePriceTypes: null,
    idfoEvent: null,
    eventName: null,
    idfoMarket: null,
    marketName: null,
    mTag: null,
    tTagLeft: null,
    tTagRight: null,
    cTag: null,
    isTrapBettingOptionOn: false,
    hadValue: null,
    handicap: null,
    upperBand: null,
    lowerBand: null,
    idfoSelection: null,
    selectionName: null,
    priceUp: null,
    priceDown: null,
    activeBetTypes: null,
    fixedOddsPriceTypes: null,
    selectionHashCode: null,
    isTradable: false
}


////////////////////////////////////////////////////////////////////////////////
// BoolabusFlashHostComponent.BoolabusFlashHostComponent

BoolabusFlashHostComponent.BoolabusFlashHostComponent = function BoolabusFlashHostComponent_BoolabusFlashHostComponent() {
    BoolabusFlashHostComponent.BoolabusFlashHostComponent.constructBase(this);
}
BoolabusFlashHostComponent.BoolabusFlashHostComponent.prototype = {
    _xsltUrl$2: null,
    _boolabusFlashURL$2: null,
    _expressInstallFlashURL$2: null,
    _flashDivID$2: null,
    _language$2: null,
    _region$2: null,
    _width$2: null,
    _height$2: null,
    _diableRetainSelectionsInBetSlip$2: false,
    _navigationService$2: null,
    
    setNavigationService: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$2 = navigationService;
    },
    
    onPageFilterChanged: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
    },
    
    _accountService$2: null,
    
    setAccountService: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$setAccountService(accountService) {
        this._log.debug('SetAccountService');
        this._accountService$2 = accountService;
    },
    
    _userService$2: null,
    
    setUserService: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$setUserService(userService) {
        this._log.debug('SetUserService');
        this._userService$2 = userService;
    },
    
    onUserChanged: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$onUserChanged(eventSource) {
        this._log.debug('OnUserChanged');
        this._raiseUserChanged$2();
    },
    
    _betSlipService: null,
    
    setBetSlipService: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$setBetSlipService(betSlipService) {
        this._log.debug('SetBetSlipService');
        this._betSlipService = betSlipService;
    },
    
    _fixedOddsBettingService: null,
    
    setFixedOddsBettingService: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$setFixedOddsBettingService(fixedOddsBettingService) {
        this._log.debug('SetFixedOddsBettingService');
        this._fixedOddsBettingService = fixedOddsBettingService;
    },
    
    onSelectionsAdded: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$onSelectionsAdded(eventSource, selection) {
        this._log.debug('OnSelectionsAdded');
        this._raiseBetSlipChanged$2();
    },
    
    onSelectionsRemoved: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$onSelectionsRemoved(eventSource, selection) {
        this._log.debug('OnSelectionsRemoved');
        this._raiseBetSlipChanged$2();
    },
    
    init: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$init(environment, componentInstanceName, domElementId, parameters) {
        this._parameters = new Framework.CommonComponentParameters(parameters);
        this._xsltUrl$2 = parameters['xslt-url'];
        this._boolabusFlashURL$2 = parameters['boolabus-flash-url'];
        this._expressInstallFlashURL$2 = parameters['expressinstall-flash-url'];
        this._flashDivID$2 = parameters['flash-div-id'];
        this._language$2 = parameters['language'];
        this._region$2 = parameters['region'];
        this._width$2 = parameters['flash-width'];
        this._height$2 = parameters['flash-height'];
        this._diableRetainSelectionsInBetSlip$2 = parameters['disable-retain-in-betslip'];
        this._setSize$2(parameters['component-height']);
    },
    
    getXsltParameters: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$getXsltParameters(contextObject) {
        var result = {};
        result['component-instance-name'] = this._componentInstanceName;
        result['component-dom-element-id'] = this._domElementId;
        result['boolabus-flash-url'] = this._boolabusFlashURL$2;
        result['expressinstall-flash-url'] = this._expressInstallFlashURL$2;
        result['div-ID'] = this._flashDivID$2;
        result['username'] = this._userService$2.get_username();
        result['language'] = this._language$2;
        result['region'] = this._region$2;
        result['betslipsize'] = this._betSlipService.getSelectionsCount();
        result['oddstype'] = this._getOddsTypeKey$2();
        result['width'] = this._width$2;
        result['height'] = this._height$2;
        return result;
    },
    
    keepUserLoggedIn: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$keepUserLoggedIn() {
        this._userService$2.getPersonalDetails(Delegate.create(this, function() {
        }), Delegate.create(this, function() {
        }));
        eval('setTimeout(\"' + this._componentInstanceName + '.keepUserLoggedIn()\",30000);');
    },
    
    get_isComponentVisible: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$get_isComponentVisible() {
        return this.isVisible(this._parameters.get_visibleOn(), this._parameters.get_notVisibleOn(), this._navigationService$2.getAction());
    },
    
    renderComplete: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$renderComplete(eventArgs) {
        var swfobjectcode = this.getPrivateDomElement('swfobjectcode').innerHTML;
        eval(swfobjectcode);
        this.getPrivateDomElement(this._flashDivID$2).style.visibility = 'visible';
        eval(this._componentInstanceName + '.keepUserLoggedIn()');
    },
    
    placeQuickBet: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$placeQuickBet(stake, selectionstring) {
        this._log.debug('placeQuickBet method called');
        if (stake <= 0) {
            this._raiseQuickBetFailed$2(null, 'Stake must be greater than 0');
            return;
        }
        var sel = null;
        try {
            sel = this._splitSelectionString$2(selectionstring);
        }
        catch ($e1) {
            this._raiseQuickBetFailed$2(null, String.format('Unable to split selection string into bet slip selection. sel string:{0}', selectionstring));
            return;
        }
        try {
            this._addSelectionToBetSlip$2(sel);
            this._betSlipService.setStakePerSelection(sel.idfoSelection, stake);
            if (!this._betSlipService.getBetSlipCalculation().length) {
                this._raiseQuickBetFailed$2(sel.idfoSelection, 'Bet Slip Error! Please choose selection');
                return;
            }
            else if (this._accountService$2.get_accountsDetails()[0].TradingBalance <= 0) {
                this._raiseQuickBetFailed$2(sel.idfoSelection, 'Insufficent trading balance');
                return;
            }
            if ((this._betSlipService.getRetainSelectionsAfterPlacement()) && this._diableRetainSelectionsInBetSlip$2) {
                this._betSlipService.setRetainSelectionsAfterPlacement(false);
            }
            this._betSlipService.placeBetSlip(FixedOddsBettingService.OverrideToShowConfirmation.overrideToNotShowConfirmation);
            eval('this.collapse()');
        }
        catch (ex) {
            this._raiseQuickBetFailed$2(sel.idfoSelection, ex.message);
        }
    },
    
    addToBetSlip: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$addToBetSlip(selectionstring) {
        this._log.debug('addToBetSlip method called');
        this._addSelectionToBetSlip$2(this._splitSelectionString$2(selectionstring));
    },
    
    setContainerSize: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$setContainerSize(height) {
        this._log.debug('setContainerSize method called');
        this._setSize$2(height.toString() + 'px');
    },
    
    _raiseQuickBetFailed$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_raiseQuickBetFailed$2(idfoSelection, message) {
        if (idfoSelection) {
            this._betSlipService.removeSelection(idfoSelection);
        }
        eval('swfobject.getObjectById(\'' + this._domElementId + '-' + this._flashDivID$2 + '\').quickBetFailed(\'' + message + '\');');
    },
    
    _raiseBetSlipChanged$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_raiseBetSlipChanged$2() {
        eval('swfobject.getObjectById(\'' + this._domElementId + '-' + this._flashDivID$2 + '\').betSlipChanged(' + this._betSlipService.getSelectionsCount() + ');');
    },
    
    _raiseUserChanged$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_raiseUserChanged$2() {
        eval('swfobject.getObjectById(\'' + this._domElementId + '-' + this._flashDivID$2 + '\').loginStatusChanged(\'' + this._userService$2.get_username() + '\');');
    },
    
    _splitSelectionString$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_splitSelectionString$2(selectionString) {
        return new BoolabusFlashHostComponent.boolabusAddSelection(selectionString);
    },
    
    _getOddsTypeKey$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_getOddsTypeKey$2() {
        return this._fixedOddsBettingService.getPreferences().OddsType.substr(0, 1).toUpperCase();
    },
    
    _addSelectionToBetSlip$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_addSelectionToBetSlip$2(selection) {
        this._betSlipService.addSelection(selection.idfoPriceType, null, selection.idfoEvent, selection.eventName, selection.idfoMarket, selection.marketName, selection.mTag, selection.tTagLeft, selection.tTagRight, selection.cTag, selection.isTrapBettingOptionOn, selection.hadValue, this._returnNumber$2(selection.handicap), this._returnNumber$2(selection.upperBand), this._returnNumber$2(selection.lowerBand), selection.eachWayReduction, selection.eachWayPlaceTerms, selection.idfoSelection, selection.selectionName, selection.priceUp, selection.priceDown, selection.activeBetTypes, selection.fixedOddsPriceTypes, selection.selectionHashCode, selection.isTradable);
    },
    
    _setSize$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_setSize$2(size) {
        this._environment.getDomElement(this._domElementId).style.height = size;
    },
    
    _hasValue$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_hasValue$2(value) {
        if (value === '') {
            return false;
        }
        return true;
    },
    
    _returnNumber$2: function BoolabusFlashHostComponent_BoolabusFlashHostComponent$_returnNumber$2(value) {
        return (this._hasValue$2(value)) ? Number.parse(value) : null;
    }
}


BoolabusFlashHostComponent.boolabusAddSelection.createClass('BoolabusFlashHostComponent.boolabusAddSelection');
BoolabusFlashHostComponent.BoolabusFlashHostComponent.createClass('BoolabusFlashHostComponent.BoolabusFlashHostComponent', Framework.Component.AbstractXsltBasedComponent, UserService.IUserChangedListener, NavigationService.IPageFilterChangedListener, BetSlipService.ISelectionsAddedListener, BetSlipService.ISelectionsRemovedListener);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
// HeadlineComponentv2.js
//


Type.createNamespace('Betfred.Warp.Components.MarketsBox');

////////////////////////////////////////////////////////////////////////////////
// Betfred.Warp.Components.MarketsBox.MarketsBox

Betfred.Warp.Components.MarketsBox.MarketsBox = function Betfred_Warp_Components_MarketsBox_MarketsBox() {
    Betfred.Warp.Components.MarketsBox.MarketsBox.constructBase(this);
}
Betfred.Warp.Components.MarketsBox.MarketsBox.prototype = {
    _headlineImagesBaseUrl$2: null,
    _limit$2: null,
    _category$2: null,
    _numberOfSelections$2: 0,
    _cssclassHeight$2: null,
    
    init: function Betfred_Warp_Components_MarketsBox_MarketsBox$init(environment, componentInstanceName, domElementId, parameters) {
        Betfred.Warp.Components.MarketsBox.MarketsBox.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._headlineImagesBaseUrl$2 = parameters['headline-images-base-url'];
        this._limit$2 = parameters['limit'];
        this._category$2 = parameters['category'];
        this._numberOfSelections$2 = Number.parse(parameters['number-of-selections']);
        this._cssclassHeight$2 = parameters['cssclass-height'];
    },
    
    repaint: function Betfred_Warp_Components_MarketsBox_MarketsBox$repaint() {
        this._log.debug('Repaint');
        this._environment.clearPeriodicalTransformAndUpdate(this._domElementId);
        if (this.isVisible(this._parameters.get_visibleOn(), this._parameters.get_notVisibleOn(), this._navigationService.getAction())) {
            this.show();
            var contentUrl = this._parameters.get_contentUrl().replace('${limit}', this._limit$2).replace('${category}', this._category$2).replace('${cssclass-height}', this._cssclassHeight$2);
            var xsltParameters = this.getXsltParameters(false);
            xsltParameters['headline-images-base-url'] = this._headlineImagesBaseUrl$2;
            xsltParameters['category'] = this._category$2;
            xsltParameters['cssclass-height'] = this._cssclassHeight$2;
            this._environment.transformAndUpdate(this._domElementId, contentUrl, this._parameters.get_xsltUrl(), xsltParameters, Delegate.create(this, function() {
                this.updateCheckboxes();
            }));
        }
        else {
            this.hide();
        }
    },
    
    getXsltParameters: function Betfred_Warp_Components_MarketsBox_MarketsBox$getXsltParameters(displayShowAll) {
        var result = Betfred.Warp.Components.MarketsBox.MarketsBox.callBase(this, 'getXsltParameters', [ displayShowAll ]);
        result['number-of-selections'] = this._numberOfSelections$2;
        return result;
    },
    
    setMarket: function Betfred_Warp_Components_MarketsBox_MarketsBox$setMarket(IDFOMarket) {
        this._log.debug(String.format('setMarket funckingEntry=[{0}]', IDFOMarket));
        this._bettingNavigationService.setMarketFromEvent(IDFOMarket);
    },
    
    setMarketGroup: function Betfred_Warp_Components_MarketsBox_MarketsBox$setMarketGroup(IDFWMarketGroup) {
        this._log.debug(String.format('setMarketGroup funckingEntry=[{0}]', IDFWMarketGroup));
        this._bettingNavigationService.setMarketGroup(0, IDFWMarketGroup);
    }
}


Betfred.Warp.Components.MarketsBox.MarketsBox.createClass('Betfred.Warp.Components.MarketsBox.MarketsBox', AbstractWarpComponents.AbstractMarketGroupListComponent);

// ---- 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)
// -----------------------------------
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('PlainMarketGroupListComponent');

////////////////////////////////////////////////////////////////////////////////
// PlainMarketGroupListComponent.PlainMarketGroupListComponent

PlainMarketGroupListComponent.PlainMarketGroupListComponent = function PlainMarketGroupListComponent_PlainMarketGroupListComponent() {
    PlainMarketGroupListComponent.PlainMarketGroupListComponent.constructBase(this);
}
PlainMarketGroupListComponent.PlainMarketGroupListComponent.prototype = {
    _boNavigationContentUrl$2: null,
    _plainMarketGroupContentUrl$2: null,
    _marketGroupType$2: null,
    _forceTopBONavigation$2: null,
    _autoRefreshAreas$2: null,
    
    get_isComponentVisible: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$get_isComponentVisible() {
        return this.isVisible(this._parameters.get_visibleOn(), this._parameters.get_notVisibleOn(), this._navigationService$2.getAction());
    },
    
    continueLoadingEventHandler: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$continueLoadingEventHandler(sender, eventArgs) {
        this.continueLoading(eventArgs.parameters.getAsString('idfwbonavigation'), eventArgs.domElement);
    },
    
    completeLoadingEventHandler: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$completeLoadingEventHandler(sender, eventArgs) {
        this.completeLoading(eventArgs.parameters.getAsString('idfwmarketgroup'), eventArgs.domElement);
    },
    
    onShowEventEventHandler: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$onShowEventEventHandler(sender, eventArgs) {
        this.showEvent(eventArgs.parameters.getAsString('idfoevent'));
    },
    
    _bettingNavigationService$2: null,
    
    setBettingNavigationService: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$setBettingNavigationService(bettingNavigationService) {
        this._log.debug('SetBettingNavigationService');
        this._bettingNavigationService$2 = bettingNavigationService;
    },
    
    _navigationService$2: null,
    
    setNavigationService: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$setNavigationService(navigationService) {
        this._log.debug('SetNavigationService');
        this._navigationService$2 = navigationService;
        this._navigationService$2.registerTopicalizedPageFilterChangedListener(this, NavigationService.NavigationService.action);
        this._navigationService$2.registerTopicalizedPageFilterChangedListener(this, BettingNavigationService.BettingNavigationService.boNavigation);
    },
    
    onPageFilterChanged: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$onPageFilterChanged(eventSource) {
        this._log.debug('OnPageFilterChanged');
        if (!Boolean.parse(this._forceTopBONavigation$2)) {
            this.update();
        }
    },
    
    init: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$init(environment, componentInstanceName, domElementId, parameters) {
        this._boNavigationContentUrl$2 = parameters['bo-navigation-content-url'];
        this._plainMarketGroupContentUrl$2 = parameters['plain-market-group-content-url'];
        this._marketGroupType$2 = parameters['market-group-type'];
        this._forceTopBONavigation$2 = parameters['force-top-bonavigation'];
        this._autoRefreshAreas$2 = parameters['auto-refresh-areas'];
    },
    
    preTransformation: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$preTransformation(eventArgs) {
        if (!this.get_isComponentVisible()) {
            eventArgs.set_cancelUpdate(true);
            return;
        }
        if (!eventArgs.get_customEventArgs()) {
            this.removeAllScheduledUpdates();
            if (this.get_isComponentVisible()) {
                this._showRightSide$2();
                this.show();
                var boNavigation = this._bettingNavigationService$2.getBONavigation();
                var IDFWBONavigation = (!boNavigation.length || Boolean.parse(this._forceTopBONavigation$2)) ? 'top' : boNavigation[0];
                var contentUrl = this._boNavigationContentUrl$2.replace('${idfwbonavigation}', IDFWBONavigation);
                eventArgs.get_contextObject().contentUrl = contentUrl;
                if (this._autoRefreshAreas$2.toLowerCase().indexOf(this._environment.getPageArea().toLowerCase()) !== -1) {
                    var _autoRefreshPeriod = 60000;
                    this.periodicalUpdate(this._domElementId, contentUrl, this._parameters.get_xsltUrl(), this.getXsltParameters(1), this._domElementId, _autoRefreshPeriod, new Framework.Component.LifeCycleManagement.EventArgs.CustomEventArgs());
                }
            }
            else {
                this.hide();
            }
        }
    },
    
    getXsltParameters: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$getXsltParameters(contextObject) {
        var depth = (!contextObject) ? 1 : contextObject;
        var result = {};
        result['component-instance-name'] = this._componentInstanceName;
        result['component-dom-element-id'] = this._domElementId;
        result['depth'] = depth;
        result['market-group-type'] = this._marketGroupType$2;
        result['force-top-bonavigation'] = this._forceTopBONavigation$2;
        result['auto-refresh-areas'] = this._autoRefreshAreas$2;
        return result;
    },
    
    _showRightSide$2: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$_showRightSide$2() {
        var right = document.getElementById('right');
        if (right) {
            right.style.display = 'block';
        }
    },
    
    continueLoading: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$continueLoading(IDFWBONavigation, domElement) {
        this._log.debug(String.format('ContinueLoading IDFWBONavigation=[{0}]', IDFWBONavigation));
        var contentUrl = this._boNavigationContentUrl$2.replace('${idfwbonavigation}', IDFWBONavigation);
        this.update(domElement, contentUrl, this._parameters.get_xsltUrl(), this.getXsltParameters(2), new Framework.Component.LifeCycleManagement.EventArgs.CustomEventArgs());
    },
    
    completeLoading: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$completeLoading(IDFWMarketGroup, domElement) {
        this._log.debug(String.format('CompleteLoading IDFWMarketGroup=[{0}]', IDFWMarketGroup));
        var contentUrl = this._plainMarketGroupContentUrl$2.replace('${idfwmarketgroup}', IDFWMarketGroup);
        this.update(domElement, contentUrl, this._parameters.get_xsltUrl(), this.getXsltParameters(3), new Framework.Component.LifeCycleManagement.EventArgs.CustomEventArgs());
    },
    
    showEvent: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$showEvent(IDFOEvent) {
        this._log.debug(String.format('ShowEvent IDFOEvent=[{0}]', IDFOEvent));
        this._bettingNavigationService$2.setEvent(IDFOEvent, null, null);
        return false;
    },
    
    showMarketGroup: function PlainMarketGroupListComponent_PlainMarketGroupListComponent$showMarketGroup(IDFOMarketGroup) {
        this._log.debug(String.format('ShowMarketGroup IDFOMarketGroup=[{0}]', IDFOMarketGroup));
        this._bettingNavigationService$2.setMarketGroup(0, IDFOMarketGroup);
        return false;
    }
}


PlainMarketGroupListComponent.PlainMarketGroupListComponent.createClass('PlainMarketGroupListComponent.PlainMarketGroupListComponent', Framework.Component.AbstractXsltBasedComponent, NavigationService.IPageFilterChangedListener);

// ---- 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)
// -----------------------------------
