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

var SendEmailAssistant = Class.create({
	initialize: function() {
		FirstUseUtil.addDashboardSmall($('target'));
		saveCurrentState("send-email");
	},
	
	setup: function() {
		var data = {
			email: Account.email
		};
		var message = $L("We sent an email to #{email}. If you don't receive the email shortly, check your junk mail folder.").interpolate(data);
		$('recoverInfo').innerHTML="<p>"+$L(message)+"</p>";
		$('target').addEventListener(Mojo.Event.tap, FirstUseUtil.tapHandler.bindAsEventListener(this));
				
		// Listen to ## key presses
		this.controller.listen(this.controller.sceneElement, Mojo.Event.keydown, FirstUseUtil.handleKeyPressEvent.bind(this));	
		$('next').observe(Mojo.Event.tap,this.showIntro.bindAsEventListener(this));	
	},
	
	handleCommand: function(event) {
		if (event.type == Mojo.Event.back) {
			Mojo.Log.info("------- Blocking back ----------");
			event.preventDefault();
			event.stopPropagation();
		}	
		if(Account.isInvalidToken == true) {
			Mojo.Controller.stageController.pushScene('invalid-token');
			return;
		}
		Mojo.Controller.stageController.pushScene('login');
	},
	
	activate: function() {
		
	},
	
	showIntro: function() {
		if(Account.isInvalidToken == true) {
			Mojo.Controller.stageController.pushScene('invalid-token');
			return;
		}
		Mojo.Controller.stageController.pushScene('intro');
	}
	
});	
