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

var ErrorAssistant = Class.create({

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

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

        this.controller.get('errorText').innerHTML = this.documentAssistant.errorText;

        this.controller.get('dismiss_button').observe(Mojo.Event.tap,
            this.doDismiss.bindAsEventListener(this));

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

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

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

    cleanup: function() {
        //Mojo.Log.info("ErrorAssistant: cleanup");
        this.documentAssistant.errorText = undefined;
        this.controller.window.close();
    },

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

    doDismiss: function(event) {
        //Mojo.Log.info("ErrorAssistant: deactivate");

        this.controller.stageController.popScene();
        this.documentAssistant.showElement('PlugIn');
        this.documentAssistant.turnOnAutoHide();
    },

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