/**
 * Core definitions for Qik Engine Client
 */

var QikEngine = {
        /** Do debugging output */
        debug : true,

        /** Qik Engine API Key */
        apikey : '94e147c9aff4392f',

        /**
         * Setup console objects in debug mode
         * for browsers that don't have one
         */

        setupConsole : function()
        {
            if (QikEngine.debug && !window.console)
            {
                /* For browsers without Firebug on board */
                window.console = new Object;
                window.console.log = function() {};
                window.console.error = function() {};
            }
        },

        /**
         * Check whether debug is switched on/off explicitly
         * via URL.
         *
         * ...?debug=1 to switch debug on
         * ...?debug=0 to switch debug off
         */

        checkDebug : function()
        {
            if (window.location && window.location.search)
            {
                var m = /debug=(\d+)/.exec(window.location.search);

                if (m)
                    QikEngine.debug = !(m[1] == '0');
            }
        },

        /**
         * Build default Qik Engine API object.
         */

        initAPI : function()
        {
            QikEngine.api = new QikEngine.API(null, QikEngine.apikey);
        },

        /**
         * Default handlers to show/hide "loading" indication.
         */

        showLoading : function() {},
        hideLoading : function() {},
};


/* Do some initial startup */
QikEngine.checkDebug();
QikEngine.setupConsole();
