/*
	Controller class for "Are you sure you want to remove account?" confirmation dialog

Copyright 2009 Palm, Inc.  All rights reserved.

*/
var PurgeAccountConfirmDialogAssistant = Class.create({
	
	initialize: function(sceneAssistant) {
		this.sceneAssistant = sceneAssistant;
		this.acctDomain = this.sceneAssistant.acctDomain;
	},
	
	setup : function(widget) {
		//Mojo.Log.info("confirm-purgeaccount: setup");
		this.widget = widget;
		
		if (this.acctDomain == 'eas') {
			this.sceneAssistant.controller.get("purge_acct_msg").hide();
			this.sceneAssistant.controller.get('RemoveAccount').update($L('Remove Exchange account'));
			this.sceneAssistant.controller.get('KeepAccount').update($L('Keep Exchange account'));
		} else {
			this.sceneAssistant.controller.get("purge_eas_acct_msg").hide();
		}
  },
	
	handleRemoveAccount:function(event){
		//Mojo.Log.info("confirm-purgeaccount: handleRemoveAccount");
		this.widget.mojo.close();
		Event.stop(event);
		this.sceneAssistant.yesToPurgeAccountConfirm();
	},
	
	handleKeepAccount:function(event){
		//Mojo.Log.info("confirm-purgeaccount: handleKeepAccount");
		this.widget.mojo.close();
		Event.stop(event);
		this.sceneAssistant.noToPurgeAccountConfirm();
	},
	
	activate: function() {
		this.removeAccountTapHandler = this.handleRemoveAccount.bindAsEventListener(this);
		this.sceneAssistant.controller.get('RemoveAccount').addEventListener(Mojo.Event.tap, this.removeAccountTapHandler);
		this.keepAccountTapHandler = this.handleKeepAccount.bindAsEventListener(this);
		this.sceneAssistant.controller.get('KeepAccount').addEventListener(Mojo.Event.tap, this.keepAccountTapHandler);
	},
	
	deactivate:function(){
		//Mojo.Log.info("confirm-purgeaccount: cleanup");
	  this.sceneAssistant.controller.get('RemoveAccount').removeEventListener(Mojo.Event.tap, this.removeAccountTapHandler);
		this.sceneAssistant.controller.get('KeepAccount').removeEventListener(Mojo.Event.tap, this.keepAccountTapHandler);
	}
});