Scenario: a user can change the default design of a site by selecting a color. This color is applied to the menu background color. The problem is that I have to change the menu text color depending on the selected color (e.g., if the user chose darkgreen, then the text color needs to be white).
I only want to use or white or black as a text color for the menu and want to know how I can calculate whether white or black results in the best readability.
Update
The website is aimed at soccer teams. Since soccer teams often have specific colors I want to give them the option to add team colors to the site. Templates won't do because I can't provide all the colors with templates. I also opted not to give them the option to define the text color, since I think this is a physics problem (contrast).