(function($){
	$.hsb2rgb = function (hue, saturation, brightness) {
		var r = 0;
	    var g = 0;
	    var b = 0;
		if (saturation == 0.0) {
			r = g = b = Math.floor(brightness * 255.0 + 0.5);
		}
		else {
	        var h = (hue - Math.floor(hue)) * 6.0;
	        var f = h - Math.floor(h);
	        var p = brightness * (1.0 - saturation);
	        var q = brightness * (1.0 - saturation * f);
	        var t = brightness * (1.0 - (saturation * (1.0 - f)));
			switch (Math.floor(h)) {
				case 0:
		            r = Math.floor(brightness * 255.0 + 0.5);
		            g = Math.floor(t * 255.0 + 0.5);
		            b = Math.floor(p * 255.0 + 0.5);
		            break;
				case 1:
		            r = Math.floor(q * 255.0 + 0.5);
		            g = Math.floor(brightness * 255.0 + 0.5);
		            b = Math.floor(p * 255.0 + 0.5);
		            break;
	            case 2:
		            r = Math.floor(p * 255.0 + 0.5);
		            g = Math.floor(brightness * 255.0 + 0.5);
		            b = Math.floor(t * 255.0 + 0.5);
            		break;
	            case 3:
		            r = Math.floor(p * 255.0 + 0.5);
		            g = Math.floor(q * 255.0 + 0.5);
		            b = Math.floor(brightness * 255.0 + 0.5);
		            break;
				case 4:
		            r = Math.floor(t * 255.0 + 0.5);
		            g = Math.floor(p * 255.0 + 0.5);
		            b = Math.floor(brightness * 255.0 + 0.5);
		            break;
				case 5:
		            r = Math.floor(brightness * 255.0 + 0.5);
		            g = Math.floor(p * 255.0 + 0.5);
		            b = Math.floor(q * 255.0 + 0.5);
		            break;
			}
		}
		return "rgb("+r+","+g+","+b+")";
	}
})(jQuery);