jQuery.fn.vimOption = function() {
	$.each(
		$(this),
		function (i, element) {
			function positiveOption(input) {
				var val = input.val();
				val = val.replace(/^no/, '');
				input
					.val(val)
					.attr('checked', 'checked');
			}
			function negativeOption(input) {
				var val = input.val();
				val = "no"+val;
				input
					.val(val)
					.attr('checked', 'checked');
			}
			function dropOption(input) {
				positiveOption(input);
				input.removeAttr('checked');
			}
			var option = $(element);
			option.css('padding', '3px');
			option.children('input[type=checkbox]').hide();
			option.children('label.three-states').toggle(function() {
				$(this).css({'font-weight': 'bold', 'text-decoration': 'none'});
				positiveOption($(this).prev())
			}, function() {
				$(this).css({'font-weight': 'bold', 'text-decoration': 'line-through'});
				negativeOption($(this).prev());
			}, function() {
				$(this).css({'font-weight': 'normal', 'color': '#000', 'text-decoration': 'none'});
				dropOption($(this).prev());
			});
			option.children('label:not(label.three-states)').toggle(function() {
				$(this).css({'font-weight': 'bold'});
				positiveOption($(this).prev());
			}, function() {
				$(this).css({'font-weight': 'normal'});
				dropOption($(this).prev());
			});
		}
	);
}

$(function() {
	$('div.vim-option').vimOption();
})
