It's going to be messy trying to get a name from the rgb value. I would instead encourage you to use the jQuery Color plugin to determine whether the current color is a particular value or not:
if ( $.Color( colorName ).is( "red" ) ) {
/* Do X */
} else {
/* Do Y */
}