/* Copyright 2009 Palm, Inc.  All rights reserved. */

var UpdateErrorAssistant = Class.create({
	initialize: function(){
		FirstUseUtil.addDashboardSmall($('target'));
		Account.action = "";
		saveCurrentState("update-error");
	},
	
	setup: function(){
		
		this.buttonAttr = {
			disabledProperty: 'disabled'
		};
		
		this.buttonModel = {
			disabled: false,
			buttonLabel : $L('Try Again'),
			buttonClass: 'palm-button'
		};
		this.tryAgainBtn = this.controller.get("tryAgain");
		
		this.controller.setupWidget('tryAgain', this.buttonAttr, this.buttonModel);
		Mojo.listen(this.controller.get('tryAgain'), Mojo.Event.tap, this.pushUpdates.bindAsEventListener(this));
		
		$('target').addEventListener(Mojo.Event.tap, FirstUseUtil.tapHandler.bindAsEventListener(this));
				
		this.keyPressEventHandler =  FirstUseUtil.handleKeyPressEvent.bind(this);
		this.controller.listen(this.controller.sceneElement, Mojo.Event.keydown, this.keyPressEventHandler);
		
		// Allow screen dimming
		if(displayRequest) {
			displayRequest.cancel();
		}
			
	},
	
	handleCommand: function(event) {
		if (event.type == Mojo.Event.back) {
			event.preventDefault();
			event.stopPropagation();
		}	
	},
						
	pushUpdates: function(event){
		this.buttonModel.disabled = true;
		this.controller.modelChanged(this.buttonModel);
		Mojo.Controller.stageController.swapScene('update-intro');
	}
});	

