﻿


	
	jQuery.fn.prettyRadios = function(settings) {
		
		settings = jQuery.extend({
					width: 32,
					height: 30,
					className : 'prettyRadio prRoomType'
				}, settings);

    var index = 0;
		$(this).each(function(){			
			$label = $('label[for="'+$(this).attr('id')+'"]');
			
			$label.addClass(settings.className);
			$label.addClass(settings.className + "-" + index);
			$label.attr('title', $label.text()).text('');
			
			if(this.checked) {
			  $label[0].className = $label[0].className.replace('-checked', '') + '-checked';
			}			
			
			index++;
			
			$label.bind('click',function(){
			  $input = $('input#' + $(this).attr('for'));
			  $input.triggerHandler('click');
			  
			  if(this.className.indexOf('-checked') == -1) {
			    $('input[name="'+$input.attr('name')+'"]').each(function(){
						$l2 = $('label[for="' + $(this).attr('id')+'"]');
						$l2[0].className = $l2[0].className.replace('-checked', '');
					});
			    this.className = this.className.replace('-checked', '') + '-checked';
			  }
			  else {
			    this.className = this.className.replace('-checked', '');
			  }
			  
			});
				
		});
	};


