﻿/// <reference name="MicrosoftAjax.js" />
/// <reference name="dnn.js" assembly="DotNetNuke.WebUtility" />
/// <reference name="dnn.xmlhttp.js" assembly="DotNetNuke.WebUtility" />

// Register Namespace
Type.registerNamespace('Bluestar.Common.Controls');

//**********************************************************************
// CasinoPopupWindow Class
//**********************************************************************
// CasinoPopupWindow - Constructor
Bluestar.Common.Controls.CasinoPopupWindow = function () {
    // Call Base Method
    Bluestar.Common.Controls.CasinoPopupWindow.initializeBase(this);
    // Member Variables
    this._msgs = {};
    // Associate delegates to single member variable dictionary to make it easier to dispose.
    this._delegates = {
        _onInitDelegate: Function.createDelegate(this, this._onInit),
        _onLoadDelegate: Function.createDelegate(this, this._onLoad),
        _onUnloadDelegate: Function.createDelegate(this, this._onUnload),
        _onPropChangedDelegate: Function.createDelegate(this, this._onPropChanged)
    };
    // Event Hookup:
    Sys.Application.add_init(this._delegates._onInitDelegate);
    Sys.Application.add_load(this._delegates._onLoadDelegate);
    Sys.Application.add_unload(this._delegates._onUnloadDelegate);
};
// CasinoPopupWindow - Prototype
Bluestar.Common.Controls.CasinoPopupWindow.prototype = {
    // Properties
    get_ns: function () { return this.get_id() + '_'; },
    get_msgs: function () { return this._msgs; },
    set_msgs: function (value) { this._msgs = value; },
    // ASP.NET AXAX Events
    initialize: function () {
        // Call Base Method
        Bluestar.Common.Controls.CasinoPopupWindow.callBaseMethod(this, 'initialize');
        // Create UI
        // Hookup Event Handlers
    },
    dispose: function () {
        // Clear Handlers.
        // Release Objects.
        // Call Base Method
        Bluestar.Common.Controls.CasinoPopupWindow.callBaseMethod(this, 'dispose');
    },
    // Public Methods
    getMessage: function (key, def) {
        if (this._msgs[key]) {
            return this._msgs[key];
        } else {
            return def;
        }
    },
    launchAppWindow: function (appId, width, height) {
        var oWnd = GetRadWindowManager().GetWindowByName("AppLaunchWindow");
        switch (appId) {
            case 1001:
                // Game History - PlayCheck
                oWnd.SetSize(725, 480);
                oWnd.SetModal(true);
                break;
            case 1002:
                // Transaction History - CashCheck
                break;
            case 1009:
                // Banking Deposit
                break;
            case 1011:
                // Redeem Loyalty Points
                break;
        }
        oWnd.SetUrl('');
        oWnd.Show();
        oWnd.Center();
    },
    // Events
    // OnInit - Raised after all scripts have been loaded but before any objects are created.
    _onInit: function (src, arg) {
        // The init event is raised only one time when the page is first rendered. 
        // subsequent partial-page updates will not re-raise the init event.
    },
    // OnLoad - Raised after all scripts have been loaded and all objects in the application that are created by using $create are initialized.
    _onLoad: function (src, arg) {
        // The load event is raised for all postbacks to the server, which includes asynchronous postbacks.
        var c = Sys.Application.getComponents();
        for (var i = 0; i < c.length; i++) {
            var id = c[i].get_id();
        }
    },
    // OnUnload - Raised before all objects are disposed and before the browser window's window.unload event occurs.
    _onUnload: function (src, arg) {
    },
    // OnPropertyChanged - Raised when a property of a component changes.
    _onPropChanged: function (src, args) {
    }
};
// Register class and inherit from Sys.Component
Bluestar.Common.Controls.CasinoPopupWindow.registerClass("Bluestar.Common.Controls.CasinoPopupWindow", Sys.Component);
