(function($) {
	$.fn.extend({
		toggleCheck: function(fn1, fn2) {
			var $$ = $(this);
			$$.each(function() {
				$(this).click(function() {
					if (this.checked)
						$(this).check(fn1);
					else
						$(this).uncheck(fn2);
				});
			});
		},
		
		check: function(fn) {
			if (typeof fn === 'function')
				fn.apply(this);
			else
				this.checked === true;
		},
		
		uncheck: function(fn) {
			if (typeof fn === 'function')
				fn.apply(this);
			else
				this.checked === false;
		},
		
		checkAll: function() {
			var $$ = $(this);
			$$.each(function() {
				this.checked = true;
			});
		},
		
		unCheckAll: function() {
			var $$ = $(this);
			$$.each(function() {
				this.checked = false;
			});
		}
	});
})(jQuery);