if( jQuery ) {
	(function($){
		$.fn.checkBox = function() {
			var checkboxes = $( this ).filter( ':checkbox, :radio' );
			var radio = {};

			checkboxes.each(function(){
				if( this.styledCheckbox )
					return;
			
				this.styledCheckbox = true;

				(function(el){
					var span = $( '<span class="png_fix ui-' + el.type + '"></span>' ).addClass( el.checked ? 'ui-' + el.type + '-state-checked' : false );
					var self = $( el ).addClass('ui-input');
				
					if( el.type == 'radio' ) {
						if( radio[ el.name ] )
							radio[ el.name ].push( span );
						else
							radio[ el.name ] = new Array( span );
					}

					self.before( span ).change(function() {
						if( el.checked ) {
							if( el.type == 'radio' ) {
								for( var i in radio[ el.name ] )
									radio[ el.name ][i].removeClass( 'ui-' + el.type + '-state-checked' );
							}
							span.addClass('ui-' + el.type + '-state-checked');
						} else
							span.removeClass('ui-' + el.type + '-state-checked');
					});

					span.click(function() {
						if( self.attr('disabled') == true )
							return false;

						self.click();
						self.change();
						self.mouseup();
					});

					$( 'label[for=' + el.name + ']' ).click(function(){
						span.click();
					});					
				})(this);
			});
			return checkboxes;
		}
	})(jQuery);
}