(function($) {

$.fn.extend({
	interval: function(tempo, fn) {
		return this.each(function() {
			$.timer.add(this, tempo, fn);
		});
	}
});

$.extend({
	timer: {
		id: 1,
		add: function(elem, tempo, fn) {
			if (!elem.$timers)
				elem.$timers = {};

			if (!elem.$timers[tempo])
				elem.$timers[tempo] = {};

			fn.$timerId = fn.$timerId || this.id++;

			var handler = function() {
				fn.call(elem);
			};

			handler.$timerId = fn.$timerId;

			if (!elem.$timers[tempo][fn.$timerId]) 
				elem.$timers[tempo][fn.$timerId] = window.setInterval(handler, tempo);
		}
	}
});

})(jQuery);
