What are ranges of cold and warm colors (http://www.diy-bathroom-remodel.com/images/color_wheel.gif) in RGB?
Looks to me like
if (B>R) { color=cool } else { color=warm }
is a pretty good approximation. You can check this out on your color wheel using: http://www.colorzilla.com/firefox/