Set the site display language based on browser's language on Drupal 6 and 7

drupal language

The other days I needed to have the language of a Drupal 6 site changed based on the user's browser language. This didn't seem to be such a daunting task but I thought that probably there is a module that does this already. Well I didn't found any module and I said to myself that this is something that I had to code although I could not believe that no one else needed this functionality until now...