dojo.registerModulePath('Webgame', '/static/js/Webgame');
dojo.registerModulePath('Dsi', '/static/js');

function addResource(_namespace, _superclass, _object) {
	if(!dojo._hasResource[_namespace]) {
		dojo._hasResource[_namespace] = true;
		dojo.provide(_namespace);
		dojo.declare(_namespace, _superclass, _object);
	}
}

var JavascriptResource = function() {
	var self = this;
	
	self._namespace;
	self._superclass = null;
	self._object;
	
	self.init = function(initObject) {
		addResource(self._namespace, self._superclass, self._object);
		if(typeof initObject != 'undefined' && initObject == true) {
			new dojo.getObject(self._namespace)();
		}
	}
};

Array.prototype.each = function(iterator) {
	for(var i = 0, length = this.length; i < length; i++) {
	    iterator(this[i]);
	}
};

Array.prototype.clear = function() {
  this.length = 0;
  return this;
};

Array.prototype.first = function() {
  return this[0];
};

Array.prototype.last = function() {
  return this[this.length - 1];
};
