App.Collections.ImapFolders = Backbone.Collection.extend({
	model: App.Models.ImapFolder,
	comparator:'globalName',
	currentAcct:-1,
	deferred:null,
	
	initialize: function(){
		this.deferred = this.fetch();
	},

	url: function() {
		return App.baseUrl + '/inbox/folder?acct='+this.currentAcct;
	}
});

App.Collections.ImapFolders.prototype.setCurrentAcct = function(acct){
	this.currentAcct = acct;
}

App.Collections.ImapFolders.prototype.getCurrentAcct = function(){
	return this.currentAcct;
}

App.Collections.ImapFolders.prototype.getByGobalName = function(name){
	for(var i=0;i<this.length;i++){
		var m = this.at(i);
		if(m.get('globalName')==name){
			return m;
		}
	}
	return null;
};
