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

var SpeeddialchoiceAssistant = Class.create({
	initialize: function(params){//numbers, person,cb){
		this.numbers = params.numbers;
		this.person = params.person;
		this.cb = params.cb;
		this.popto = params.popto;
	},
	
	setup: function(){
		this.person.fullName = this.person.fullName || this.person.getFullName()
		this.controller.get("SpeedDialChoiceHeader").update(Mojo.View.render({
			template:'speeddialchoice/header',
			object: this.person
		}))
		this.listAttrs = {
			emptyTemplate:'speeddialchoice/empty',
			itemTemplate: 'speeddialchoice/phoneNumber'
		}
		this.listModel = {
			items: this.numbers
		}
		this.controller.setupWidget("PhoneNumberList", this.listAttrs, this.listModel);
		this.controller.listen("PhoneNumberList", Mojo.Event.listTap, this.numberClick.bind(this));
	},
	
	numberClick: function(e){
		this.controller.stageController.pushScene("speeddial", {phone:e.item, person:this.person, cb:this.cb, popto:this.popto});
	}
})