/**
 * metin
 */
(function($) {
	$.fn.extend( {
		loopy : function(callback, options) {
			this.oInterval = null;
			var defaults = {
				time : 3,
				stop : 0,
				startDelay : 0
			};
			options = $.extend(defaults, options);

			this.stop = function() {
				clearInterval(this.oInterval);
				this.oInterval = null;
			};

			this.start = function() {
				if (null === this.checkRun()) {
					this.oInterval = setInterval(this.callback, (options.time * 1000));
				}
			};

			this.checkRun = function() {
				return this.oInterval;
			};

			this.callback = callback;

			this.start();

			if (options.stop * 1000 >= 1) {
				var t = this;
				setTimeout(function() {
					t.stop();
				}, options.stop * 1000);
			}

			return this;
		}
	});

})(jQuery);
