Install the most recent java update (assuming you are using 10.6.8 or Lion) which advertises itself as being able to remove the trojans.
Java for OS X Lion 2012-003
Java for Mac OS X 10.6 Update 8
If you don't want to do these installs then at least go to F_Secure's Flashback Removal Tool web page, download their Flashback trojan detection/removal tool, and follow the instructions you find there.
Ads poping up in the browser is usually not a sign of these trojans. But there is at least one "app" that can cause some of this. By any chance did you install MacKeeper?
Do not install MacKeeper (by Klaus1)
https://discussions.apple.com/docs/DOC-3035