
KISSY.add("qr/collection",function(S, mvc,Model) {
	function Collection(config){
		var self = this;
		Collection.superclass.constructor.apply(this, arguments);
		if(config != undefined){
			self.set('url',config.url);
			self.set('parse',config.parse);
		}
	}
	S.extend(Collection, mvc.Collection,{
		update:function(json){
			var newObj = new Model(json);
			var id = newObj.get('id');
			var obj = this.getById(id);
			for(i = 0 ; i < this.get('models').length;i++){
				if(id == this.get('models')[i].get('id')){
					this.get('models')[i] = newObj;
				}
			}
			
		},
		updateByIndex:function(index,json){
			var newObj = new Model(json);
			var obj = this.at(index);
			obj = newObj;
		},
		indexOf:function(model){
			var self = this;
			var index = -1;
			for(i = 0;i < self.get('models').length;i++){
				if(model.get('id') == self.get('models')[i].get('id')){
					index = i;
				}
			}
			return index;
		}
	},{
	      ATTRS:{
	          model:{
	              value:Model
	          }
	      }}
	  );
	return Collection;
}, {attach:false,requires:["mvc","./model"]});

