/* 
 *	Usage example:
 *		cron = new CRON({
 *			interval: 100,
 *			callback: function () {
 *				//Some code you want to repeat every 100ms
 *				//this.stop(); - will stop cron
 *			}
 *		)};
 */

if (typeof CRON == 'undefined') {
	CRON = function (params) {
		this.interval = parseInt(params.interval) || 1000;
		this.id = 0;
		this.callback = params.callback;

		this.start = function () {
			var thisObj = this;
			this.stop();
			this.id = window.setInterval(function(){thisObj.action();}, this.interval);
		}

		this.action = function () {
			this.callback();
		}

		this.stop = function () {
			window.clearInterval(this.id);
		}
	}
}

