﻿(function($){
	$.fn.formFieldEnabler = function(options){
		var targets;
		
		options = $.extend({
			targets:null,
			type:'disable'
		},options);
		
		
		
		targets = $.isFunction(options.targets)?options.targets:function(){return $(options.targets)};
		
		return this.each(function(){
			$(this).click(function(e){
				if(options.type == 'disable'){
					targets.call(this,this).attr('disabled', e.target.checked?'':'disabled');
				}
				else{
					targets.call(this,this).toggle(e.target.checked);
				}
			});
		});
	
	};
})(jQuery)