﻿(function($){

$.fn.timeout = function(option, msec){
	var $this = this, timeout;
	$this.option = option;
	if(option == "clear" && (timeout = $this.data("timeout"))) window.clearTimeout(timeout);
	else if($.isFunction(option) && msec) 
		$this.data("timeout", window.setTimeout(function(){
			$this.option()
		}, msec));
	return this;
}

$.fn.interval = function(option, msec){
	var $this = this;
	if(option == "clear") $this.timeout("clear");
	if ($.isFunction(option) && msec){
		var opt = function(){
			option();
			$this.timeout(opt, msec);
		}
		$this.timeout(opt, msec);
	}
	return this;
}

})(jQuery);