(function($){
	$.fn.jNice = function(options){
		var self = this;
	
		/* each form */
		this.each(function(){
			
			$('input:radio', this).each(function(){
				$input = $(this);
				$input.addClass('jNiceHidden').wrap('<span class="jRadioWrapper"></span>');
				var $wrapper = $input.parent();
				$wrapper.prepend('<a href="#" class="jNiceRadio" rel="'+ this.name +'"></a>');
				/* Click Handler */
				$('a.jNiceRadio', $wrapper).click(function(){
						var $a = $(this);
						$a.siblings('input')[0].checked = true;
						$a.addClass('jNiceChecked');
						/* uncheck all others of same name */
						$('a[rel="'+ $a.attr('rel') +'"]').not($a).each(function(){
							$(this).removeClass('jNiceChecked').siblings('input')[0].checked=false;
						});
						return false;
				});
				/* set the default state */
				if (this.checked){$('a.jNiceRadio', $wrapper).addClass('jNiceChecked');}
			});
	
		}); /* End Form each */
		

		
		
	};/* End the Plugin */

	/* Automatically apply to any forms with class jNice */
	$(function(){$('form.jNice').jNice();	});

})(jQuery);
				   
