/*jslint laxbreak:true */
/*jslint laxcomma:true */
/*jslint loopfunc:true */
/*jslint strict:true */
/*jslint browser:true */
/*jslint devel:true */
define([
	"underscore"
	, "backbone"
	, "models/dmap"
]
, function (_, Backbone, DMAPModel) {
	"use strict";

	var that

	, Collection	= Backbone.Collection.extend({
		attributes:	{}
		, model:	DMAPModel

		, initialize:	function (attributes, options) {
			that	= this
			;

			if (!_.isObject(options)) {
				options	= {};
			}

			if (_.isFunction(options.fetch)) {
				that.fetch = options.fetch;
				delete options.fetch;
			}

			if (!_.isUndefined(options.model)) {
				that.model = options.model;
				delete options.model;
			}

			Collection.__super__.initialize.call(that, [attributes, options]);

			return that;
		}
/*
		, toJSON: function(options) {
			return this.map(function(model){ return model.toJSON(options); });
		}
*/
		, parse: function () {console.error("PARSE", arguments);}

		, fetch:		function (options) {
			that.trigger("dmap.collection.fetch", this, arguments);

			return that;
		}

		, push:			function (attributes, options) {
			that.trigger("dmap.collection.push", this, arguments);

			return that;
		}
	});

	return Collection;
});