Color shifting

ok, what Im trying to do is create a function that takes any color you give it and shifts it lighter or darker and returns the new value.

Ex:

function receives 0x0000FF. It should then seperate it into its three colors, add a specified amount to each and retun it back in the same form. Any ideas on how I can do that?