old_contents: /**@
  * #Crafty Time
  * @category Utilities
  */
  Crafty.c("Delay", {
  	init : function() {
  		this._delays = [];
  		this.bind("EnterFrame", function() {
  			var now = new Date().getTime();
  			var index = this._delays.length;
  			while (--index >= 0) {
  				var item = this._delays[index];
  				if(item.start + item.delay + item.pause < now) {
  					item.func.call(this);
  					// remove item from array
  					this._delays.splice(index,1);
  				}
  			}
  		});
  		this.bind("Pause", function() {
  			var now = new Date().getTime();
  			for(var index in this._delays) {
  				this._delays[index].pauseBuffer = now;
  			}
  		});
  		this.bind("Unpause", function() {
  			var now = new Date().getTime();
  			for(var index in this._delays) {
  				var item = this._delays[index];
  				item.pause += now-item.pauseBuffer;
  			}
  		});
  	},
  	/**@
  	* #.delay
  	* @comp Crafty Time
  	* @sign public this.delay(Function callback, Number delay)
  	* @param callback - Method to execute after given amount of milliseconds
  	* @param delay - Amount of milliseconds to execute the method
  	* 
  	* The delay method will execute a function after a given amount of time in milliseconds.
  	* 
  	* It is not a wrapper for `setTimeout`.
  	* 
  	* If Crafty is paused, the delay is interrupted with the pause and then resume when unpaused
  	*
  	* If the entity is destroyed, the delay is also destroyed and will not have effect. 
  	*
  	* @example
  	* ~~~
  	* console.log("start");
  	* this.delay(function() {
  		 console.log("100ms later");
  	* }, 100);
  	* ~~~
  	*/
  	delay : function(func, delay) {
  		return this._delays.push({
  			start : new Date().getTime(),
  			func : func,
  			delay : delay,
  			pauseBuffer: 0,
  			pause: 0
  		});
  	}
  });
  
new_contents: /**@
  * #Crafty Time
  * @category Utilities
  */
  Crafty.c("Delay", {
  	init : function() {
  		this._delays = [];
  		this.bind("EnterFrame", function() {
  			var now = new Date().getTime();
  			var index = this._delays.length;
  			while (--index >= 0) {
  				var item = this._delays[index];
  				if(item.start + item.delay + item.pause < now) {
  					item.func.call(this);
  					if (item.repeat > 0 ) {
  						// reschedule item
  						item.start = now;
  						item.pause = 0;
  						item.pauseBuffer = 0;
  						if (item.repeat !== Infinity)
  							item.repeat--;
  					} else if (item.repeat === 0) {
  						// remove item from array
  						this._delays.splice(index,1);
  					}
  				}
  			}
  		});
  		this.bind("Pause", function() {
  			var now = new Date().getTime();
  			for(var index in this._delays) {
  				this._delays[index].pauseBuffer = now;
  			}
  		});
  		this.bind("Unpause", function() {
  			var now = new Date().getTime();
  			for(var index in this._delays) {
  				var item = this._delays[index];
  				item.pause += now-item.pauseBuffer;
  			}
  		});
  	},
  	/**@
  	* #.delay
  	* @comp Crafty Time
  	* @sign public this.delay(Function callback, Number delay)
  	* @param callback - Method to execute after given amount of milliseconds
  	* @param delay - Amount of milliseconds to execute the method
  	* @param repeat - How often to repeat the delayed function. A value of 0 triggers the delayed
  	* function exactly once. A value n > 0 triggers the delayed function exactly n+1 times. A
  	* value of Infinity triggers the delayed function indefinitely.
  	* 
  	* The delay method will execute a function after a given amount of time in milliseconds.
  	* 
  	* It is not a wrapper for `setTimeout`.
  	* 
  	* If Crafty is paused, the delay is interrupted with the pause and then resume when unpaused
  	*
  	* If the entity is destroyed, the delay is also destroyed and will not have effect. 
  	*
  	* @example
  	* ~~~
  	* console.log("start");
  	* this.delay(function() {
  		 console.log("100ms later");
  	* }, 100, 0);
  	* ~~~
  	*/
  	delay : function(func, delay, repeat) {
  		this._delays.push({
  			start : new Date().getTime(),
  			func : func,
  			delay : delay,
  			repeat: repeat || 0,
  			pauseBuffer: 0,
  			pause: 0
  		});
  		return this;
  	}
  });
  
subject: Update time.js