Help identifying taxonomy of referrer page

Hello,

I was wondering if someone could help me figure out how to add a body class (taxonomy) to a post that matches the taxonomy of the referrer page (all of a custom post type). What I am trying to accomplish is having color coded ( by taxonomy) single product pages that display a list of accessories for that product. However, each accessory may belong to several different products. So if a user clicks on an accessory from my blue styled product page the accessory page should be styled blue. Yet if a user accesses that same accessory from a red styled product page the accessory page should be styled red.

I have been searching to a solution for months and implemented a ridiculous hack approach that works but involves incorporating extra pages (basically duplicate pages, one for each taxonomy) risking duplicate content issues but now I need to go back and find a cleaner solution. Any help would be greatly appreciated. Thanks