register("pedro.clock");

pedro.clock.interval = { registry : [] }

pedro.clock.interval.register = function(obj){ 
	this.registry[obj.key] = obj; 
}

pedro.clock.interval.unregister = function(obj){ 
	this.registry[obj.key] = null; 
}

pedro.clock.interval.exec = function(key){ 
	if(!isUndef(this.registry[key])){ 
		this.registry[key].execute(); 
	} 
}

var AbstractInterval = pedro.Base.extend(
	function(millis){
		this.key = (new Date()).getTime();
		this.millis = millis;
		this.ref = null;
		this.register(this);
	}
);

AbstractInterval.prototype.register = function(){ 
	pedro.clock.interval.register(this); 
}

AbstractInterval.prototype.unregister = function(){ 
	pedro.clock.interval.unregister(this); 
}

AbstractInterval.prototype.start = function(){
	this.ref = window.setInterval("pedro.clock.interval.exec("+this.key+")",this.millis);
}

AbstractInterval.prototype.stop = function(){ window.clearInterval(this.ref); }

AbstractInterval.prototype.execute = function(){ /* Make Custom */ }

