(function($) {
	
	$.fn.checkBox = function(params) {
		var opt = {
			imgPath: 'img/i2bforms/bg_checkbox.png',
			imgPathIE6: 'img/i2bforms/bg_checkbox.gif',
			width: 15
		};
		$.extend(opt, params);
		
		return this.each(function() {
			var box = $(this).hide().change(function() {
				updateSpan();
			});
			
			var fakeBox = $('<span></span>').insertAfter(box).css({
				width: opt.width+'px',
				height: opt.width+'px',
				backgroundImage: 'url('+opt.imgPath+')',
				backgroundPosition: 'left top',
				cursor: 'pointer',
				display: 'block',
				'float': 'left'
			}).click(function() {
				if(!box.attr('checked')) {
					box.attr('checked', 'checked');
				} else {
					box.removeAttr('checked');
				}
				updateSpan();
			});
			
			var updateSpan = function() {
				if(box.attr('checked')) {
					fakeBox.css('backgroundPosition','left bottom');
				} else {
					fakeBox.css('backgroundPosition','left top');
				}
			}
			
			if($.browser.msie && $.browser.version < 7)
				fakeBox.css('backgroundImage','url('+opt.imgPathIE6+')');
		});
	};
	
})(jQuery);
