jQuery.rgb2hex = function(rgb)
{
	var rgb_match = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
	if(rgb_match == null)
		return rgb;
	function hex(x)
	{
		hexDigits = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f");
		return isNaN(x) ? "00" : hexDigits[(x - x % 16) / 16] + hexDigits[x % 16];
	}
	return "#" + hex(rgb_match[1]) + hex(rgb_match[2]) + hex(rgb_match[3]);
};

