/* Copyright 2009 Palm, Inc.  All rights reserved. */
/*global Mojo, Class, $L */
/*jslint rhino:true, undef:true */

var TrialAssistant = Class.create({

    initialize: function(docAssistant) {
        //Mojo.Log.info("TrialAssistant: initialize");
		this.docAssistant = docAssistant;
		this.controller = docAssistant.controller;
    },

    setup: function() {
        //Mojo.Log.info("TrialAssistant: setup");

        // Set up the view buttons (header)
        this.viewMenuModel = { visible: true, items: this.viewMenu };
        this.controller.setupWidget(Mojo.Menu.viewMenu,
                                    undefined,
                                    this.viewMenuModel);

        this.controller.get('trial_button').observe(Mojo.Event.tap,
            this.doTrial.bindAsEventListener(this));

        this.controller.setupWidget(Mojo.Menu.appMenu,
                                    { omitDefaultItems: true },
                                    this.appMenuModel);
    },

    activate: function() {
        //Mojo.Log.info("TrialAssistant: activate");
    },

    ready: function() {
        //Mojo.Log.info("TrialAssistant: ready");
    },

    cleanup: function() {
        //Mojo.Log.info("TrialAssistant: cleanup");
    },

    deactivate: function() {
        //Mojo.Log.info("TrialAssistant: deactivate");
    },

    doTrial: function(event) {
        //Mojo.Log.info("TrialAssistant: doTrial");

        var openParams = {
                           scene: 'page',
                           target: 'http://www.dataviz.com/starttrialDTGEditor'
                         };

        this.controller.serviceRequest(
                'palm://com.palm.applicationManager',
                {
                  method: 'open',
                  parameters: {
                                id: 'com.palm.app.browser',
                                params: openParams
                              }
                });
    },

    appMenuModel: {
                    items: [
                             {
                               label: $L('Help...'),
                               command: Mojo.Menu.helpCmd,
                               disabled: true
                             }
                           ]
                  },

    viewMenu: [ { template: 'dataviz/dataviz_header' } ]
});
