RGB parsing functions in Javascript