/*jslint browser: true, cap: false, passfail: false, undef: false, white: false */
/*global SONGHAY YAHOO */

(function(){

	SONGHAY.ui.Index =
	{
        ajax:SONGHAY.ui.Ajax,
        application:null,
        applicationName:'MegaFunk',
        applicationTitle:'mEga FunK',

        getUri:function()
        {
            var vUriCase = (arguments.length > 0) ? arguments[0] : 'default';
            var vServerCommand = (arguments.length > 1) ? arguments[1] : '';
			var vId = (arguments.length > 2) ? arguments[2] : '';

            var vUri;

            switch(vUriCase)
            {
                case 'default':
                    vUri = 'rest/' + vServerCommand + '/' +
                        'salt/' + new Date().getTime();
                break;

                case 'byid':
                    vUri = 'rest/' + vServerCommand + '/' +
                        vId + '/' +
                        'salt/' + new Date().getTime();
                break;
            }

			return vUri;
        },

        initialize:function()
        {
            //Get a reference to the Client Application (on window.load):
            self.application = self.ui[self.applicationName];

            //Plug this Client into Ajax:
            self.ajax.client = self;

            var o = null; var vValue = '';

            if(self.root.canEnhance() && self.dataForm.loadAppSettings())
            {
                self.application.buildDisplay();
                self.application.splashAndRedirect();
            }
        },

        /**
         * The root container of this Client.
         * @property root
         * @type object
         */
        root:SONGHAY,

        settings:null,

        /**
         * The user interface branch of the root container.
         * @property ui
         * @type object
         */
        ui:SONGHAY.ui
		
	};

    //Module-level "this":
    var self = SONGHAY.ui.Index;

    YAHOO.util.Event.addListener(window, 'load', self.initialize);

})();
