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('BFAreaImageComponent');

////////////////////////////////////////////////////////////////////////////////
// BFAreaImageComponent.BFAreaImageComponent

BFAreaImageComponent.BFAreaImageComponent = function BFAreaImageComponent_BFAreaImageComponent() {
    BFAreaImageComponent.BFAreaImageComponent.constructBase(this);
}
BFAreaImageComponent.BFAreaImageComponent.prototype = {
    _imagefilename$1: null,
    
    init: function BFAreaImageComponent_BFAreaImageComponent$init(environment, componentInstanceName, domElementId, parameters) {
        BFAreaImageComponent.BFAreaImageComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._imagefilename$1 = parameters['image-filename'];
    },
    
    repaint: function BFAreaImageComponent_BFAreaImageComponent$repaint() {
        this._log.debug('Repaint');
        var imageElement = document.createElement('img');
        imageElement.src = String.format('images/areaimage/{0}', this._imagefilename$1);
        imageElement.alt = '';
        document.getElementById(this._domElementId).appendChild(imageElement);
    }
}


BFAreaImageComponent.BFAreaImageComponent.createClass('BFAreaImageComponent.BFAreaImageComponent', Framework.AbstractComponent);

// ---- 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('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('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('DebugInfoComponent');

////////////////////////////////////////////////////////////////////////////////
// DebugInfoComponent.DebugInfoComponent

DebugInfoComponent.DebugInfoComponent = function DebugInfoComponent_DebugInfoComponent() {
    DebugInfoComponent.DebugInfoComponent.constructBase(this);
}
DebugInfoComponent.DebugInfoComponent.prototype = {
    _parameters: null,
    _textColor$1: null,
    _loadDelaySeconds$1: 0,
    
    init: function DebugInfoComponent_DebugInfoComponent$init(environment, componentInstanceName, domElementId, parameters) {
        DebugInfoComponent.DebugInfoComponent.callBase(this, 'init', [ environment, componentInstanceName, domElementId, parameters ]);
        this._parameters = new Framework.CommonComponentParameters(parameters);
        this._loadDelaySeconds$1 = parameters['load-delay-seconds'];
        this._textColor$1 = parameters['text-color'];
    },
    
    start: function DebugInfoComponent_DebugInfoComponent$start() {
        window.setTimeout(Delegate.create(this, this.repaint), this._loadDelaySeconds$1);
    },
    
    repaint: function DebugInfoComponent_DebugInfoComponent$repaint() {
        this._log.debug('Repaint');
        var placeHolder = document.getElementById(this._domElementId);
        placeHolder.style.color = this._textColor$1;
        this._environment.updateDomElementDirect(placeHolder, this._environment.get_debugInfo());
    }
}


DebugInfoComponent.DebugInfoComponent.createClass('DebugInfoComponent.DebugInfoComponent', Framework.AbstractComponent);

// ---- Do not remove this footer ----
// Generated using Script# v0.5.1.0 (http://projects.nikhilk.net)
// -----------------------------------
Type.createNamespace('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)
// -----------------------------------
