App.Views.AccountsMenu = Backbone.View.extend({
	template: _.template( $('#main-account-dropdown-template').html() ),

	initialize: function(){
		_.bindAll(this,'render','onNewAccountPress','onChangeAccounts');
	},

	render: function(){
		var html = this.template();
		this.$el.find('#email-account-dropdown-menu').remove();
		this.$el.append( html );
		return this;
	},

	events : {
		'click .add-new-account-menu-item':'onNewAccountPress',
		'click #email-account-dropdown-menu a' : 'onChangeAccounts'
	},

	onChangeAccounts:function(e) {
		var id = e.target.id;
		var name = e.target.innerText;
		var cid = $(e.target).data('accountId');

		this.trigger('change-account-button-press',e);
	},

	onNewAccountPress: function(e){
		$('#ui-id-3').click();
		$('button.new-account-button').click();
	}
})